diff options
Diffstat (limited to 'parser')
-rw-r--r-- | parser/reader.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/parser/reader.go b/parser/reader.go index 28cbe3d..d9a1712 100644 --- a/parser/reader.go +++ b/parser/reader.go @@ -35,15 +35,15 @@ type reader struct { // parser forwards. func (reader *reader) peekRune() (rune, error) { bytes, _ := reader.r.Peek(4) - r, size := utf8.DecodeRune(bytes) - switch { + switch r, size := utf8.DecodeRune(bytes); { case r == utf8.RuneError && size == 0: return 0, io.EOF case r == utf8.RuneError && size == 1: return 0, errors.New("Tried to decode malformed UTF-8") + default: + return r, nil } - return r, nil } // unreadRune moves the parser one rune back, allowing for basic backtracking. |