From ce211fb7fcf1463619d2b2ef32b8f6c2f4f35459 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 30 May 2016 17:35:37 -0400 Subject: Allow FS = "\0" if RS = "". --- ChangeLog | 5 +++++ field.c | 6 +++++- test/ChangeLog | 5 +++++ test/Makefile.am | 5 ++++- test/Makefile.in | 10 +++++++++- test/Maketests | 5 +++++ test/fsnul1.awk | 2 ++ test/fsnul1.in | Bin 0 -> 6 bytes test/fsnul1.ok | 1 + 9 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/fsnul1.awk create mode 100644 test/fsnul1.in create mode 100644 test/fsnul1.ok diff --git a/ChangeLog b/ChangeLog index 1476f3c1..77119e0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ * main.c (arg_assign): Fully bracket ifdefs around call to force_number. Thanks to Andrew Schorr for pointing out that force_number was called only if LC_NUMERIC was defined. + + Lots of files: Update copyright date. + + * field.c (set_FS): Handle FS = "\0" if RS = "". Thanks to + Janis Papanagnou for the report. 2016-05-26 Andrew J. Schorr diff --git a/field.c b/field.c index abd08c08..5f5b2b65 100644 --- a/field.c +++ b/field.c @@ -1270,8 +1270,12 @@ choose_fs_function: } else if (fs->stptr[0] == '\\') { /* yet another special case */ strcpy(buf, "[\\\\\n]"); - } else if (fs->stptr[0] != '\n') + } else if (fs->stptr[0] == '\0') { + /* and yet another special case */ + strcpy(buf, "[\\000\n]"); + } else if (fs->stptr[0] != '\n') { sprintf(buf, "[%c\n]", fs->stptr[0]); + } } } else { if (do_posix) diff --git a/test/ChangeLog b/test/ChangeLog index 2ba62311..2e1090ce 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2016-05-30 Arnold D. Robbins + + * Makefile.am (fsnul1): New test. + * fsnul1.awk, fsnul1.in, fsnul1.ok: New files. + 2016-05-25 Arnold D. Robbins * arrayind1.awk: Flush writes to stderr. We hope this helps diff --git a/test/Makefile.am b/test/Makefile.am index 59656523..92e8f6e7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -316,6 +316,9 @@ EXTRA_DIST = \ fsfwfs.awk \ fsfwfs.in \ fsfwfs.ok \ + fsnul1.awk \ + fsnul1.in \ + fsnul1.ok \ fsrs.awk \ fsrs.in \ fsrs.ok \ @@ -1056,7 +1059,7 @@ BASIC_TESTS = \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ eofsplit exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ - fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ + fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsnul1 fsrs fsspcoln \ fstabplus funsemnl funsmnam funstack \ getline getline2 getline3 getline4 getline5 getlnbuf getnr2tb getnr2tm \ gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \ diff --git a/test/Makefile.in b/test/Makefile.in index 7c201eab..34656eca 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -573,6 +573,9 @@ EXTRA_DIST = \ fsfwfs.awk \ fsfwfs.in \ fsfwfs.ok \ + fsnul1.awk \ + fsnul1.in \ + fsnul1.ok \ fsrs.awk \ fsrs.in \ fsrs.ok \ @@ -1312,7 +1315,7 @@ BASIC_TESTS = \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ eofsplit exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ - fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ + fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsnul1 fsrs fsspcoln \ fstabplus funsemnl funsmnam funstack \ getline getline2 getline3 getline4 getline5 getlnbuf getnr2tb getnr2tm \ gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \ @@ -2908,6 +2911,11 @@ fsbs: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +fsnul1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fsrs: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index c16bdc25..e5bde1d2 100644 --- a/test/Maketests +++ b/test/Maketests @@ -315,6 +315,11 @@ fsbs: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +fsnul1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fsrs: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/fsnul1.awk b/test/fsnul1.awk new file mode 100644 index 00000000..5a1b473b --- /dev/null +++ b/test/fsnul1.awk @@ -0,0 +1,2 @@ +BEGIN { FS = "\0" ; RS = "" } +{ print $2 } diff --git a/test/fsnul1.in b/test/fsnul1.in new file mode 100644 index 00000000..7dec250c Binary files /dev/null and b/test/fsnul1.in differ diff --git a/test/fsnul1.ok b/test/fsnul1.ok new file mode 100644 index 00000000..ab4a9819 --- /dev/null +++ b/test/fsnul1.ok @@ -0,0 +1 @@ +ho -- cgit v1.2.3