]> git.pld-linux.org Git - packages/checkpolicy.git/blob - checkpolicy-lineno.patch
- really no need to use C99 in this place ;)
[packages/checkpolicy.git] / checkpolicy-lineno.patch
1 diff -ur checkpolicy-1.4.orig/checkpolicy.c checkpolicy-1.4/checkpolicy.c
2 --- checkpolicy-1.4.orig/checkpolicy.c  2003-12-01 14:24:57.000000000 -0500
3 +++ checkpolicy-1.4/checkpolicy.c       2003-12-15 02:50:48.000000000 -0500
4 @@ -45,6 +45,8 @@
5  extern queue_t id_queue;
6  extern unsigned int policydb_errors;
7  extern unsigned long policydb_lineno;
8 +extern unsigned long source_lineno;
9 +extern char source_file[];
10  extern unsigned int pass;
11  extern unsigned int ss_initialized;
12  
13 @@ -400,6 +402,8 @@
14                 }
15                 rewind(yyin);
16                 policydb_lineno = 1;
17 +               source_file[0] = '\0';
18 +               source_lineno = 1;
19                 yyrestart(yyin);
20                 pass = 2;
21                 if (yyparse() || policydb_errors) {
22 diff -ur checkpolicy-1.4.orig/policy_parse.y checkpolicy-1.4/policy_parse.y
23 --- checkpolicy-1.4.orig/policy_parse.y 2003-10-24 10:23:09.000000000 -0400
24 +++ checkpolicy-1.4/policy_parse.y      2003-12-15 02:30:59.000000000 -0500
25 @@ -18,6 +18,8 @@
26  policydb_t *policydbp;
27  queue_t id_queue = 0;
28  unsigned int pass;
29 +char *curfile = 0;
30 +unsigned int curline; 
31  
32  extern unsigned long policydb_lineno;
33  
34 diff -ur checkpolicy-1.4.orig/policy_scan.l checkpolicy-1.4/policy_scan.l
35 --- checkpolicy-1.4.orig/policy_scan.l  2003-06-26 13:23:12.000000000 -0400
36 +++ checkpolicy-1.4/policy_scan.l       2003-12-15 02:51:18.000000000 -0500
37 @@ -11,6 +11,9 @@
38  static char linebuf[2][255];
39  static unsigned int lno = 0;
40  
41 +char source_file[255];
42 +unsigned long source_lineno = 1;
43 +
44  unsigned long policydb_lineno = 1;
45  
46  unsigned int policydb_errors = 0;
47 @@ -23,6 +26,7 @@
48                                    linebuf[lno][254] = 0;
49                                    lno = 1 - lno; 
50                                    policydb_lineno++;
51 +                                 source_lineno++;
52                                    yyless(1); }
53  CLONE |
54  clone                          { return(CLONE); }
55 @@ -130,6 +134,8 @@
56  {letter}({letter}|{digit}|_)*  { return(IDENTIFIER); }
57  {letter}({letter}|{digit}|_|"."|"-")*  { return(USER_IDENTIFIER); }
58  {digit}{digit}*                 { return(NUMBER); }
59 +#line[ ]1[ ]\"[^\n]*\"         { source_lineno = 1; strncpy(source_file, yytext+9, 255); source_file[strlen(source_file)-1] = '\0'; }
60 +#line[ ]{digit}{digit}*                { source_lineno = atoi(yytext+6)-1; }
61  #[^\n]*                         { /* delete comments */ }
62  [ \t\f]+                       { /* delete whitespace */ }
63  "=="                           { return(EQUALS); }
64 @@ -154,6 +160,11 @@
65  %%
66  int yyerror(char *msg)
67  {
68 +       if (source_file[0])
69 +               fprintf(stderr, "%s:%ld:",
70 +                       source_file, source_lineno);
71 +       else
72 +               fprintf(stderr, "(unknown source)::");
73         fprintf(stderr, "ERROR '%s' at token '%s' on line %ld:\n%s\n%s\n",
74                         msg,
75                         yytext,
76 @@ -165,6 +176,11 @@
77  
78  int yywarn(char *msg)
79  {
80 +       if (source_file[0])
81 +               fprintf(stderr, "%s:%ld:",
82 +                       source_file, source_lineno);
83 +       else
84 +               fprintf(stderr, "(unknown source)::");
85         fprintf(stderr, "WARNING '%s' at token '%s' on line %ld:\n%s\n%s\n",
86                         msg,
87                         yytext,
88 @@ -172,5 +188,3 @@
89                         linebuf[0], linebuf[1]);
90         return 0;
91  }
92 -
93 -
This page took 0.049795 seconds and 3 git commands to generate.