diff options
-rw-r--r-- | x2p/a2p.h | 1 | ||||
-rw-r--r-- | x2p/a2p.pod | 6 | ||||
-rw-r--r-- | x2p/a2py.c | 3 | ||||
-rw-r--r-- | x2p/walk.c | 2 |
4 files changed, 11 insertions, 1 deletions
@@ -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; |