From a5571d593ac90d11dc2015dcb1d4f62bc0d28a6d Mon Sep 17 00:00:00 2001 From: Chip Salzenberg Date: Fri, 7 Mar 1997 03:48:20 +1200 Subject: Add B<-o> option to a2p, for old awk; make new the default --- x2p/a2p.h | 1 + x2p/a2p.pod | 6 ++++++ x2p/a2py.c | 3 +++ x2p/walk.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) (limited to 'x2p') diff --git a/x2p/a2p.h b/x2p/a2p.h index f1ab12461d..b00b0723ea 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 06c5ac7322..fa726fb101 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 46ec604c06..ad685fe7e9 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 936f202df8..cb40073b22 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; -- cgit v1.2.1