diff options
Diffstat (limited to 'vendor/github.com/tdewolff/parse/xml/lex.go')
-rw-r--r-- | vendor/github.com/tdewolff/parse/xml/lex.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/vendor/github.com/tdewolff/parse/xml/lex.go b/vendor/github.com/tdewolff/parse/xml/lex.go index 0f1393c..c7ea4d1 100644 --- a/vendor/github.com/tdewolff/parse/xml/lex.go +++ b/vendor/github.com/tdewolff/parse/xml/lex.go @@ -81,11 +81,10 @@ func NewLexer(r io.Reader) *Lexer { // Err returns the error encountered during lexing, this is often io.EOF but also other errors can be returned. func (l *Lexer) Err() error { - err := l.r.Err() - if err != nil { - return err + if l.err != nil { + return l.err } - return l.err + return l.r.Err() } // Restore restores the NULL byte at the end of the buffer. @@ -107,7 +106,9 @@ func (l *Lexer) Next() (TokenType, []byte) { break } if c == 0 { - l.err = parse.NewErrorLexer("unexpected null character", l.r) + if l.r.Err() == nil { + l.err = parse.NewErrorLexer("unexpected null character", l.r) + } return ErrorToken, nil } else if c != '>' && (c != '/' && c != '?' || l.r.Peek(1) != '>') { return AttributeToken, l.shiftAttribute() @@ -148,7 +149,7 @@ func (l *Lexer) Next() (TokenType, []byte) { l.r.Move(7) return CDATAToken, l.shiftCDATAText() } else if l.at('D', 'O', 'C', 'T', 'Y', 'P', 'E') { - l.r.Move(8) + l.r.Move(7) return DOCTYPEToken, l.shiftDOCTYPEText() } l.r.Move(-2) @@ -164,7 +165,9 @@ func (l *Lexer) Next() (TokenType, []byte) { if l.r.Pos() > 0 { return TextToken, l.r.Shift() } - l.err = parse.NewErrorLexer("unexpected null character", l.r) + if l.r.Err() == nil { + l.err = parse.NewErrorLexer("unexpected null character", l.r) + } return ErrorToken, nil } l.r.Move(1) |