From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: How to substitute empty array element, or empty string
Date: Thu, 23 Mar 2017 20:47:18 +0000 [thread overview]
Message-ID: <20170323204718.4882bace@ntlworld.com> (raw)
In-Reply-To: <20170322095212.2ff2dec8@pwslap01u.europe.root.pri>
On Wed, 22 Mar 2017 09:52:12 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> Other cases in igetmatch() may need adaption.
This appears to be one.
pws
diff --git a/Src/glob.c b/Src/glob.c
index 9ac0ae6..af5d082 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2929,7 +2929,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* move forward along string until we get a match. *
* Again there's no optimisation. */
mb_charinit();
- for (ioff = 0, t = s, umlen = umltot; t < send ; ioff++) {
+ for (ioff = 0, t = s, umlen = umltot; t <= send ; ioff++) {
set_pat_start(p, t-s);
if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
*sp = get_match_ret(&imd, t-s, umltot);
@@ -2937,6 +2937,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
if (fl & SUB_START)
break;
+ if (t == send)
+ break;
umlen -= iincchar(&t, send - t);
}
if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 99f7dd9..66d9022 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2158,3 +2158,13 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>x
>x
>y
+
+ a=(1 "" 3)
+ print -rl -- "${(@)a//#%*/x}"
+ a=""
+ print -rl -- "${(@)a//#%*/y}"
+0:Zero-length string match at end
+>x
+>x
+>x
+>y
parent reply other threads:[~2017-03-23 20:54 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20170322095212.2ff2dec8@pwslap01u.europe.root.pri>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170323204718.4882bace@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).