Message ID | mcr392dqzsg.fsf@google.com |
---|---|
State | New |
Headers | show |
diff -r 917ece6aa599 go/lex.cc --- a/go/lex.cc Wed Sep 19 08:50:19 2012 -0700 +++ b/go/lex.cc Wed Sep 19 17:47:42 2012 -0700 @@ -726,7 +726,7 @@ &issued_error); // Ignore byte order mark at start of file. - if (ci == 0xfeff && this->lineno_ == 1 && this->lineoff_ == 0) + if (ci == 0xfeff) { p = pnext; break; @@ -840,6 +840,14 @@ *issued_error = true; return p + 1; } + + // Warn about byte order mark, except at start of file. + if (*value == 0xfeff && (this->lineno_ != 1 || this->lineoff_ != 0)) + { + error_at(this->location(), "Unicode (UTF-8) BOM in middle of file"); + *issued_error = true; + } + return p + adv; }