Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: fixing ${1+"$@"} when word-splitting
- X-seq: zsh-workers 22266
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: PATCH: fixing ${1+"$@"} when word-splitting
- Date: Mon, 13 Feb 2006 11:48:42 -0800
- Cc: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <20060213174338.GC6952@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20060211181440.GA30984@xxxxxxxxxxxxx> <200602122026.k1CKQHGH003629@xxxxxxxxxxxxxxxxx> <20060213105349.GD31780@xxxxxxxxxxxxx> <EXCHANGE03NXLbrBmWU0000c118@xxxxxxxxxxxxxxxxxx> <20060213174338.GC6952@xxxxxxxxxxxxx>
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..
--- 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))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author