From owner-p4-projects@FreeBSD.ORG Thu Oct 23 10:21:56 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0F4F116A4C1; Thu, 23 Oct 2003 10:21:56 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF12116A4BF for ; Thu, 23 Oct 2003 10:21:55 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49AC343FA3 for ; Thu, 23 Oct 2003 10:21:55 -0700 (PDT) (envelope-from areisse@nailabs.com) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h9NHLtXJ068096 for ; Thu, 23 Oct 2003 10:21:55 -0700 (PDT) (envelope-from areisse@nailabs.com) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h9NHLslE068093 for perforce@freebsd.org; Thu, 23 Oct 2003 10:21:54 -0700 (PDT) (envelope-from areisse@nailabs.com) Date: Thu, 23 Oct 2003 10:21:54 -0700 (PDT) Message-Id: <200310231721.h9NHLslE068093@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to areisse@nailabs.com using -f From: Andrew Reisse To: Perforce Change Reviews Subject: PERFORCE change 40315 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2003 17:21:56 -0000 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] = ""; 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;