From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 737 invoked by alias); 4 Mar 2016 12:24:48 -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: 38091 Received: (qmail 1303 invoked from network); 4 Mar 2016 12:24:46 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-AuditID: cbfec7f4-f79026d00000418a-77-56d97c2ea00b Date: Fri, 04 Mar 2016 12:14:35 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Empty $'' Message-id: <20160304121435.0d07611f@pwslap01u.europe.root.pri> In-reply-to: <20160304103502.531f6bb9@pwslap01u.europe.root.pri> References: <1533e4d3e82.cbf3800a134118.3897690426664036468@enosys.org> <160303153436.ZM31948@torch.brasslantern.com> <160303153647.ZM31964@torch.brasslantern.com> <20160304103502.531f6bb9@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xK7p6NTfDDHYds7E42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGRen9TEX3OCs6O3jamA8xd7FyMkhIWAicfBvIxuELSZx4d56 IJuLQ0hgKaPEmn8fmCGcGUwSf389ZIJwTjNKNE+5CJU5wyjxe9FERpB+FgFViVub/rOC2GwC hhJTN80Gi4sIiEucXXueBcQWBtox+cUhsBpeAXuJ/k2XwO7gFHCQ6Jh9jAVi6F1GibNnVjCD JPgF9CWu/v3EBHGgvcTMK2cYIZoFJX5Mvgc2lFlAS2LztiZWCFteYvOat2C9QgLqEjfu7maf wCg8C0nLLCQts5C0LGBkXsUomlqaXFCclJ5rqFecmFtcmpeul5yfu4kREtBfdjAuPmZ1iFGA g1GJh/dGw/UwIdbEsuLK3EOMEhzMSiK8CypvhgnxpiRWVqUW5ccXleakFh9ilOZgURLnnbvr fYiQQHpiSWp2ampBahFMlomDU6qBUW59zo33f+/4L/XUmcIxKyl0kukMZbXXZy4+ClCP2a42 abN3ld0x0f7FVQe1F4awBv97Gud65tyLWj+nE/dDBKOfitvd0akw+M6gEBcp9Xv6zud+BSvd PDTZrgdXbuQV5RPe32EZFJrPrqbzl9/w8izfyIcPVdNyl5Su3+7pcob94kWzZbXHlFiKMxIN tZiLihMBX6m2b2QCAAA= On Fri, 4 Mar 2016 10:35:02 +0000 Peter Stephenson wrote: > nulstring always confused me, but something like this appears to be > correct, so as long as this passes tests (we should presumably add > another). > > Hmm... actually, isn't the usual logic for using nulstring more like > > if (!*strsub) > strret = dupstring(nulstring); Was thinking of something like... diff --git a/Src/subst.c b/Src/subst.c index bb1dd89..f2d0f65 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -145,8 +145,12 @@ stringsubstquote(char *strstart, char **pstrdpos) strret = dyncat(strstart, strsub); } else if (strdpos[len]) strret = dyncat(strsub, strdpos + len); - else + else if (*strsub) strret = strsub; + else { + /* This ensures a $'' doesn't get elided. */ + strret = dupstring(nulstring); + } *pstrdpos = strret + (strdpos - strstart) + strlen(strsub); diff --git a/Test/A03quoting.ztst b/Test/A03quoting.ztst index 0cf0e8a..da3ce35 100644 --- a/Test/A03quoting.ztst +++ b/Test/A03quoting.ztst @@ -74,3 +74,7 @@ >16#61 >16#62 >16#64 + + () { print $# } '' "" $'' +0:$'' should not be elided, in common with other empty quotes +>3