(want_arg): New lexical tie-in to correctly
process trailing whitespace in calls like %(putaddr To: ).
Showing
1 changed file
with
7 additions
and
2 deletions
... | @@ -39,6 +39,7 @@ static void branch_fixup (size_t pc, size_t tgt); | ... | @@ -39,6 +39,7 @@ static void branch_fixup (size_t pc, size_t tgt); |
39 | /* Lexical tie-ins */ | 39 | /* Lexical tie-ins */ |
40 | static int in_escape; /* Set when inside an escape sequence */ | 40 | static int in_escape; /* Set when inside an escape sequence */ |
41 | static int want_function; /* Set when expecting function name */ | 41 | static int want_function; /* Set when expecting function name */ |
42 | static int want_arg; /* Expecting function argument */ | ||
42 | %} | 43 | %} |
43 | 44 | ||
44 | %union { | 45 | %union { |
... | @@ -155,7 +156,7 @@ cbrace : CBRACE | ... | @@ -155,7 +156,7 @@ cbrace : CBRACE |
155 | } | 156 | } |
156 | ; | 157 | ; |
157 | 158 | ||
158 | funcall : fmtspec obrace { want_function = 1;} function { want_function = 0; } argument cbrace | 159 | funcall : fmtspec obrace { want_function = 1;} function { want_function = 0; want_arg = 1;} argument cbrace |
159 | { | 160 | { |
160 | if ($4) | 161 | if ($4) |
161 | { | 162 | { |
... | @@ -368,6 +369,10 @@ static int backslash(int c); | ... | @@ -368,6 +369,10 @@ static int backslash(int c); |
368 | int | 369 | int |
369 | yylex () | 370 | yylex () |
370 | { | 371 | { |
372 | /* Reset the tie-in */ | ||
373 | int expect_arg = want_arg; | ||
374 | want_arg = 0; | ||
375 | |||
371 | if (yydebug) | 376 | if (yydebug) |
372 | fprintf (stderr, "[lex at %10.10s]\n", curp); | 377 | fprintf (stderr, "[lex at %10.10s]\n", curp); |
373 | if (*curp == '%') | 378 | if (*curp == '%') |
... | @@ -459,7 +464,7 @@ yylex () | ... | @@ -459,7 +464,7 @@ yylex () |
459 | obstack_1grow (&stack, *curp); | 464 | obstack_1grow (&stack, *curp); |
460 | curp++; | 465 | curp++; |
461 | } | 466 | } |
462 | while (*curp && !isdelim(*curp)); | 467 | while (*curp && (expect_arg ? *curp != ')' : !isdelim(*curp))); |
463 | 468 | ||
464 | obstack_1grow (&stack, 0); | 469 | obstack_1grow (&stack, 0); |
465 | yylval.str = obstack_finish (&stack); | 470 | yylval.str = obstack_finish (&stack); | ... | ... |
-
Please register or sign in to post a comment