cmd/compile/internal/syntax: simplify BOM handling

Change-Id: I5e2522d34720d7687e1e9ff0831936702976a1c7
This commit is contained in:
Matthew Dempsky 2016-06-10 11:22:11 -07:00
parent 0d8ac5ecf1
commit a17ec6b30c
2 changed files with 4 additions and 7 deletions

View File

@ -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
}

View File

@ -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()