Merge pull request #68 from Buzer/lastline_comment

Fixed hang when comment is on the last line of the file
This commit is contained in:
Mitchell Hashimoto 2015-11-28 14:43:01 -08:00
commit 5bd8787dc9
3 changed files with 9 additions and 2 deletions

View File

@ -231,6 +231,10 @@ func TestParse(t *testing.T) {
"comment.hcl",
false,
},
{
"comment_lastline.hcl",
false,
},
{
"comment_single.hcl",
false,

View File

@ -0,0 +1 @@
#foo

View File

@ -224,10 +224,12 @@ func (s *Scanner) scanComment(ch rune) {
// single line comments
if ch == '#' || (ch == '/' && s.peek() != '*') {
ch = s.next()
for ch != '\n' && ch >= 0 {
for ch != '\n' && ch >= 0 && ch != eof {
ch = s.next()
}
s.unread()
if ch != eof && ch >= 0 {
s.unread()
}
return
}