Fixed hang when comment was on the last line of the file
This commit is contained in:
parent
f0ca992551
commit
2ec27b6be2
@ -231,6 +231,10 @@ func TestParse(t *testing.T) {
|
|||||||
"comment.hcl",
|
"comment.hcl",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"comment_lastline.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"comment_single.hcl",
|
"comment_single.hcl",
|
||||||
false,
|
false,
|
||||||
|
1
hcl/parser/test-fixtures/comment_lastline.hcl
Normal file
1
hcl/parser/test-fixtures/comment_lastline.hcl
Normal file
@ -0,0 +1 @@
|
|||||||
|
#foo
|
@ -224,10 +224,12 @@ func (s *Scanner) scanComment(ch rune) {
|
|||||||
// single line comments
|
// single line comments
|
||||||
if ch == '#' || (ch == '/' && s.peek() != '*') {
|
if ch == '#' || (ch == '/' && s.peek() != '*') {
|
||||||
ch = s.next()
|
ch = s.next()
|
||||||
for ch != '\n' && ch >= 0 {
|
for ch != '\n' && ch >= 0 && ch != eof {
|
||||||
ch = s.next()
|
ch = s.next()
|
||||||
}
|
}
|
||||||
s.unread()
|
if ch != eof && ch >= 0 {
|
||||||
|
s.unread()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user