diff options
-rwxr-xr-x | ChangeLog | 8 | ||||
-rw-r--r-- | re.c | 8 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/trailbs.awk | 1 | ||||
-rw-r--r-- | test/trailbs.in | 1 | ||||
-rw-r--r-- | test/trailbs.ok | 2 |
9 files changed, 42 insertions, 3 deletions
@@ -1,5 +1,13 @@ 2018-09-21 Arnold D. Robbins <arnold@skeeve.com> + * re.c (make_regexp): Handle backslash at end of + input string. Thanks to Anatoly Trosinenko + <anatoly.trosinenko@gmail.com> for the report. + Also, improve the error message when compilation of + the regexp fails. + +2018-09-21 Arnold D. Robbins <arnold@skeeve.com> + * io.c (fork_and_open_slave_pty): Move an errant close brace inside the #endif so that gawk will compile on AIX. Thanks to Fredrik Laurin <fredrik_laurin@yahoo.se> for the report. @@ -112,6 +112,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) (*src == '\\')) { c = *++src; switch (c) { + case '\0': /* \\ before \0, either dynamic data or real end of string */ + if (src >= s + len) + *dest++ = '\\'; // at end of string, will fatal below + else + fatal(_("invalid NUL byte in dynamic regexp")); + break; case 'a': case 'b': case 'f': @@ -241,7 +247,7 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) error("%s: /%s/", rerr, buf); return NULL; } - fatal("%s: /%s/", rerr, buf); + fatal("invalid regexp: %s: /%s/", rerr, buf); } /* gack. this must be done *after* re_compile_pattern */ diff --git a/test/ChangeLog b/test/ChangeLog index adc93aec..4eb36e08 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2018-09-21 Arnold D. Robbins <arnold@skeeve.com> + + * Maefile.am (EXTRA_DIST): New test: trailbs. + * trailbs.awk, trailbs.in, trailbs.ok: New files. + 2018-09-16 Arnold D. Robbins <arnold@skeeve.com> * Makefile.in: Regenerated, using Automake 1.16.1. diff --git a/test/Makefile.am b/test/Makefile.am index 74f82aa2..3eca3e97 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1161,6 +1161,9 @@ EXTRA_DIST = \ tradanch.awk \ tradanch.in \ tradanch.ok \ + trailbs.awk \ + trailbs.in \ + trailbs.ok \ tweakfld.awk \ tweakfld.in \ tweakfld.ok \ @@ -1270,7 +1273,7 @@ BASIC_TESTS = \ sigpipe1 sortempty sortglos spacere splitargv splitarr \ splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \ - tailrecurse tradanch tweakfld \ + tailrecurse tradanch trailbs tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ zero2 zeroe0 zeroflag diff --git a/test/Makefile.in b/test/Makefile.in index 34ec85bc..3a6f5649 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1419,6 +1419,9 @@ EXTRA_DIST = \ tradanch.awk \ tradanch.in \ tradanch.ok \ + trailbs.awk \ + trailbs.in \ + trailbs.ok \ tweakfld.awk \ tweakfld.in \ tweakfld.ok \ @@ -1528,7 +1531,7 @@ BASIC_TESTS = \ sigpipe1 sortempty sortglos spacere splitargv splitarr \ splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \ - tailrecurse tradanch tweakfld \ + tailrecurse tradanch trailbs tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ zero2 zeroe0 zeroflag @@ -3767,6 +3770,11 @@ tradanch: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --traditional < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +trailbs: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + uninit2: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index eb7c4651..e24fed82 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1113,6 +1113,11 @@ tradanch: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --traditional < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +trailbs: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + uninit2: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/trailbs.awk b/test/trailbs.awk new file mode 100644 index 00000000..9b8c6d63 --- /dev/null +++ b/test/trailbs.awk @@ -0,0 +1 @@ +0~$0
\ No newline at end of file diff --git a/test/trailbs.in b/test/trailbs.in new file mode 100644 index 00000000..4434fe2b --- /dev/null +++ b/test/trailbs.in @@ -0,0 +1 @@ +00000ķa000000000000000\
\ No newline at end of file diff --git a/test/trailbs.ok b/test/trailbs.ok new file mode 100644 index 00000000..b0bb8d3a --- /dev/null +++ b/test/trailbs.ok @@ -0,0 +1,2 @@ +gawk: trailbs.awk:1: (FILENAME=- FNR=1) fatal: invalid regexp: Trailing backslash: /00000ķa000000000000000\/ +EXIT CODE: 2 |