aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--awkgram.c6
-rw-r--r--awkgram.y8
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in12
-rw-r--r--test/Maketests5
-rw-r--r--test/regexpbrack.awk2
-rw-r--r--test/regexpbrack.in0
-rw-r--r--test/regexpbrack.ok0
10 files changed, 34 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index a4afb19e..231288ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2015-01-07 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac: Update debug flags if developing.
+ * awkgram.y (yylex): Regex parsing bug fix for bracket expressions.
+ Thanks to Mike Brennan for the report.
2014-12-10 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/awkgram.c b/awkgram.c
index 431954d9..84140eef 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -5374,10 +5374,8 @@ yylex(void)
pushback();
break;
case ']':
- if (tokstart[0] == '['
- && (tok == tokstart + 1
- || (tok == tokstart + 2
- && tokstart[1] == '^')))
+ if (tok[-1] == '['
+ || (tok[-2] == '[' && tok[-1] == '^'))
/* do nothing */;
else
in_brack--;
diff --git a/awkgram.y b/awkgram.y
index 9cf88da3..267cf077 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2014 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-2015 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -3035,10 +3035,8 @@ yylex(void)
pushback();
break;
case ']':
- if (tokstart[0] == '['
- && (tok == tokstart + 1
- || (tok == tokstart + 2
- && tokstart[1] == '^')))
+ if (tok[-1] == '['
+ || (tok[-2] == '[' && tok[-1] == '^'))
/* do nothing */;
else
in_brack--;
diff --git a/test/ChangeLog b/test/ChangeLog
index 8d39af74..95134f6b 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-07 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (regexpbrack): New test.
+ * regexpbrack.awk, regexpbrack.in, regexpbrack.ok: New files.
+
2014-12-24 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (badbuild): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index b93f851f..df0da10c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,7 @@
#
# test/Makefile.am --- automake input file for gawk
#
-# Copyright (C) 1988-2014 the Free Software Foundation, Inc.
+# Copyright (C) 1988-2015 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -742,6 +742,9 @@ EXTRA_DIST = \
regeq.awk \
regeq.in \
regeq.ok \
+ regexpbrack.awk \
+ regexpbrack.in \
+ regexpbrack.ok \
regexprange.awk \
regexprange.ok \
reginttrad.awk \
@@ -999,7 +1002,7 @@ BASIC_TESTS = \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
- rand range1 rebt8b1 redfilnm regeq regexprange regrange reindops \
+ rand range1 rebt8b1 redfilnm regeq regexpbrack 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 7a281eca..5bd39f45 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -17,7 +17,7 @@
#
# test/Makefile.am --- automake input file for gawk
#
-# Copyright (C) 1988-2014 the Free Software Foundation, Inc.
+# Copyright (C) 1988-2015 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -989,6 +989,9 @@ EXTRA_DIST = \
regeq.awk \
regeq.in \
regeq.ok \
+ regexpbrack.awk \
+ regexpbrack.in \
+ regexpbrack.ok \
regexprange.awk \
regexprange.ok \
reginttrad.awk \
@@ -1245,7 +1248,7 @@ BASIC_TESTS = \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
- rand range1 rebt8b1 redfilnm regeq regexprange regrange reindops \
+ rand range1 rebt8b1 redfilnm regeq regexpbrack regexprange regrange reindops \
reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sortempty sortglos splitargv splitarr splitdef \
@@ -3122,6 +3125,11 @@ regeq:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+regexpbrack:
+ @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 e1b92bf9..4104f142 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -697,6 +697,11 @@ regeq:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+regexpbrack:
+ @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/regexpbrack.awk b/test/regexpbrack.awk
new file mode 100644
index 00000000..136cd194
--- /dev/null
+++ b/test/regexpbrack.awk
@@ -0,0 +1,2 @@
+/[]+()0-9.,$%/'"-]*$/
+/^[]+()0-9.,$%/'"-]*$/
diff --git a/test/regexpbrack.in b/test/regexpbrack.in
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/regexpbrack.in
diff --git a/test/regexpbrack.ok b/test/regexpbrack.ok
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/regexpbrack.ok