1
0
mirror of https://github.com/golang/go synced 2024-11-22 06:24:38 -07:00

gc: include full text of import path in error message

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5783091
This commit is contained in:
Rob Pike 2012-03-13 15:35:08 +11:00
parent 677caf7813
commit daacba5184

View File

@ -3624,23 +3624,23 @@ isbadimport(Strlit *path)
while(*s) { while(*s) {
s += chartorune(&r, s); s += chartorune(&r, s);
if(r == Runeerror) { if(r == Runeerror) {
yyerror("import path contains invalid UTF-8 sequence"); yyerror("import path contains invalid UTF-8 sequence: \"%s\"", path->s);
return 1; return 1;
} }
if(r < 0x20 || r == 0x7f) { if(r < 0x20 || r == 0x7f) {
yyerror("import path contains control character"); yyerror("import path contains control character: \"%s\"", path->s);
return 1; return 1;
} }
if(r == '\\') { if(r == '\\') {
yyerror("import path contains backslash; use slash"); yyerror("import path contains backslash; use slash: \"%s\"", path->s);
return 1; return 1;
} }
if(isspacerune(r)) { if(isspacerune(r)) {
yyerror("import path contains space character"); yyerror("import path contains space character: \"%s\"", path->s);
return 1; return 1;
} }
if(utfrune("!\"#$%&'()*,:;<=>?[]^`{|}~", r)) { if(utfrune("!\"#$%&'()*,:;<=>?[]^`{|}~", r)) {
yyerror("import path contains invalid character '%C'", r); yyerror("import path contains invalid character '%C': \"%s\"", r, path->s);
return 1; return 1;
} }
} }