diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | re.c | 18 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 12 | ||||
-rw-r--r-- | test/Makefile.in | 12 | ||||
-rw-r--r-- | test/colonwarn.awk | 4 | ||||
-rw-r--r-- | test/colonwarn.in | 1 | ||||
-rw-r--r-- | test/colonwarn.ok | 3 |
8 files changed, 57 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2013-03-11 Arnold D. Robbins <arnold@skeeve.com> + + * re.c (check_bracket_exp): Make handling of embedded ] in + regexp smarter. Thanks to Ed Morton <mortoneccc@comcast.net> + for reporting the bug. + 2013-02-26 Arnold D. Robbins <arnold@skeeve.com> * parse.y (expression_list): In case of error return the list @@ -564,8 +564,22 @@ again: if (*sp == '[') count++; - else if (*sp == ']') - count--; + /* + * ] as first char after open [ is skipped + * \] is skipped + * [^]] is skipped + */ + if (*sp == ']' && sp > sp2) { + if (sp[-1] != '[' + && sp[-1] != '\\') + ; + else if ((sp - sp2) >= 2 + && sp[-1] == '^' && sp[-2] == '[') + ; + else + count--; + } + if (*sp == '-' && do_lint && ! range_warned && count == 1 && sp[-1] != '[' && sp[1] != ']' && ! isdigit((unsigned char) sp[-1]) && ! isdigit((unsigned char) sp[1]) diff --git a/test/ChangeLog b/test/ChangeLog index bd78c510..9774277f 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2013-03-11 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (colonwarn): New test. + * colonwarn.awk, colonwarn.in, colonwarn.ok: New files. + 2013-02-26 Arnold D. Robbins <arnold@skeeve.com> * parseme.ok: Update after change in grammar. Now with new and diff --git a/test/Makefile.am b/test/Makefile.am index f59aa52a..ee57bdd1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -134,6 +134,9 @@ EXTRA_DIST = \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ + colonwarn.awk \ + colonwarn.in \ + colonwarn.ok \ compare.awk \ compare.in \ compare.ok \ @@ -848,7 +851,7 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - clos1way delsub devfd devfd1 devfd2 dumpvars exit \ + colonwarn clos1way delsub devfd devfd1 devfd2 dumpvars exit \ fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \ fwtest fwtest2 fwtest3 \ gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ @@ -1487,6 +1490,13 @@ reginttrad: @$(AWK) --traditional -r -f $@.awk > _$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +colonwarn: + @echo $@ + @for i in 1 2 3 ; \ + do $(AWK) -f $(srcdir)/$@.awk $$i < $(srcdir)/$@.in ; \ + done > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + # Targets generated for other tests: include Maketests diff --git a/test/Makefile.in b/test/Makefile.in index 3066c31c..b6aa3f67 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -338,6 +338,9 @@ EXTRA_DIST = \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ + colonwarn.awk \ + colonwarn.in \ + colonwarn.ok \ compare.awk \ compare.in \ compare.ok \ @@ -1052,7 +1055,7 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - clos1way delsub devfd devfd1 devfd2 dumpvars exit \ + colonwarn clos1way delsub devfd devfd1 devfd2 dumpvars exit \ fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \ fwtest fwtest2 fwtest3 \ gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ @@ -1863,6 +1866,13 @@ reginttrad: @echo $@ @$(AWK) --traditional -r -f $@.awk > _$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +colonwarn: + @echo $@ + @for i in 1 2 3 ; \ + do $(AWK) -f $(srcdir)/$@.awk $$i < $(srcdir)/$@.in ; \ + done > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ Gt-dummy: # file Maketests, generated from Makefile.am by the Gentests program addcomma: diff --git a/test/colonwarn.awk b/test/colonwarn.awk new file mode 100644 index 00000000..0b0650e0 --- /dev/null +++ b/test/colonwarn.awk @@ -0,0 +1,4 @@ +BEGIN { pattern = ARGV[1] + 0; delete ARGV } +pattern == 1 { sub(/[][:space:]]/,""); print } +pattern == 2 { sub(/[\][:space:]]/,""); print } +pattern == 3 { sub(/[^][:space:]]/,""); print } diff --git a/test/colonwarn.in b/test/colonwarn.in new file mode 100644 index 00000000..d34368d7 --- /dev/null +++ b/test/colonwarn.in @@ -0,0 +1 @@ +a]b diff --git a/test/colonwarn.ok b/test/colonwarn.ok new file mode 100644 index 00000000..d084ee3d --- /dev/null +++ b/test/colonwarn.ok @@ -0,0 +1,3 @@ +ab +ab +]b |