summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-27 18:30:12 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-27 18:30:12 +0300
commit8dedda4944d453e2b9fe3e6d0234f7cae1e894c7 (patch)
tree3d4819655a99cf17a6abb2f8367792ddb8b6ac4c
parente78dfd4b04060ad3278a1b3505720893ec432617 (diff)
parent454ae7c0f350842ab40a30ff4a2643cd76e8e277 (diff)
downloadgawk-8dedda4944d453e2b9fe3e6d0234f7cae1e894c7.tar.gz
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog5
-rw-r--r--awkgram.c4
-rw-r--r--awkgram.y4
-rw-r--r--test/ChangeLog6
-rw-r--r--test/Makefile.am5
-rw-r--r--test/Makefile.in10
-rw-r--r--test/Maketests5
-rw-r--r--test/regexpbrack2.awk2
-rw-r--r--test/regexpbrack2.in2
-rw-r--r--test/regexpbrack2.ok2
10 files changed, 39 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 327af606..d656f5c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (yylex): Make change of Jan 7 for parsing regexps
+ work better. Thanks to Nelson Beebe.
+
2015-04-26 Arnold D. Robbins <arnold@skeeve.com>
* dfa.c: Sync with grep.
diff --git a/awkgram.c b/awkgram.c
index 6fb66123..68540e88 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -5578,8 +5578,8 @@ yylex(void)
pushback();
break;
case ']':
- if (tok[-1] == '['
- || (tok[-2] == '[' && tok[-1] == '^'))
+ if ((tok[-1] == '[' && tok[-2] != '\\')
+ || (tok[-2] == '[' && tok[-3] != '\\' && tok[-1] == '^'))
/* do nothing */;
else
in_brack--;
diff --git a/awkgram.y b/awkgram.y
index d14cf68e..1102a572 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -3246,8 +3246,8 @@ yylex(void)
pushback();
break;
case ']':
- if (tok[-1] == '['
- || (tok[-2] == '[' && tok[-1] == '^'))
+ if ((tok[-1] == '[' && tok[-2] != '\\')
+ || (tok[-2] == '[' && tok[-3] != '\\' && tok[-1] == '^'))
/* do nothing */;
else
in_brack--;
diff --git a/test/ChangeLog b/test/ChangeLog
index b84345f9..ebd1e3b0 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (regexpbrack2): New test.
+ * regexpbrack2.awk, regexpbrack2.in, regexpbrack2.ok: New files.
+ Thanks to Nelson Beebe.
+
2015-04-16 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (shadowbuiltin): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index d700f475..443245f6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -783,6 +783,9 @@ EXTRA_DIST = \
regexpbrack.awk \
regexpbrack.in \
regexpbrack.ok \
+ regexpbrack2.awk \
+ regexpbrack2.in \
+ regexpbrack2.ok \
regexprange.awk \
regexprange.ok \
reginttrad.awk \
@@ -1045,7 +1048,7 @@ BASIC_TESTS = \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
- rand randtest range1 rebt8b1 redfilnm regeq regexpbrack regexprange regrange reindops \
+ rand randtest range1 rebt8b1 redfilnm regeq regexpbrack regexpbrack2 regexprange regrange reindops \
reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sortempty sortglos splitargv splitarr splitdef \
diff --git a/test/Makefile.in b/test/Makefile.in
index b3a07283..c73cfc80 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1040,6 +1040,9 @@ EXTRA_DIST = \
regexpbrack.awk \
regexpbrack.in \
regexpbrack.ok \
+ regexpbrack2.awk \
+ regexpbrack2.in \
+ regexpbrack2.ok \
regexprange.awk \
regexprange.ok \
reginttrad.awk \
@@ -1301,7 +1304,7 @@ BASIC_TESTS = \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
- rand randtest range1 rebt8b1 redfilnm regeq regexpbrack regexprange regrange reindops \
+ rand randtest range1 rebt8b1 redfilnm regeq regexpbrack regexpbrack2 regexprange regrange reindops \
reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sortempty sortglos splitargv splitarr splitdef \
@@ -3254,6 +3257,11 @@ regexpbrack:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+regexpbrack2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
regexprange:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index aa328bf7..75b9c0a6 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -712,6 +712,11 @@ regexpbrack:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+regexpbrack2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
regexprange:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/regexpbrack2.awk b/test/regexpbrack2.awk
new file mode 100644
index 00000000..81424844
--- /dev/null
+++ b/test/regexpbrack2.awk
@@ -0,0 +1,2 @@
+NR == 1 { gsub(/\\\\[;?!,()<>|+@%\]\[]/, " ") ; print "\"" $0 "\"" }
+NR == 2 { gsub(/\\\\[;?!,()<>|+@%\]\[^]/, " ") ; print "\"" $0 "\"" }
diff --git a/test/regexpbrack2.in b/test/regexpbrack2.in
new file mode 100644
index 00000000..42888dd0
--- /dev/null
+++ b/test/regexpbrack2.in
@@ -0,0 +1,2 @@
+test: \\; \\? \\!
+test: \\; \\? \\!
diff --git a/test/regexpbrack2.ok b/test/regexpbrack2.ok
new file mode 100644
index 00000000..9c2a2922
--- /dev/null
+++ b/test/regexpbrack2.ok
@@ -0,0 +1,2 @@
+"test: "
+"test: "