From: Chip Salzenberg Date: Thu, 6 Mar 1997 15:48:20 +0000 (+1200) Subject: Add B<-o> option to a2p, for old awk; make new the default X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5571d593ac90d11dc2015dcb1d4f62bc0d28a6d;p=p5sagit%2Fp5-mst-13.2.git Add B<-o> option to a2p, for old awk; make new the default --- diff --git a/x2p/a2p.h b/x2p/a2p.h index f1ab124..b00b072 100644 --- a/x2p/a2p.h +++ b/x2p/a2p.h @@ -415,6 +415,7 @@ EXT bool nomemok INIT(FALSE); EXT char const_FS INIT(0); EXT char *namelist INIT(Nullch); EXT char fswitch INIT(0); +EXT bool old_awk INIT(0); EXT int saw_FS INIT(0); EXT int maxfld INIT(0); diff --git a/x2p/a2p.pod b/x2p/a2p.pod index 06c5ac7..fa726fb 100644 --- a/x2p/a2p.pod +++ b/x2p/a2p.pod @@ -41,6 +41,12 @@ Any delimiter can be used to separate the field names. causes a2p to assume that input will always have that many fields. +=item B<-o> + +tells a2p to use old awk behavior. For now, the only difference is +that old awk always has a line loop, even if there are no line +actions, whereas new awk does not. + =back =head2 "Considerations" diff --git a/x2p/a2py.c b/x2p/a2py.c index 46ec604..ad685fe 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -80,6 +80,9 @@ register char **env; case 'n': namelist = savestr(argv[0]+2); break; + case 'o': + old_awk = TRUE; + break; case '-': argc--,argv++; goto switch_end; diff --git a/x2p/walk.c b/x2p/walk.c index 936f202..cb40073 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -145,7 +145,7 @@ int minprec; /* minimum precedence without parens */ if (saw_FNR) str_cat(str,"continue {\n $FNRbase = $. if eof;\n}\n"); } - else + else if (old_awk) str_cat(str,"while (<>) { } # (no line actions)\n"); if (ops[node+4].ival) { realexit = TRUE;