diff -ur checkpolicy-1.4.orig/checkpolicy.c checkpolicy-1.4/checkpolicy.c --- checkpolicy-1.4.orig/checkpolicy.c 2003-12-01 14:24:57.000000000 -0500 +++ checkpolicy-1.4/checkpolicy.c 2003-12-15 02:50:48.000000000 -0500 @@ -45,6 +45,8 @@ extern queue_t id_queue; extern unsigned int policydb_errors; extern unsigned long policydb_lineno; +extern unsigned long source_lineno; +extern char source_file[]; extern unsigned int pass; extern unsigned int ss_initialized; @@ -400,6 +402,8 @@ } rewind(yyin); policydb_lineno = 1; + source_file[0] = '\0'; + source_lineno = 1; yyrestart(yyin); pass = 2; if (yyparse() || policydb_errors) { diff -ur checkpolicy-1.4.orig/policy_parse.y checkpolicy-1.4/policy_parse.y --- checkpolicy-1.4.orig/policy_parse.y 2003-10-24 10:23:09.000000000 -0400 +++ checkpolicy-1.4/policy_parse.y 2003-12-15 02:30:59.000000000 -0500 @@ -18,6 +18,8 @@ policydb_t *policydbp; queue_t id_queue = 0; unsigned int pass; +char *curfile = 0; +unsigned int curline; extern unsigned long policydb_lineno; diff -ur checkpolicy-1.4.orig/policy_scan.l checkpolicy-1.4/policy_scan.l --- checkpolicy-1.4.orig/policy_scan.l 2003-06-26 13:23:12.000000000 -0400 +++ checkpolicy-1.4/policy_scan.l 2003-12-15 02:51:18.000000000 -0500 @@ -11,6 +11,9 @@ static char linebuf[2][255]; static unsigned int lno = 0; +char source_file[255]; +unsigned long source_lineno = 1; + unsigned long policydb_lineno = 1; unsigned int policydb_errors = 0; @@ -23,6 +26,7 @@ linebuf[lno][254] = 0; lno = 1 - lno; policydb_lineno++; + source_lineno++; yyless(1); } CLONE | clone { return(CLONE); } @@ -130,6 +134,8 @@ {letter}({letter}|{digit}|_)* { return(IDENTIFIER); } {letter}({letter}|{digit}|_|"."|"-")* { return(USER_IDENTIFIER); } {digit}{digit}* { return(NUMBER); } +#line[ ]1[ ]\"[^\n]*\" { source_lineno = 1; strncpy(source_file, yytext+9, 255); source_file[strlen(source_file)-1] = '\0'; } +#line[ ]{digit}{digit}* { source_lineno = atoi(yytext+6)-1; } #[^\n]* { /* delete comments */ } [ \t\f]+ { /* delete whitespace */ } "==" { return(EQUALS); } @@ -154,6 +160,11 @@ %% int yyerror(char *msg) { + if (source_file[0]) + fprintf(stderr, "%s:%ld:", + source_file, source_lineno); + else + fprintf(stderr, "(unknown source)::"); fprintf(stderr, "ERROR '%s' at token '%s' on line %ld:\n%s\n%s\n", msg, yytext, @@ -165,6 +176,11 @@ int yywarn(char *msg) { + if (source_file[0]) + fprintf(stderr, "%s:%ld:", + source_file, source_lineno); + else + fprintf(stderr, "(unknown source)::"); fprintf(stderr, "WARNING '%s' at token '%s' on line %ld:\n%s\n%s\n", msg, yytext, @@ -172,5 +188,3 @@ linebuf[0], linebuf[1]); return 0; } - -