Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: fixing ${1+"$@"} when word-splitting



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