From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6029 invoked from network); 13 Feb 2006 19:48:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Feb 2006 19:48:54 -0000 Received: (qmail 17833 invoked from network); 13 Feb 2006 19:48:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 19:48:48 -0000 Received: (qmail 18810 invoked by alias); 13 Feb 2006 19:48:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22266 Received: (qmail 18800 invoked from network); 13 Feb 2006 19:48:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Feb 2006 19:48:44 -0000 Received: (qmail 17531 invoked from network); 13 Feb 2006 19:48:44 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 19:48:43 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id 4B2A55EDF; Mon, 13 Feb 2006 11:48:42 -0800 (PST) Date: Mon, 13 Feb 2006 11:48:42 -0800 From: Wayne Davison To: Peter Stephenson Cc: Zsh hackers list Subject: Re: PATCH: fixing ${1+"$@"} when word-splitting Message-ID: <20060213194842.GF6952@dot.blorf.net> References: <20060211181440.GA30984@dot.blorf.net> <200602122026.k1CKQHGH003629@pwslaptop.csr.com> <20060213105349.GD31780@dot.blorf.net> <20060213174338.GC6952@dot.blorf.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="FFoLq8A0u+X9iRU8" Content-Disposition: inline In-Reply-To: <20060213174338.GC6952@dot.blorf.net> User-Agent: Mutt/1.5.11 --FFoLq8A0u+X9iRU8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 13, 2006 at 09:43:38AM -0800, Wayne Davison wrote: > insertlinknode(&foo, n, (void *)x), incnode(n); > + mult_isarr = 1; > } This turned out to be inadequate in the face of the following expansion: print -l ${=1:-$LINES $COLUMNS} This is because mult_isarr got reset to 0. The attached patch fixes this (which should be applied to whatever patched version you're using). ..wayne.. --FFoLq8A0u+X9iRU8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="better-splitting.diff" --- Src/subst.c 2006-02-13 11:35:16.000000000 -0800 +++ Src/subst.c 2006-02-13 11:40:48.000000000 -0800 @@ -337,6 +337,7 @@ if (split) { LinkNode n = firstnode(&foo); int inq = 0, inp = 0; + split = 0; /* used to flag if we really split anything */ for ( ; *x; x += l+1) { char c = (l = *x == Meta) ? x[1] ^ 32 : *x; if (!inq && !inp && isep(c)) { @@ -349,7 +350,7 @@ if (!*x) break; insertlinknode(&foo, n, (void *)x), incnode(n); - mult_isarr = 1; + split = 1; } switch (c) { case Dnull: @@ -375,6 +376,9 @@ mult_isarr = omi; return 0; } + if (split) + mult_isarr = 1; + if ((l = countlinknodes(&foo)) > 1 || (a && mult_isarr)) { p = r = hcalloc((l + 1) * sizeof(char*)); while (nonempty(&foo)) --FFoLq8A0u+X9iRU8--