diff options
Diffstat (limited to 'x2p/a2py.c')
-rw-r--r-- | x2p/a2py.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/x2p/a2py.c b/x2p/a2py.c index 8a6155f455..cb09fce485 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -705,8 +705,15 @@ yylex(void) } if (strEQ(d,"sub")) XTERM(SUB); - if (strEQ(d,"sprintf")) - XTERM(SPRINTF); + if (strEQ(d,"sprintf")) { + /* In old awk, { print sprintf("str%sg"),"in" } prints + * "string"; in new awk, "in" is not considered an argument to + * sprintf, so the statement breaks. To support both, the + * grammar treats arguments to SPRINTF_OLD like old awk, + * SPRINTF_NEW like new. Here we return the appropriate one. + */ + XTERM(old_awk ? SPRINTF_OLD : SPRINTF_NEW); + } if (strEQ(d,"sqrt")) { yylval = OSQRT; XTERM(FUN1); |