From: Todd C. Miller Date: Sun, 27 Mar 2011 13:45:42 +0000 (-0400) Subject: Move lexer globals initialization into init_lexer. X-Git-Tag: SUDO_1_8_1~43^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45b82039be7c01cff6634bac69b6f4c94c88a4cc;p=sudo Move lexer globals initialization into init_lexer. --- diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 182c0c818..d95b834ed 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -807,10 +807,9 @@ init_parser(const char *path, int quiet) parse_error = FALSE; errorlineno = -1; errorfile = NULL; - sudolineno = 1; verbose = !quiet; } -#line 761 "y.tab.c" +#line 760 "y.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ #if defined(__cplusplus) || defined(__STDC__) static int yygrowstack(void) @@ -1579,7 +1578,7 @@ case 96: yyval.member = new_member(yyvsp[0].string, WORD); } break; -#line 1530 "y.tab.c" +#line 1529 "y.tab.c" } yyssp -= yym; yystate = *yyssp; diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index 8229ebf10..b1eed8995 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -776,6 +776,5 @@ init_parser(const char *path, int quiet) parse_error = FALSE; errorlineno = -1; errorfile = NULL; - sudolineno = 1; verbose = !quiet; } diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index 608b39aa1..a1e059e1b 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -1476,12 +1476,10 @@ char *yytext; extern YYSTYPE yylval; extern int parse_error; -int sudolineno = 1; +int sudolineno; char *sudoers; -static int sawspace = FALSE; -static int continued = FALSE; -static int prev_state = INITIAL; +static int continued, prev_state, sawspace; static int _push_include(char *, int); static int pop_include(void); @@ -1508,7 +1506,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print; #define INSTR 5 -#line 1511 "lex.yy.c" +#line 1509 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1662,9 +1660,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 120 "toke.l" +#line 118 "toke.l" -#line 1667 "lex.yy.c" +#line 1665 "lex.yy.c" if ( yy_init ) { @@ -1750,7 +1748,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 121 "toke.l" +#line 119 "toke.l" { LEXTRACE(", "); return ','; @@ -1758,12 +1756,12 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 126 "toke.l" +#line 124 "toke.l" BEGIN STARTDEFS; YY_BREAK case 3: YY_RULE_SETUP -#line 128 "toke.l" +#line 126 "toke.l" { BEGIN INDEFS; LEXTRACE("DEFVAR "); @@ -1775,7 +1773,7 @@ YY_RULE_SETUP case 4: YY_RULE_SETUP -#line 137 "toke.l" +#line 135 "toke.l" { BEGIN STARTDEFS; LEXTRACE(", "); @@ -1784,7 +1782,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 143 "toke.l" +#line 141 "toke.l" { LEXTRACE("= "); return '='; @@ -1792,7 +1790,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 148 "toke.l" +#line 146 "toke.l" { LEXTRACE("+= "); return '+'; @@ -1800,7 +1798,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 153 "toke.l" +#line 151 "toke.l" { LEXTRACE("-= "); return '-'; @@ -1808,7 +1806,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 158 "toke.l" +#line 156 "toke.l" { LEXTRACE("BEGINSTR "); yylval.string = NULL; @@ -1818,7 +1816,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 165 "toke.l" +#line 163 "toke.l" { LEXTRACE("WORD(2) "); if (!fill(yytext, yyleng)) @@ -1830,7 +1828,7 @@ YY_RULE_SETUP case 10: YY_RULE_SETUP -#line 174 "toke.l" +#line 172 "toke.l" { /* Line continuation char followed by newline. */ ++sudolineno; @@ -1839,7 +1837,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 180 "toke.l" +#line 178 "toke.l" { LEXTRACE("ENDSTR "); BEGIN prev_state; @@ -1874,7 +1872,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 212 "toke.l" +#line 210 "toke.l" { LEXTRACE("BACKSLASH "); if (!append(yytext, yyleng)) @@ -1883,7 +1881,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 218 "toke.l" +#line 216 "toke.l" { LEXTRACE("STRBODY "); if (!append(yytext, yyleng)) @@ -1894,7 +1892,7 @@ YY_RULE_SETUP case 14: YY_RULE_SETUP -#line 226 "toke.l" +#line 224 "toke.l" { /* quoted fnmatch glob char, pass verbatim */ LEXTRACE("QUOTEDCHAR "); @@ -1905,7 +1903,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 234 "toke.l" +#line 232 "toke.l" { /* quoted sudoers special char, strip backslash */ LEXTRACE("QUOTEDCHAR "); @@ -1916,7 +1914,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 242 "toke.l" +#line 240 "toke.l" { BEGIN INITIAL; yyless(0); @@ -1925,7 +1923,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 248 "toke.l" +#line 246 "toke.l" { LEXTRACE("ARG "); if (!fill_args(yytext, yyleng, sawspace)) @@ -1936,7 +1934,7 @@ YY_RULE_SETUP case 18: YY_RULE_SETUP -#line 256 "toke.l" +#line 254 "toke.l" { char *path; @@ -1957,7 +1955,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 274 "toke.l" +#line 272 "toke.l" { char *path; @@ -1981,7 +1979,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 295 "toke.l" +#line 293 "toke.l" { char deftype; int n; @@ -2024,7 +2022,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 335 "toke.l" +#line 333 "toke.l" { int n; @@ -2053,7 +2051,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 361 "toke.l" +#line 359 "toke.l" { /* cmnd does not require passwd for this user */ LEXTRACE("NOPASSWD "); @@ -2062,7 +2060,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 367 "toke.l" +#line 365 "toke.l" { /* cmnd requires passwd for this user */ LEXTRACE("PASSWD "); @@ -2071,7 +2069,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 373 "toke.l" +#line 371 "toke.l" { LEXTRACE("NOEXEC "); return NOEXEC; @@ -2079,7 +2077,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 378 "toke.l" +#line 376 "toke.l" { LEXTRACE("EXEC "); return EXEC; @@ -2087,7 +2085,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 383 "toke.l" +#line 381 "toke.l" { LEXTRACE("SETENV "); return SETENV; @@ -2095,7 +2093,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 388 "toke.l" +#line 386 "toke.l" { LEXTRACE("NOSETENV "); return NOSETENV; @@ -2103,7 +2101,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 393 "toke.l" +#line 391 "toke.l" { LEXTRACE("LOG_OUTPUT "); return LOG_OUTPUT; @@ -2111,7 +2109,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 398 "toke.l" +#line 396 "toke.l" { LEXTRACE("NOLOG_OUTPUT "); return NOLOG_OUTPUT; @@ -2119,7 +2117,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 403 "toke.l" +#line 401 "toke.l" { LEXTRACE("LOG_INPUT "); return LOG_INPUT; @@ -2127,7 +2125,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 408 "toke.l" +#line 406 "toke.l" { LEXTRACE("NOLOG_INPUT "); return NOLOG_INPUT; @@ -2135,7 +2133,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 413 "toke.l" +#line 411 "toke.l" { /* empty group or netgroup */ LEXTRACE("ERROR "); @@ -2144,7 +2142,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 419 "toke.l" +#line 417 "toke.l" { /* netgroup */ if (!fill(yytext, yyleng)) @@ -2155,7 +2153,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 427 "toke.l" +#line 425 "toke.l" { /* group */ if (!fill(yytext, yyleng)) @@ -2166,7 +2164,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 435 "toke.l" +#line 433 "toke.l" { if (!fill(yytext, yyleng)) yyterminate(); @@ -2176,7 +2174,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 442 "toke.l" +#line 440 "toke.l" { if (!fill(yytext, yyleng)) yyterminate(); @@ -2186,7 +2184,7 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 449 "toke.l" +#line 447 "toke.l" { if (!ipv6_valid(yytext)) { LEXTRACE("ERROR "); @@ -2200,7 +2198,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 460 "toke.l" +#line 458 "toke.l" { if (!ipv6_valid(yytext)) { LEXTRACE("ERROR "); @@ -2214,7 +2212,7 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 471 "toke.l" +#line 469 "toke.l" { if (strcmp(yytext, "ALL") == 0) { LEXTRACE("ALL "); @@ -2239,7 +2237,7 @@ YY_RULE_SETUP YY_BREAK case 40: YY_RULE_SETUP -#line 493 "toke.l" +#line 491 "toke.l" { /* no command args allowed for Defaults!/path */ if (!fill_cmnd(yytext, yyleng)) @@ -2250,7 +2248,7 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 501 "toke.l" +#line 499 "toke.l" { BEGIN GOTCMND; LEXTRACE("COMMAND "); @@ -2260,7 +2258,7 @@ YY_RULE_SETUP YY_BREAK case 42: YY_RULE_SETUP -#line 508 "toke.l" +#line 506 "toke.l" { /* directories can't have args... */ if (yytext[yyleng - 1] == '/') { @@ -2278,7 +2276,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 523 "toke.l" +#line 521 "toke.l" { LEXTRACE("BEGINSTR "); yylval.string = NULL; @@ -2288,7 +2286,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 530 "toke.l" +#line 528 "toke.l" { /* a word */ if (!fill(yytext, yyleng)) @@ -2299,7 +2297,7 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 538 "toke.l" +#line 536 "toke.l" { LEXTRACE("( "); return '('; @@ -2307,7 +2305,7 @@ YY_RULE_SETUP YY_BREAK case 46: YY_RULE_SETUP -#line 543 "toke.l" +#line 541 "toke.l" { LEXTRACE(") "); return ')'; @@ -2315,7 +2313,7 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -#line 548 "toke.l" +#line 546 "toke.l" { LEXTRACE(", "); return ','; @@ -2323,7 +2321,7 @@ YY_RULE_SETUP YY_BREAK case 48: YY_RULE_SETUP -#line 553 "toke.l" +#line 551 "toke.l" { LEXTRACE("= "); return '='; @@ -2331,7 +2329,7 @@ YY_RULE_SETUP YY_BREAK case 49: YY_RULE_SETUP -#line 558 "toke.l" +#line 556 "toke.l" { LEXTRACE(": "); return ':'; @@ -2339,7 +2337,7 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 563 "toke.l" +#line 561 "toke.l" { if (yyleng % 2 == 1) return '!'; /* return '!' */ @@ -2347,7 +2345,7 @@ YY_RULE_SETUP YY_BREAK case 51: YY_RULE_SETUP -#line 568 "toke.l" +#line 566 "toke.l" { BEGIN INITIAL; ++sudolineno; @@ -2358,14 +2356,14 @@ YY_RULE_SETUP YY_BREAK case 52: YY_RULE_SETUP -#line 576 "toke.l" +#line 574 "toke.l" { /* throw away space/tabs */ sawspace = TRUE; /* but remember for fill_args */ } YY_BREAK case 53: YY_RULE_SETUP -#line 580 "toke.l" +#line 578 "toke.l" { sawspace = TRUE; /* remember for fill_args */ ++sudolineno; @@ -2374,7 +2372,7 @@ YY_RULE_SETUP YY_BREAK case 54: YY_RULE_SETUP -#line 586 "toke.l" +#line 584 "toke.l" { BEGIN INITIAL; ++sudolineno; @@ -2385,7 +2383,7 @@ YY_RULE_SETUP YY_BREAK case 55: YY_RULE_SETUP -#line 594 "toke.l" +#line 592 "toke.l" { LEXTRACE("ERROR "); return ERROR; @@ -2397,7 +2395,7 @@ case YY_STATE_EOF(GOTCMND): case YY_STATE_EOF(STARTDEFS): case YY_STATE_EOF(INDEFS): case YY_STATE_EOF(INSTR): -#line 599 "toke.l" +#line 597 "toke.l" { if (YY_START != INITIAL) { BEGIN INITIAL; @@ -2410,10 +2408,10 @@ case YY_STATE_EOF(INSTR): YY_BREAK case 56: YY_RULE_SETUP -#line 609 "toke.l" +#line 607 "toke.l" ECHO; YY_BREAK -#line 2416 "lex.yy.c" +#line 2414 "lex.yy.c" case YY_END_OF_BUFFER: { @@ -3304,7 +3302,7 @@ int main() return 0; } #endif -#line 609 "toke.l" +#line 607 "toke.l" struct path_list { char *path; @@ -3441,7 +3439,11 @@ init_lexer(void) efree(istack); istack = NULL; istacksize = idepth = 0; + sudolineno = 1; keepopen = FALSE; + sawspace = FALSE; + continued = FALSE; + prev_state = INITIAL; } static int diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 22e852da5..dbf7ba50a 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -73,12 +73,10 @@ extern YYSTYPE yylval; extern int parse_error; -int sudolineno = 1; +int sudolineno; char *sudoers; -static int sawspace = FALSE; -static int continued = FALSE; -static int prev_state = INITIAL; +static int continued, prev_state, sawspace; static int _push_include(char *, int); static int pop_include(void); @@ -742,7 +740,11 @@ init_lexer(void) efree(istack); istack = NULL; istacksize = idepth = 0; + sudolineno = 1; keepopen = FALSE; + sawspace = FALSE; + continued = FALSE; + prev_state = INITIAL; } static int