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

Re: Patch available for 3.0.6-pre-0



I wrote:

> I seem to remember that one of the
> patches I sent after 4988 (which is the last entry with my name in it
> in the ChangeLog) fixed something that might be buggy in
> 3.0.[56]. Unfortunately I forgot to write myself a note about this and
> I can't remember what it was.

I found /them/:

 - Completion inside $((...)) didn't work -- see message 5799.
 - The other fix was hidden in 5564: at the end of makecomplist(),
   `addmatches' is set and then a couple of `dumphashtable()'s may be
   called and also some `addmatch()'es directly. Since
   `dumphashtable()' sets `addwhat' but doesn't restore it this may
   sometimes have the wrong value. Most significantly, if you have
   `compctl -vb foo', `foo <TAB>' seg-faults.

The patch also avoids some `suggest brace around ambiguous else'
messages.

Bye
 Sven

--- Src/zle_tricky.c.old	Thu Apr 22 09:04:42 1999
+++ Src/zle_tricky.c	Fri Apr 23 16:05:34 1999
@@ -578,7 +578,7 @@
 	    if (*q == Equals) {
 		/* The word starts with `=', see if we can expand it. */
 		q = s + 1;
-		if (cmdnamtab->getnode(cmdnamtab, q) || hashcmd(q, pathchecked))
+		if (cmdnamtab->getnode(cmdnamtab, q) || hashcmd(q, pathchecked)) {
 		    if (isset(RECEXACT))
 			lst = COMP_EXPAND;
 		    else {
@@ -600,6 +600,7 @@
 			if (n == 1)
 			    lst = COMP_EXPAND;
 		    }
+		}
 	    }
 	    if (lst == COMP_EXPAND_COMPLETE)
 		do {
@@ -708,11 +709,12 @@
 		if (*p == Tilde || *p == Equals)
 		    p++;
 		for (; *p; p++)
-		    if (itok(*p))
+		    if (itok(*p)) {
 			if (*p != String && *p != Qstring)
 			    *p = ztokens[*p - Pound];
 			else if (p[1] == Inbrace)
 			    p++, skipparens(Inbrace, Outbrace, &p);
+		    }
 		docompletion(s, lst, lincmd, 1);
 	    }
 	} else
@@ -1017,12 +1019,16 @@
 	    if (parend >= 0 && !tmp)
 		line = (unsigned char *) dupstring(tmp = (char *)line);
 	    linptr = (char *) line + ll + addedx - parbegin + 1;
-	    if (parend >= 0) {
-		ll -= parend;
-		line[ll + addedx] = '\0';
+
+	    if ((linptr - (char *) line) < 2 ||
+		linptr[-1] != '(' || linptr[-2] != '$') {
+		if (parend >= 0) {
+		    ll -= parend;
+		    line[ll + addedx] = '\0';
+		}
+		lexrestore();
+		goto start;
 	    }
-	    lexrestore();
-	    goto start;
 	}
 
 	if (inwhat == IN_MATH)
@@ -1272,7 +1278,7 @@
 			   *u == (char)bangchar) ||
 	     (instring == 2 &&
 	      (*u == '$' || *u == '`' || *u == '\"')) ||
-	     (instring == 1 && *u == '\'')))
+	     (instring == 1 && *u == '\''))) {
 	    if (*u == '\n' || (instring == 1 && *u == '\'')) {
 		if (unset(RCQUOTES)) {
 		    *v++ = '\'';
@@ -1287,6 +1293,7 @@
 		continue;
 	    } else
 		*v++ = '\\';
+	}
 	if(*u == Meta)
 	    *v++ = *u++;
 	*v++ = *u;
@@ -1923,14 +1930,14 @@
 dumphashtable(HashTable ht, int what)
 {
     HashNode hn;
-    int i;
+    int i, aw = addwhat;
 
     addwhat = what;
 
     for (i = 0; i < ht->hsize; i++)
 	for (hn = ht->nodes[i]; hn; hn = hn->next)
 	    addmatch(hn->nam, (char *) hn);
-
+    addwhat = aw;
 }
 
 /* ScanFunc used by maketildelist() et al. */
@@ -3342,7 +3349,7 @@
 	    menuend = ll;
 	if (menuend && ((((char)line[menuend - 1]) != singlec) ||
 	    (menuend > 1 && singlec == ' ' &&
-	      (line[menuend - 2] == '\\' || line[menuend - 2] == STOUC(Meta)))))
+	     (line[menuend - 2] == '\\' || line[menuend - 2] == STOUC(Meta))))) {
 	    if (parampre && singlec == '/' && ((char)line[menuend]) == '/')
 		addedsuffix = 0;
 	    /* Now insert the slash or space if there is none already. */
@@ -3357,6 +3364,7 @@
 		if (!menuwe)
 		    cs = ccs;
 	    }
+	}
     }
     /* Move to the end of the word if requested. */
     if (isset(ALWAYSTOEND) || menuwe)
@@ -3664,7 +3672,7 @@
 	if (t1 != colsz - 1 || !clearflag)
 	    putc('\n', shout);
     }
-    if (clearflag)
+    if (clearflag) {
 	/* Move the cursor up to the prompt, if always_last_prompt *
 	 * is set and all that...                                  */
 	if (up < lines) {
@@ -3672,6 +3680,7 @@
 	    showinglist = -1;
 	} else
 	    clearflag = 0, putc('\n', shout);
+    }
 }
 
 /* This is used to print expansions. */

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author