summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/x2p/a2py.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/x2p/a2py.c')
-rw-r--r--contrib/perl5/x2p/a2py.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/contrib/perl5/x2p/a2py.c b/contrib/perl5/x2p/a2py.c
index 8a6155f..3976c86 100644
--- a/contrib/perl5/x2p/a2py.c
+++ b/contrib/perl5/x2p/a2py.c
@@ -35,7 +35,7 @@ static void usage(void);
static void
usage()
{
- printf("\nThis is the AWK to PERL translator, version 5.0, patchlevel %d\n", PATCHLEVEL);
+ printf("\nThis is the AWK to PERL translator, revision %d.0, version %d\n", PERL_REVISION, PERL_VERSION);
printf("\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n", myname);
printf("\n -D<number> sets debugging flags."
"\n -F<character> the awk script to translate is always invoked with"
@@ -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);
OpenPOWER on IntegriCloud