]> Cypherpunks repositories - gostls13.git/commitdiff
go/scanner: skip first character if it's a BOM
authorRobert Griesemer <gri@golang.org>
Fri, 7 Sep 2012 20:56:31 +0000 (13:56 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 7 Sep 2012 20:56:31 +0000 (13:56 -0700)
R=r
CC=golang-dev
https://golang.org/cl/6490095

src/pkg/go/scanner/scanner.go

index c213161c47bfcdfb2a9be2523dbc3a6ffc914741..3322c58b339b1d0f260715d255cef87d579cba63 100644 (file)
@@ -125,6 +125,9 @@ func (s *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode Mode
        s.ErrorCount = 0
 
        s.next()
+       if s.ch == '\uFEFF' {
+               s.next() // ignore BOM
+       }
 }
 
 func (s *Scanner) error(offs int, msg string) {
@@ -390,7 +393,7 @@ func (s *Scanner) scanEscape(quote rune) {
        for ; i > 0 && s.ch != quote && s.ch >= 0; i-- {
                s.next()
        }
-       if x > max || 0xd800 <= x && x < 0xe000 {
+       if x > max || 0xD800 <= x && x < 0xE000 {
                s.error(offs, "escape sequence is invalid Unicode code point")
        }
 }