This keeps the BOM runes from causing other errors.
R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/
6625062
static int
getc(void)
{
- int c;
+ int c, c1, c2;
c = curio.peekc;
if(c != 0) {
c = *curio.cp & 0xff;
if(c != 0)
curio.cp++;
- } else
+ } else {
+ loop:
c = Bgetc(curio.bin);
+ if(c == 0xef) {
+ c1 = Bgetc(curio.bin);
+ c2 = Bgetc(curio.bin);
+ if(c1 == 0xbb && c2 == 0xbf) {
+ yyerrorl(lexlineno, "Unicode (UTF-8) BOM in middle of file");
+ goto loop;
+ }
+ Bungetc(curio.bin);
+ Bungetc(curio.bin);
+ }
+ }
check:
switch(c) {
if(!fullrune(str, i))
goto loop;
c = chartorune(&rune, str);
- if(rune == BOM) {
- lineno = lexlineno;
- yyerror("Unicode (UTF-8) BOM in middle of file");
- }
if(rune == Runeerror && c == 1) {
lineno = lexlineno;
yyerror("illegal UTF-8 sequence");