Commit 50c46feb 50c46feb538444d2e7f03773c6f69cf780ffac17 by Sergey Poznyakoff

(want_arg): New lexical tie-in to correctly

process trailing whitespace in calls like %(putaddr To: ).
1 parent cd9a5361
...@@ -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);
......