aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-06-14 21:30:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-06-14 21:30:50 +0300
commit92edf3d8864ca092c9cffb7e1211e38ef7556be5 (patch)
tree8c9de16a939fc069a339c5ddfd9c0b4802637bd3
parent68773e1444b7e353346e52756e9db8fb487b56d4 (diff)
parentb5a63ab37a2d018b0ae08abbf76ee2e88c3aff4c (diff)
downloadegawk-92edf3d8864ca092c9cffb7e1211e38ef7556be5.tar.gz
egawk-92edf3d8864ca092c9cffb7e1211e38ef7556be5.tar.bz2
egawk-92edf3d8864ca092c9cffb7e1211e38ef7556be5.zip
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog4
-rw-r--r--builtin.c10
-rw-r--r--pc/ChangeLog6
-rw-r--r--pc/Makefile.tst22
-rw-r--r--test/ChangeLog17
-rw-r--r--test/Makefile.am12
-rw-r--r--test/Makefile.in17
-rw-r--r--test/Maketests5
-rw-r--r--test/mixed1.ok4
-rw-r--r--test/subback.awk16
-rw-r--r--test/subback.in1
-rw-r--r--test/subback.ok12
12 files changed, 111 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 055eb7d0..dffa8918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2016-06-14 Arnold D. Robbins <arnold@skeeve.com>
+ * builtin.c (do_sub): Fix sub for long runs of backslashes.
+ Thanks to Mike Brennan for the report.
+
+ Unrelated:
* ext.c (get_argument): Remove unused variable pcount.
2016-06-10 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/builtin.c b/builtin.c
index 285b442b..888fa10c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2973,8 +2973,10 @@ set_how_many:
leave alone, it goes into the output */
} else {
/* gawk default behavior since 1996 */
- if (strncmp(scan, "\\\\\\&", 4) == 0) {
+ if (strncmp(scan, "\\\\\\&", 4) == 0
+ || strncmp(scan, "\\\\\\\\", 4) == 0) { /* 2016: fixed */
/* \\\& --> \& */
+ /* \\\\ --> \\ */
repllen -= 2;
scan += 3;
} else if (strncmp(scan, "\\\\&", 3) == 0) {
@@ -3087,10 +3089,12 @@ set_how_many:
*bp++ = *scan;
} else {
/* gawk default behavior since 1996 */
- if (strncmp(scan, "\\\\\\&", 4) == 0) {
+ if (strncmp(scan, "\\\\\\&", 4) == 0
+ || strncmp(scan, "\\\\\\\\", 4) == 0) { /* 2016: fixed */
/* \\\& --> \& */
+ /* \\\\ --> \\ */
*bp++ = '\\';
- *bp++ = '&';
+ *bp++ = scan[3];
scan += 3;
} else if (strncmp(scan, "\\\\&", 3) == 0) {
/* \\& --> \<string> */
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 1f93d451..4154fcba 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.tst: Sync with mainline:
+ (mixed1, symtab10, subback): New tests.
+ (FAIL_CODE1): Updated.
+
2016-05-25 Eli Zaretskii <eliz@gnu.org>
* Makefile.tst (BASIC_TESTS): Add arrayind1 and sigpipe1.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 404d4b66..e4414294 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -171,7 +171,7 @@ BASIC_TESTS = \
reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \
- splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
+ splitvar splitwht strcat1 strnum1 strtod subamp subback subi18n \
subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
@@ -193,7 +193,7 @@ GAWK_EXT_TESTS = \
incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \
include include2 indirectbuiltin indirectcall indirectcall2 \
lint lintold lintwarn \
- manyfiles match1 match2 match3 mbstr1 mbstr2 \
+ mixed1 manyfiles match1 match2 match3 mbstr1 mbstr2 \
muldimposix \
nastyparm negtime next nondec nondec2 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
@@ -203,7 +203,7 @@ GAWK_EXT_TESTS = \
rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
splitarg4 strftime \
strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
- symtab7 symtab8 symtab9 \
+ symtab7 symtab8 symtab9 symtab10 \
watchpoint1
EXTRA_TESTS = inftest regtest
@@ -233,7 +233,10 @@ NEED_LINT_OLD = lintold
# List of the tests which fail with EXIT CODE 1
FAIL_CODE1 = \
- fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm
+ badassign1 badbuild callparam delfunc fcall_exit fcall_exit2 \
+ fnamedat fnarray fnarray2 fnasgnm fnmisc funsmnam gsubasgn \
+ incdupe2 lintwarn match2 mixed1 noparms paramasfunc1 paramasfunc2 \
+ paramdup paramres parseme readbuf synerr1 synerr2 unterm
# List of files which have .ok versions for MPFR
@@ -1281,6 +1284,12 @@ rscompat:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) --traditional -f $@.awk "$(srcdir)/$@.in" >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+symtab10:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < "$(srcdir)/$@.in" >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
@@ -2171,6 +2180,11 @@ strtod:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+subback:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
subsepnm:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index 49ad457e..5f2d683f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,20 @@
+2016-06-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (subback): New test.
+ * subback.awk, subback.in, subback.ok: New files.
+ Thanks to Mike Brennan for the test.
+
+ Unrelated:
+
+ * Makefile.am (FAIL_CODE1): Update the list.
+
+2016-06-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (GAWK_EXT_TESTS): Add mixed1. Who knows
+ how long that's been broken...
+ * mixed1.ok: Adjust to match what the code produces.
+ Thanks to John E. Malmberg <wb8tyw@qsl.net> for the report.
+
2016-06-08 Arnold D. Robbins <arnold@skeeve.com>
* symtab10.awk, symtab10.in, symtab10.ok: New files.
diff --git a/test/Makefile.am b/test/Makefile.am
index 9d95a609..7ec75508 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -985,6 +985,9 @@ EXTRA_DIST = \
subamp.awk \
subamp.in \
subamp.ok \
+ subback.awk \
+ subback.in \
+ subback.ok \
subi18n.awk \
subi18n.ok \
subsepnm.awk \
@@ -1138,7 +1141,7 @@ BASIC_TESTS = \
reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \
- splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
+ splitvar splitwht strcat1 strnum1 strtod subamp subback subi18n \
subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
@@ -1161,7 +1164,7 @@ GAWK_EXT_TESTS = \
incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \
include include2 indirectbuiltin indirectcall indirectcall2 \
lint lintold lintwarn \
- manyfiles match1 match2 match3 mbstr1 mbstr2 \
+ mixed1 manyfiles match1 match2 match3 mbstr1 mbstr2 \
muldimposix \
nastyparm negtime next nondec nondec2 \
nonfatal1 nonfatal2 nonfatal3 \
@@ -1206,7 +1209,10 @@ NEED_LINT_OLD = lintold
# List of the tests which fail with EXIT CODE 1
FAIL_CODE1 = \
- fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm
+ badassign1 badbuild callparam delfunc fcall_exit fcall_exit2 \
+ fnamedat fnarray fnarray2 fnasgnm fnmisc funsmnam gsubasgn \
+ incdupe2 lintwarn match2 mixed1 noparms paramasfunc1 paramasfunc2 \
+ paramdup paramres parseme readbuf synerr1 synerr2 unterm
# List of files which have .ok versions for MPFR
CHECK_MPFR = \
diff --git a/test/Makefile.in b/test/Makefile.in
index 67fc7b45..dda34978 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1242,6 +1242,9 @@ EXTRA_DIST = \
subamp.awk \
subamp.in \
subamp.ok \
+ subback.awk \
+ subback.in \
+ subback.ok \
subi18n.awk \
subi18n.ok \
subsepnm.awk \
@@ -1394,7 +1397,7 @@ BASIC_TESTS = \
reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \
- splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
+ splitvar splitwht strcat1 strnum1 strtod subamp subback subi18n \
subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
@@ -1417,7 +1420,7 @@ GAWK_EXT_TESTS = \
incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \
include include2 indirectbuiltin indirectcall indirectcall2 \
lint lintold lintwarn \
- manyfiles match1 match2 match3 mbstr1 mbstr2 \
+ mixed1 manyfiles match1 match2 match3 mbstr1 mbstr2 \
muldimposix \
nastyparm negtime next nondec nondec2 \
nonfatal1 nonfatal2 nonfatal3 \
@@ -1461,7 +1464,10 @@ NEED_LINT_OLD = lintold
# List of the tests which fail with EXIT CODE 1
FAIL_CODE1 = \
- fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm
+ badassign1 badbuild callparam delfunc fcall_exit fcall_exit2 \
+ fnamedat fnarray fnarray2 fnasgnm fnmisc funsmnam gsubasgn \
+ incdupe2 lintwarn match2 mixed1 noparms paramasfunc1 paramasfunc2 \
+ paramdup paramres parseme readbuf synerr1 synerr2 unterm
# List of files which have .ok versions for MPFR
@@ -3597,6 +3603,11 @@ strtod:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+subback:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
subsepnm:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 0877ea86..59ff889a 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -897,6 +897,11 @@ strtod:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+subback:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
subsepnm:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/mixed1.ok b/test/mixed1.ok
index 91608fa3..bd6f447d 100644
--- a/test/mixed1.ok
+++ b/test/mixed1.ok
@@ -1,3 +1,3 @@
-gawk: BEGIN {return junk}
-gawk: ^ `return' used outside function context
+gawk: cmd. line:1: BEGIN {return junk}
+gawk: cmd. line:1: ^ `return' used outside function context
EXIT CODE: 1
diff --git a/test/subback.awk b/test/subback.awk
new file mode 100644
index 00000000..d91513c1
--- /dev/null
+++ b/test/subback.awk
@@ -0,0 +1,16 @@
+BEGIN {
+ A[0] = "&"
+ for(i=1;i<=11;i++) {
+ A[i] = "\\" A[i-1]
+ }
+## A[] holds & \& \\& \\\& \\\\& ...
+}
+
+{
+ for(i=0; i <= 11 ; i++) {
+ x = $0
+ sub(/B/, A[i], x)
+ y = gensub(/B/, A[i], "1", $0)
+ print i, x, y
+ }
+}
diff --git a/test/subback.in b/test/subback.in
new file mode 100644
index 00000000..223b7836
--- /dev/null
+++ b/test/subback.in
@@ -0,0 +1 @@
+B
diff --git a/test/subback.ok b/test/subback.ok
new file mode 100644
index 00000000..9792c82b
--- /dev/null
+++ b/test/subback.ok
@@ -0,0 +1,12 @@
+0 B B
+1 & &
+2 \B \B
+3 \& \&
+4 \\B \\B
+5 \\& \\&
+6 \\\B \\\B
+7 \\\& \\\&
+8 \\\\B \\\\B
+9 \\\\& \\\\&
+10 \\\\\B \\\\\B
+11 \\\\\& \\\\\&