]> Cypherpunks repositories - gostls13.git/commitdiff
go/scanner: use strconv.QuoteRune now that it is available
authorRobert Griesemer <gri@golang.org>
Wed, 25 May 2011 18:16:17 +0000 (11:16 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 25 May 2011 18:16:17 +0000 (11:16 -0700)
R=r, rsc
CC=golang-dev
https://golang.org/cl/4538096

src/pkg/go/scanner/scanner.go
src/pkg/go/scanner/scanner_test.go

index 82b9aba0d68714b0afe2041b03a3082fbf88e7e8..60ac45c86e06fd668c47d73cd981eee2bef1a13c 100644 (file)
@@ -22,7 +22,6 @@ package scanner
 
 import (
        "bytes"
-       "fmt"
        "go/token"
        "path/filepath"
        "strconv"
@@ -671,7 +670,7 @@ scanAgain:
                        tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR)
                default:
                        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
                }
index 657e85122e9d0e3b627ea11245fe892deac55059..5b99bede11818f4a444aaea4e0e294857544858c 100644 (file)
@@ -650,8 +650,9 @@ var errors = []struct {
        pos int
        err string
 }{
-       {"\a", token.ILLEGAL, 0, "illegal character '\a' (U+0007)"},
-       {`#`, token.ILLEGAL, 0, "illegal character '#' (U+0023)"},
+       {"\a", token.ILLEGAL, 0, "illegal character '\\a'"},
+       {`#`, token.ILLEGAL, 0, "illegal character '#'"},
+       {`…`, token.ILLEGAL, 0, "illegal character '\\u2026'"},
        {`' '`, token.CHAR, 0, ""},
        {`''`, token.CHAR, 0, "illegal character literal"},
        {`'\8'`, token.CHAR, 2, "unknown escape sequence"},