From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13917 invoked by alias); 23 Mar 2017 20:54:31 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40891 Received: (qmail 944 invoked from network); 23 Mar 2017 20:54:30 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-7.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.71):SA:0(-2.8/5.0):. Processed in 1.25917 secs); 23 Mar 2017 20:54:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.71 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=SYcKDalu c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=MWUjAzoEKyAA:10 a=hD80L64hAAAA:8 a=npldXguGAAAA:8 a=nW5i4kOOIJypnMPEYQUA:9 a=CjuIK1q_8ugA:10 a=1Z6EAcxPEhoA:10 a=ImLYxMjnSFIJI1KS7skI:22 a=1MEZn5qd6kv58cYvHi58:22 Date: Thu, 23 Mar 2017 20:47:18 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: How to substitute empty array element, or empty string Message-ID: <20170323204718.4882bace@ntlworld.com> In-Reply-To: <20170322095212.2ff2dec8@pwslap01u.europe.root.pri> References: <20170322095212.2ff2dec8@pwslap01u.europe.root.pri> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 22 Mar 2017 09:52:12 +0000 Peter Stephenson 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