mirror of
https://github.com/golang/go
synced 2024-11-26 08:17:59 -07:00
Complain about control characters that are not white space.
Bitten by invisible chars too many times. R=ken OCL=24024 CL=24024
This commit is contained in:
parent
6fdb18f900
commit
2538cf747b
@ -299,6 +299,21 @@ cannedimports(char *file, char *cp)
|
|||||||
inimportsys = 1;
|
inimportsys = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
isfrog(int c) {
|
||||||
|
// complain about possibly invisible control characters
|
||||||
|
if(c < 0)
|
||||||
|
return 1;
|
||||||
|
if(c < ' ') {
|
||||||
|
if(c == ' ' || c == '\n' || c== '\r' || c == '\t') // good white space
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(0x80 <= c && c <=0xa0) // unicode block including unbreakable space.
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
yylex(void)
|
yylex(void)
|
||||||
{
|
{
|
||||||
@ -645,6 +660,10 @@ lx:
|
|||||||
DBG("%L lex: TOKEN %s\n", lineno, lexname(c));
|
DBG("%L lex: TOKEN %s\n", lineno, lexname(c));
|
||||||
else
|
else
|
||||||
DBG("%L lex: TOKEN '%c'\n", lineno, c);
|
DBG("%L lex: TOKEN '%c'\n", lineno, c);
|
||||||
|
if(isfrog(c)) {
|
||||||
|
yyerror("illegal character 0x%ux", c);
|
||||||
|
goto l0;
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
asop:
|
asop:
|
||||||
@ -661,8 +680,14 @@ talph:
|
|||||||
if(c >= Runeself) {
|
if(c >= Runeself) {
|
||||||
for(c1=0;;) {
|
for(c1=0;;) {
|
||||||
cp[c1++] = c;
|
cp[c1++] = c;
|
||||||
if(fullrune(cp, c1))
|
if(fullrune(cp, c1)) {
|
||||||
|
chartorune(&rune, cp);
|
||||||
|
if(isfrog(rune)) {
|
||||||
|
yyerror("illegal character 0x%ux", rune);
|
||||||
|
goto l0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
c = getc();
|
c = getc();
|
||||||
}
|
}
|
||||||
cp += c1;
|
cp += c1;
|
||||||
|
Loading…
Reference in New Issue
Block a user