mirror of
https://github.com/golang/go
synced 2024-11-25 10:17:57 -07:00
gc: allow colon in //line file name
Assume last colon introduces line number. Fixes #2543. R=ken2 CC=golang-dev https://golang.org/cl/5485047
This commit is contained in:
parent
ebdcbf1cdc
commit
ecda0fa5d4
@ -1336,7 +1336,7 @@ static int
|
||||
getlinepragma(void)
|
||||
{
|
||||
int i, c, n;
|
||||
char *cp, *ep;
|
||||
char *cp, *ep, *linep;
|
||||
Hist *h;
|
||||
|
||||
for(i=0; i<5; i++) {
|
||||
@ -1347,32 +1347,36 @@ getlinepragma(void)
|
||||
|
||||
cp = lexbuf;
|
||||
ep = lexbuf+sizeof(lexbuf)-5;
|
||||
linep = nil;
|
||||
for(;;) {
|
||||
c = getr();
|
||||
if(c == '\n' || c == EOF)
|
||||
if(c == EOF)
|
||||
goto out;
|
||||
if(c == '\n')
|
||||
break;
|
||||
if(c == ' ')
|
||||
continue;
|
||||
if(c == ':')
|
||||
break;
|
||||
linep = cp;
|
||||
if(cp < ep)
|
||||
*cp++ = c;
|
||||
}
|
||||
*cp = 0;
|
||||
|
||||
if(linep == nil || linep >= ep)
|
||||
goto out;
|
||||
*linep++ = '\0';
|
||||
n = 0;
|
||||
for(;;) {
|
||||
c = getr();
|
||||
if(!yy_isdigit(c))
|
||||
break;
|
||||
n = n*10 + (c-'0');
|
||||
for(cp=linep; *cp; cp++) {
|
||||
if(*cp < '0' || *cp > '9')
|
||||
goto out;
|
||||
n = n*10 + *cp - '0';
|
||||
if(n > 1e8) {
|
||||
yyerror("line number out of range");
|
||||
errorexit();
|
||||
}
|
||||
}
|
||||
|
||||
if(c != '\n' || n <= 0)
|
||||
if(n <= 0)
|
||||
goto out;
|
||||
|
||||
// try to avoid allocating file name over and over
|
||||
|
Loading…
Reference in New Issue
Block a user