X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fa2py.c;h=3976c860c5ad3f5d7334e6c87ecb5f951a6d90c9;hb=189d1e8d580baf589b8a569f3f4af6e73eba632f;hp=fefa81da7e4d152d6d2fbec32e32f7031bbff696;hpb=d07c2202867c84a305417e42e522ca39d055c62a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/a2py.c b/x2p/a2py.c index fefa81d..3976c86 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -9,6 +9,9 @@ */ #if defined(OS2) || defined(WIN32) +#if defined(WIN32) +#include +#endif #include "../patchlevel.h" #endif #include "util.h" @@ -32,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] [-F] [-n] [-] filename\n", myname); printf("\n -D sets debugging flags." "\n -F the awk script to translate is always invoked with" @@ -63,7 +66,7 @@ main(register int argc, register char **argv, register char **env) #ifdef DEBUGGING case 'D': debug = atoi(argv[0]+2); -#ifdef YYDEBUG +#if YYDEBUG yydebug = (debug & 1); #endif break; @@ -208,7 +211,7 @@ yylex(void) register int tmp; retry: -#ifdef YYDEBUG +#if YYDEBUG if (yydebug) if (strchr(s,'\n')) fprintf(stderr,"Tokener at %s",s); @@ -270,7 +273,11 @@ yylex(void) case ':': tmp = *s++; XOP(tmp); +#ifdef EBCDIC + case 7: +#else case 127: +#endif s++; XTERM('}'); case '}': @@ -698,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);