summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2026-06-04 06:44:16 +0200
committerMikael Magnusson <mikachu@gmail.com>2026-06-07 12:45:30 +0200
commitdda9d01fde4f6d692c1d66f458583abd0f084ef3 (patch)
tree9ceb96463b378bf9f27ed0b4e030cf7ee2691e97
parent54670: don't cache the user saying --disable-multibyte as meaning multibyte s... (diff)
downloadzsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar.gz
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar.bz2
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar.lz
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar.xz
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.tar.zst
zsh-dda9d01fde4f6d692c1d66f458583abd0f084ef3.zip
54671: fix anchored pattern with --disable-multibyte
Just copied this code over from the multibyte branch.
-rw-r--r--ChangeLog3
-rw-r--r--Src/glob.c14
-rw-r--r--Test/D04parameter.ztst21
3 files changed, 36 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ca1f16ef2..846c34cfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2026-06-07 Mikael Magnusson <mikachu@gmail.com>
+ * 54671: Src/glob.c, Test/D04parameter.ztst: fix anchored pattern
+ with --disable-multibyte
+
* 54670: configure.ac: don't cache the user saying
--disable-multibyte as meaning multibyte support was detected
broken
diff --git a/Src/glob.c b/Src/glob.c
index e9967cad1..5c6288060 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -3350,13 +3350,23 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Largest possible match at tail of string: *
* move forward along string until we get a match. *
* Again there's no optimisation. */
- for (ioff = 0, t = s, umlen = uml; t <= send;
- ioff++, t++, umlen--) {
+ for (ioff = 0, t = s, umlen = uml; t <= send; ioff++) {
set_pat_start(p, t-s);
if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff)) {
*sp = get_match_ret(&imd, t-s, uml);
return 1;
}
+ if (fl & SUB_START)
+ break;
+ if (t == send)
+ break;
+ t++;
+ umlen--;
+ }
+ if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
+ &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, uml, uml);
+ return 1;
}
break;
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 218bca739..6a039d483 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2460,6 +2460,27 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>different
>string
+ foo="abcdef"
+ print 1${foo/#abc/REPLACED}
+ print 2${foo/%abc/REPLACED}
+ print 3${foo/#%abc/REPLACED}
+ print 4${foo/#def/REPLACED}
+ print 5${foo/%def/REPLACED}
+ print 6${foo/#%def/REPLACED}
+ print 7${foo/#bc/REPLACED}
+ print 8${foo/%bc/REPLACED}
+ print 9${foo/#%bc/REPLACED}
+0:Respect anchors
+>1REPLACEDdef
+>2abcdef
+>3abcdef
+>4abcdef
+>5abcREPLACED
+>6abcdef
+>7abcdef
+>8abcdef
+>9abcdef
+
my_width=6
my_index=1
my_options=Option1