Skip to content

Commit 88a6f16

Browse files
authored
Merge pull request #86 from Anaminus/fix-skipComment
Fix skipComment returning EOF as regular error
2 parents 1372282 + 7374c74 commit 88a6f16

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

auxiliary.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,21 @@ func NewLibrary(l *State, functions []RegistryFunction) {
461461

462462
func skipComment(r *bufio.Reader) (bool, error) {
463463
bom := "\xEF\xBB\xBF"
464-
if ba, err := r.Peek(len(bom)); err != nil {
464+
if ba, err := r.Peek(len(bom)); err != nil && err != io.EOF {
465465
return false, err
466466
} else if string(ba) == bom {
467467
_, _ = r.Read(ba)
468468
}
469469
if c, _, err := r.ReadRune(); err != nil {
470+
if err == io.EOF {
471+
err = nil
472+
}
470473
return false, err
471474
} else if c == '#' {
472475
_, err = r.ReadBytes('\n')
476+
if err == io.EOF {
477+
err = nil
478+
}
473479
return true, err
474480
}
475481
return false, r.UnreadRune()

0 commit comments

Comments
 (0)