Date: Thu, 23 Oct 2003 10:21:54 -0700 (PDT) From: Andrew Reisse <areisse@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 40315 for review Message-ID: <200310231721.h9NHLslE068093@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=40315 Change 40315 by areisse@areisse_ibook on 2003/10/23 10:21:52 checkpolicy reports errors using the original file and line number Affected files ... .. //depot/projects/trustedbsd/sedarwin/sebsd_cmds/checkpolicy/policy_scan.l#2 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin/sebsd_cmds/checkpolicy/policy_scan.l#2 (text+ko) ==== @@ -11,9 +11,34 @@ static char linebuf[2][255]; static unsigned int lno = 0; +static char policydb_curfile[1024] = "<input>"; unsigned long policydb_lineno = 1; unsigned int policydb_errors = 0; + +static void set_file (const char *in) +{ + policydb_lineno = 0; + const char *p = in; + p += 5; + while (*p == ' ' || (*p >= '0' && *p <= '9') || *p == '"') + { + if (*p >= '0' && *p <= '9') + policydb_lineno = (*p - '0') + policydb_lineno * 10; + p++; + } + char *pp = policydb_curfile; + + while (*p != '"' && *p != '\n' && *p) + { + *pp = *p; + pp++; + *pp = 0; + p++; + } + policydb_lineno--; +} + %} %array letter [A-Za-z] @@ -130,6 +155,7 @@ {letter}({letter}|{digit}|_)* { return(IDENTIFIER); } {letter}({letter}|{digit}|_|"."|"-")* { return(USER_IDENTIFIER); } {digit}{digit}* { return(NUMBER); } +#line[ ]{digit}{digit}*[^\n]* { set_file (yytext); } #[^\n]* { /* delete comments */ } [ \t\f]+ { /* delete whitespace */ } "==" { return(EQUALS); } @@ -154,9 +180,10 @@ %% int yyerror(char *msg) { - fprintf(stderr, "ERROR '%s' at token '%s' on line %ld:\n%s\n%s\n", + fprintf(stderr, "ERROR '%s' at token '%s' on line %s:%ld:\n%s\n%s\n", msg, yytext, + policydb_curfile, policydb_lineno, linebuf[0], linebuf[1]); policydb_errors++; @@ -165,9 +192,10 @@ int yywarn(char *msg) { - fprintf(stderr, "WARNING '%s' at token '%s' on line %ld:\n%s\n%s\n", + fprintf(stderr, "WARNING '%s' at token '%s' on line %s:%ld:\n%s\n%s\n", msg, yytext, + policydb_curfile, policydb_lineno, linebuf[0], linebuf[1]); return 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310231721.h9NHLslE068093>
