Browse Source

Handle eof in comments and do not prematurely close file handler

master v0.2.3
Brett Langdon 9 years ago
parent
commit
c9dd35bf48
No known key found for this signature in database GPG Key ID: A2ECAB73CE12147F
2 changed files with 1 additions and 2 deletions
  1. +0
    -1
      parser.go
  2. +1
    -1
      scanner.go

+ 0
- 1
parser.go View File

@ -40,7 +40,6 @@ func NewParser(reader io.Reader) *Parser {
// NewFileParser will create and initialize a new Parser from a provided from a filename string
func NewFileParser(filename string) (*Parser, error) {
reader, err := os.Open(filename)
defer reader.Close()
if err != nil {
return nil, err
}


+ 1
- 1
scanner.go View File

@ -167,7 +167,7 @@ func (scanner *Scanner) parseComment() {
scanner.curTok.Literal = ""
for {
scanner.readRune()
if scanner.curCh == '\n' {
if scanner.curCh == '\n' || scanner.curCh == eof {
break
}
scanner.curTok.Literal += string(scanner.curCh)


Loading…
Cancel
Save