aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/syntax/source.go6
-rw-r--r--src/cmd/compile/internal/syntax/syntax.go5
2 files changed, 4 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/syntax/source.go b/src/cmd/compile/internal/syntax/source.go
index fc63e04931..577d7cb168 100644
--- a/src/cmd/compile/internal/syntax/source.go
+++ b/src/cmd/compile/internal/syntax/source.go
@@ -112,8 +112,10 @@ redo:
// BOM's are only allowed as the first character in a file
const BOM = 0xfeff
- if r == BOM && s.r0 > 0 { // s.r0 is always > 0 after 1st character (fill will set it to 1)
- s.error("invalid BOM in the middle of the file")
+ if r == BOM {
+ if s.r0 > 0 { // s.r0 is always > 0 after 1st character (fill will set it to 1)
+ s.error("invalid BOM in the middle of the file")
+ }
goto redo
}
diff --git a/src/cmd/compile/internal/syntax/syntax.go b/src/cmd/compile/internal/syntax/syntax.go
index 5d50883753..71990bca8b 100644
--- a/src/cmd/compile/internal/syntax/syntax.go
+++ b/src/cmd/compile/internal/syntax/syntax.go
@@ -46,11 +46,6 @@ func Read(src io.Reader, errh ErrorHandler, mode Mode) (*File, error) {
var p parser
p.init(src, errh)
- // skip initial BOM if present
- if p.getr() != '\ufeff' {
- p.ungetr()
- }
-
p.next()
ast := p.file()