[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5077-ga72e1831
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5077-ga72e1831 |
Date: |
Wed, 13 Sep 2023 21:05:19 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-5.2-stable has been updated
via a72e18316329e8e3a3b50f95f29e207b394d79f6 (commit)
from c85749daba596ba2b827bcea239db74fc5321665 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a72e18316329e8e3a3b50f95f29e207b394d79f6
commit a72e18316329e8e3a3b50f95f29e207b394d79f6
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Sep 13 18:04:46 2023 -0700
Fix null matches around multibyte characters in sub/gsub.
diff --git a/ChangeLog b/ChangeLog
index bbdc869b..c6804689 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-09-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ Fix handling of zero length matching in multibyte locales
+ with sub/gsub. Thanks again to Ed Morton for the report.
+
+ * builtin.c (do_sub): When the match is empty and we copy in
+ the subsequent character, check gawk_mb_cur_max to know whether
+ to copy one byte or multiple bytes.
+
2023-09-01 Miguel Pineiro Jr <mpj@pineiro.cc>
Fix the handling of zero-length matches in multibyte locales.
diff --git a/builtin.c b/builtin.c
index 2bc0aaa3..88663ebe 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2962,6 +2962,8 @@ do_match(int nargs)
*
* 7/2011: Reverted backslash handling to what it used to be. It was in
* gawk for too long. Should have known better.
+ *
+ * 9/2023: Update for matches of null strings around multibyte characters.
*/
/*
@@ -3264,8 +3266,20 @@ do_sub(int nargs, unsigned int flags)
empty:
/* catch the case of gsub(//, "blah", whatever), i.e. empty
regexp */
if (matchstart == matchend && matchend < text + textlen) {
- *bp++ = *matchend;
- matchend++;
+ // copy in regular text
+ if (gawk_mb_cur_max == 1) {
+ *bp++ = *matchend;
+ matchend++;
+ } else {
+ mbstate_t mbs;
+ size_t i, j;
+
+ memset(& mbs, 0, sizeof(mbs));
+ j = mbrlen(matchend, (target->stptr +
target->stlen) - matchend, & mbs);
+ // FIXME: Error checking on the value of `j'
would be a good idea....
+ for (i = 0; i < j; i++)
+ *bp++ = *matchend++;
+ }
}
textlen = text + textlen - matchend;
text = matchend;
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 2eea265d..ba84284e 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2023-09-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.tst: Regenerated.
+
2023-09-01 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.tst: Regenerated.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index d1d7c856..afc7124d 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -159,7 +159,8 @@ BASIC_TESTS = \
fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
getline2 getline3 getline4 getline5 getlnbuf getlnfa getnr2tb \
- getnr2tm gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
+ getnr2tm gsubasgn gsubnulli18n \
+ gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
gsubtst6 gsubtst7 gsubtst8 hex hex2 hsprint inpref inputred intest \
intprec iobug1 leaddig leadnl litoct longsub longwrds manglprm \
math membug1 memleak messages minusstr mmap8k nasty nasty2 negexp \
@@ -310,7 +311,8 @@ NEED_LOCALE_C = \
clos1way gsubtst6 range2
NEED_LOCALE_EN = \
- backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 ignrcas2
lc_num1 \
+ backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 \
+ gsubnulli18n ignrcas2 lc_num1 \
mbfw1 mbprintf1 mbprintf3 mbprintf4 mbstr1 mbstr2 \
mtchi18n2 posix_compare \
printhuge reint2 rri1 subamp subi18n wideidx wideidx2 \
@@ -1787,6 +1789,12 @@ gsubasgn:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+gsubnulli18n:
+ @echo $@
+ @-[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=ENU_USA.1252; export GAWKLOCALE; \
+ AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
gsubtest:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index 7ed0832b..28a0a0db 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2023-09-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (EXTRA_DIST): New test, gsubnulli18n.
+ * gsubnulli18n.awk, gsubnulli18n.ok: New files.
+
2023-09-01 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (EXTRA_DIST): New test, mtchi18n2.
diff --git a/test/Makefile.am b/test/Makefile.am
index fe37d58f..b20fa576 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -532,6 +532,8 @@ EXTRA_DIST = \
gsubasgn.ok \
gsubind.awk \
gsubind.ok \
+ gsubnulli18n.awk \
+ gsubnulli18n.ok \
gsubtest.awk \
gsubtest.ok \
gsubtst2.awk \
@@ -1483,7 +1485,8 @@ BASIC_TESTS = \
fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
getline2 getline3 getline4 getline5 getlnbuf getlnfa getnr2tb \
- getnr2tm gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
+ getnr2tm gsubasgn gsubnulli18n \
+ gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
gsubtst6 gsubtst7 gsubtst8 hex hex2 hsprint inpref inputred intest \
intprec iobug1 leaddig leadnl litoct longsub longwrds manglprm \
math membug1 memleak messages minusstr mmap8k nasty nasty2 negexp \
@@ -1633,7 +1636,8 @@ NEED_LOCALE_C = \
clos1way gsubtst6 range2
NEED_LOCALE_EN = \
- backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 ignrcas2
lc_num1 \
+ backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 \
+ gsubnulli18n ignrcas2 lc_num1 \
mbfw1 mbprintf1 mbprintf3 mbprintf4 mbstr1 mbstr2 \
mtchi18n2 posix_compare \
printhuge reint2 rri1 subamp subi18n wideidx wideidx2 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 7fe4e7a1..5ed1b735 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -800,6 +800,8 @@ EXTRA_DIST = \
gsubasgn.ok \
gsubind.awk \
gsubind.ok \
+ gsubnulli18n.awk \
+ gsubnulli18n.ok \
gsubtest.awk \
gsubtest.ok \
gsubtst2.awk \
@@ -1751,7 +1753,8 @@ BASIC_TESTS = \
fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
getline2 getline3 getline4 getline5 getlnbuf getlnfa getnr2tb \
- getnr2tm gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
+ getnr2tm gsubasgn gsubnulli18n \
+ gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 \
gsubtst6 gsubtst7 gsubtst8 hex hex2 hsprint inpref inputred intest \
intprec iobug1 leaddig leadnl litoct longsub longwrds manglprm \
math membug1 memleak messages minusstr mmap8k nasty nasty2 negexp \
@@ -1902,7 +1905,8 @@ NEED_LOCALE_C = \
clos1way gsubtst6 range2
NEED_LOCALE_EN = \
- backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 ignrcas2
lc_num1 \
+ backbigs1 backsmalls1 backsmalls2 commas concat4 dfamb1 \
+ gsubnulli18n ignrcas2 lc_num1 \
mbfw1 mbprintf1 mbprintf3 mbprintf4 mbstr1 mbstr2 \
mtchi18n2 posix_compare \
printhuge reint2 rri1 subamp subi18n wideidx wideidx2 \
@@ -3567,6 +3571,12 @@ gsubasgn:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+gsubnulli18n:
+ @echo $@
+ @-[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; export GAWKLOCALE; \
+ AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
gsubtest:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 8284e165..e7ad8c52 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -477,6 +477,12 @@ gsubasgn:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+gsubnulli18n:
+ @echo $@
+ @-[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; export GAWKLOCALE; \
+ AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
gsubtest:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE:
$$? >>_$@
diff --git a/test/gsubnulli18n.awk b/test/gsubnulli18n.awk
new file mode 100644
index 00000000..874586ea
--- /dev/null
+++ b/test/gsubnulli18n.awk
@@ -0,0 +1,5 @@
+BEGIN {
+ str = "×××"
+ n = gsub(//, "x", str)
+ print n, str
+}
diff --git a/test/gsubnulli18n.ok b/test/gsubnulli18n.ok
new file mode 100644
index 00000000..7099c3f0
--- /dev/null
+++ b/test/gsubnulli18n.ok
@@ -0,0 +1 @@
+4 x×x×x×x
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 9 +++++++++
builtin.c | 18 ++++++++++++++++--
pc/ChangeLog | 4 ++++
pc/Makefile.tst | 12 ++++++++++--
test/ChangeLog | 5 +++++
test/Makefile.am | 8 ++++++--
test/Makefile.in | 14 ++++++++++++--
test/Maketests | 6 ++++++
test/gsubnulli18n.awk | 5 +++++
test/gsubnulli18n.ok | 1 +
10 files changed, 74 insertions(+), 8 deletions(-)
create mode 100644 test/gsubnulli18n.awk
create mode 100644 test/gsubnulli18n.ok
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5077-ga72e1831,
Arnold Robbins <=