aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-10-13 14:29:16 -0400
committerArnold D. Robbins <arnold@skeeve.com>2019-10-13 14:29:16 -0400
commit71f74c483838db2e18a7756469aa8c7edc76c33f (patch)
tree018b7830dbed25bf7e1b8145df751cbdccdc4f63
parent8f330804cf3061aacf627ca63f6483207230d7b6 (diff)
downloadegawk-71f74c483838db2e18a7756469aa8c7edc76c33f.tar.gz
egawk-71f74c483838db2e18a7756469aa8c7edc76c33f.tar.bz2
egawk-71f74c483838db2e18a7756469aa8c7edc76c33f.zip
Fix assigning typed regex to FS and RS.
-rw-r--r--ChangeLog9
-rw-r--r--field.c2
-rw-r--r--io.c2
-rw-r--r--test/ChangeLog7
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in17
-rw-r--r--test/Maketests10
-rw-r--r--test/typedregex5.awk2
-rw-r--r--test/typedregex5.in1
-rw-r--r--test/typedregex5.ok1
-rw-r--r--test/typedregex6.awk2
-rw-r--r--test/typedregex6.in1
-rw-r--r--test/typedregex6.ok6
13 files changed, 65 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 858bdaa6..fa78a694 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ Fix handling of assigning @/.../ to FS and RS. Thanks
+ to Stephane Chazelas <stephane.chazelas@gmail.com>
+ for the report.
+
+ * field.c (set_FS): Check for REGEX in the flags.
+ * io.c (set_RS): Ditto.
+
2019-10-04 Arnold D. Robbins <arnold@skeeve.com>
* config.guess, config.sub, install-sh: Updated from GNULIB.
diff --git a/field.c b/field.c
index feba8fd8..8814233a 100644
--- a/field.c
+++ b/field.c
@@ -1311,7 +1311,7 @@ choose_fs_function:
warned = true;
lintwarn(_("null string for `FS' is a gawk extension"));
}
- } else if (fs->stlen > 1) {
+ } else if (fs->stlen > 1 || (fs->flags & REGEX) != 0) {
if (do_lint_old)
lintwarn(_("old awk does not support regexps as value of `FS'"));
set_parser(re_parse_field);
diff --git a/io.c b/io.c
index 710314cc..4bf389b5 100644
--- a/io.c
+++ b/io.c
@@ -4066,7 +4066,7 @@ set_RS()
if (RS->stlen == 0) {
RS_is_null = true;
matchrec = rsnullscan;
- } else if (RS->stlen > 1 && ! do_traditional) {
+ } else if ((RS->stlen > 1 || (RS->flags & REGEX) != 0) && ! do_traditional) {
static bool warned = false;
RS_re[0] = make_regexp(RS->stptr, RS->stlen, false, true, true);
diff --git a/test/ChangeLog b/test/ChangeLog
index 956a0ff8..0ec118e4 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
+2019-10-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (EXTRA_DISTS): New tests, typedregex5 and
+ typedregex6.
+ * typedregex5.awk, typedregex5.ok, typedregex6.in,
+ typedregex5.in, typedregex6.awk, typedregex6.ok: New files.
+
2019-09-24 Jürgen Kahrs Google <juergen.kahrs@googlemail.com>
* Makefile.am (EXTRA_DISTS): New test, mpfranswer42.
diff --git a/test/Makefile.am b/test/Makefile.am
index 62767427..053ff545 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1243,6 +1243,12 @@ EXTRA_DIST = \
typedregex3.ok \
typedregex4.awk \
typedregex4.ok \
+ typedregex5.awk \
+ typedregex5.in \
+ typedregex5.ok \
+ typedregex6.awk \
+ typedregex6.in \
+ typedregex6.ok \
typeof1.awk \
typeof1.ok \
typeof2.awk \
@@ -1384,6 +1390,7 @@ GAWK_EXT_TESTS = \
splitarg4 strftfld strftime strtonum strtonum1 switch2 symtab1 symtab2 \
symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
timeout typedregex1 typedregex2 typedregex3 typedregex4 \
+ typedregex5 typedregex6 \
typeof1 typeof2 typeof3 typeof4 typeof5 \
watchpoint1
diff --git a/test/Makefile.in b/test/Makefile.in
index f5450ff3..357f3b16 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1502,6 +1502,12 @@ EXTRA_DIST = \
typedregex3.ok \
typedregex4.awk \
typedregex4.ok \
+ typedregex5.awk \
+ typedregex5.in \
+ typedregex5.ok \
+ typedregex6.awk \
+ typedregex6.in \
+ typedregex6.ok \
typeof1.awk \
typeof1.ok \
typeof2.awk \
@@ -1643,6 +1649,7 @@ GAWK_EXT_TESTS = \
splitarg4 strftfld strftime strtonum strtonum1 switch2 symtab1 symtab2 \
symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
timeout typedregex1 typedregex2 typedregex3 typedregex4 \
+ typedregex5 typedregex6 \
typeof1 typeof2 typeof3 typeof4 typeof5 \
watchpoint1
@@ -4793,6 +4800,16 @@ typedregex3:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+typedregex5:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+typedregex6:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
typeof1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index a17bf90e..3e443f54 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1966,6 +1966,16 @@ typedregex3:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+typedregex5:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+typedregex6:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
typeof1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/typedregex5.awk b/test/typedregex5.awk
new file mode 100644
index 00000000..f702543b
--- /dev/null
+++ b/test/typedregex5.awk
@@ -0,0 +1,2 @@
+BEGIN { FS = @/./ }
+{ print typeof(FS), $1, NF }
diff --git a/test/typedregex5.in b/test/typedregex5.in
new file mode 100644
index 00000000..7aff6580
--- /dev/null
+++ b/test/typedregex5.in
@@ -0,0 +1 @@
+ab.c
diff --git a/test/typedregex5.ok b/test/typedregex5.ok
new file mode 100644
index 00000000..b986ed9a
--- /dev/null
+++ b/test/typedregex5.ok
@@ -0,0 +1 @@
+regexp 5
diff --git a/test/typedregex6.awk b/test/typedregex6.awk
new file mode 100644
index 00000000..c2d04e6c
--- /dev/null
+++ b/test/typedregex6.awk
@@ -0,0 +1,2 @@
+BEGIN { RS = @/./ }
+{ printf("<%s> <<%s>>\n", $0, RT) }
diff --git a/test/typedregex6.in b/test/typedregex6.in
new file mode 100644
index 00000000..7aff6580
--- /dev/null
+++ b/test/typedregex6.in
@@ -0,0 +1 @@
+ab.c
diff --git a/test/typedregex6.ok b/test/typedregex6.ok
new file mode 100644
index 00000000..39550e8f
--- /dev/null
+++ b/test/typedregex6.ok
@@ -0,0 +1,6 @@
+<> <<a>>
+<> <<b>>
+<> <<.>>
+<> <<c>>
+<> <<
+>>