mirror of
https://github.com/golang/go
synced 2024-11-25 11:57:58 -07:00
go/scanner: use strconv.QuoteRune now that it is available
R=r, rsc CC=golang-dev https://golang.org/cl/4538096
This commit is contained in:
parent
8c2078796d
commit
a1c92c612f
@ -22,7 +22,6 @@ package scanner
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -671,7 +670,7 @@ scanAgain:
|
|||||||
tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR)
|
tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR)
|
||||||
default:
|
default:
|
||||||
if S.mode&AllowIllegalChars == 0 {
|
if S.mode&AllowIllegalChars == 0 {
|
||||||
S.error(offs, fmt.Sprintf("illegal character '%c' (%U)", ch, ch))
|
S.error(offs, "illegal character "+strconv.QuoteRune(ch))
|
||||||
}
|
}
|
||||||
insertSemi = S.insertSemi // preserve insertSemi info
|
insertSemi = S.insertSemi // preserve insertSemi info
|
||||||
}
|
}
|
||||||
|
@ -650,8 +650,9 @@ var errors = []struct {
|
|||||||
pos int
|
pos int
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
{"\a", token.ILLEGAL, 0, "illegal character '\a' (U+0007)"},
|
{"\a", token.ILLEGAL, 0, "illegal character '\\a'"},
|
||||||
{`#`, token.ILLEGAL, 0, "illegal character '#' (U+0023)"},
|
{`#`, token.ILLEGAL, 0, "illegal character '#'"},
|
||||||
|
{`…`, token.ILLEGAL, 0, "illegal character '\\u2026'"},
|
||||||
{`' '`, token.CHAR, 0, ""},
|
{`' '`, token.CHAR, 0, ""},
|
||||||
{`''`, token.CHAR, 0, "illegal character literal"},
|
{`''`, token.CHAR, 0, "illegal character literal"},
|
||||||
{`'\8'`, token.CHAR, 2, "unknown escape sequence"},
|
{`'\8'`, token.CHAR, 2, "unknown escape sequence"},
|
||||||
|
Loading…
Reference in New Issue
Block a user