Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix anchored pattern with --disable-multibyte
- X-seq: zsh-workers 54671
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: fix anchored pattern with --disable-multibyte
- Date: Thu, 4 Jun 2026 07:31:29 +0200
- Archived-at: <https://zsh.org/workers/54671>
- List-id: <zsh-workers.zsh.org>
Just copied this code over from the multibyte branch.
---
Src/glob.c | 14 ++++++++++++--
Test/D04parameter.ztst | 21 +++++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/Src/glob.c b/Src/glob.c
index e9967cad1a..5c6288060a 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 218bca739b..6a039d4830 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
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author