1
--- pscan-1.2.orig/scanner.l
2
+++ pscan-1.2/scanner.l
8
static void skip_strings(char literal);
9
+extern int cur_lineno;
15
-reserved "default"|"struct"|"void"|"for"|"if"|"else"|"while"|"do"|"return"|"case"|"switch"|"break"|"auto"|"continue"|"goto"|"sizeof"|"static"|"typedef"|"union"|"volatile"
16
+reserved "default"|"struct"|"void"|"for"|"if"|"else"|"while"|"do"|"return"|"case"|"switch"|"break"|"auto"|"continue"|"goto"|"sizeof"|"static"|"typedef"|"union"|"volatile"|"asm"
18
vartype "char"|"double"|"enum"|"extern"|"float"|"int"|"long"|"register"|"short"|"signed"|"unsigned"|"const"
20
-cprep "include"|"define"|"if"|"else"|"endif"|"ifdef"|"ifndef"
21
+cprep "include"|"define"|"undef"|"if"|"else"|"elif"|"endif"|"ifdef"|"ifndef"|"error"|"line"|"pragma"
25
-{reserved} state->last_token = NOT_PROBLEMATIC;
26
+{reserved} {// Ignore reserved words because issue arises
27
+ // if reserved sizeof used as argument to a defined
28
+ // problematic function such as snprintf
29
+ // but we also do not want to attempt to check these
30
+ // for defined issues in setup_checks function as we know
31
+ // they are undefined
32
+ // Default last_token state is NOT_PROBLEMATIC
34
+ // state->last_token = NOT_PROBLEMATIC;
37
{vartype} state->last_token = NOT_PROBLEMATIC;
41
\' skip_strings('\'');
43
-\/\/.*$ /* skip C++ style comments */
45
+\/\/[^\n]* /* skip C++ style comments */
47
[a-zA-Z_][_a-zA-Z0-9]* state = setup_checks(yytext, state);
54
-"\n"|"\r" /* ignore LF's and CR's */
59
<comment>[^*\n]* /* eat anything that's not a '*' */
60
<comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
61
-<comment>\n /* do nothing */
62
+<comment>\n {cur_lineno++;}
63
<comment>"*"+"/" BEGIN(INITIAL);
65
+"\n" { cur_lineno++;}
68
/**********************************************************************
69
* pscan: http://www.striker.ottawa.on.ca/~aland/pscan/
72
void skip_strings(char literal)
75
+ int c,last_c=0,done=0;
84
+ if ((last_c!='\\') && (c==literal)) // non escaped literal found
86
+ else if ((last_c=='\\') && (c=='\\')) // avoid \\ issue
92
- while ((c = input()) != literal)
98
- if (c == '\\') continue;
99
- if (c == EOF) return;