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

Re: PATCH: _urls, _netscape, a seg fault and new completion thoughts



Bart Schaefer wrote:

> Doesn't work for me either; not even the first bit that works for Oliver.
> I get a listing if I ask for one with ^D, but not with TAB, and automenu
> does not work if there's a quote on the line.  See:
> 
> ...
> 
> Doesn't matter if the command is ls, cd, bindkey ... unambiguous prefixes
> get inserted, but as soon as there's an ambiguity it all stops.

Ah, I didn't understand Oliver, sorry.

The problem was that in d_ambiguous() we test if the line changed or
not to decide if LIST_AMBIGUOUS should be used. But with a quote on the
original line, that quote was intermediately removed, but cline_str()
inserted the final string, so the comparison failed and it thought it
should use LIST_AMBIGUOUS (i.e. don't do anything further in that part 
of the code).

Bye
 Sven

diff -u oldsrc/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- oldsrc/Zle/zle_tricky.c	Wed Oct 13 16:17:37 1999
+++ Src/Zle/zle_tricky.c	Thu Oct 14 08:37:51 1999
@@ -66,7 +66,7 @@
 /* The line before completion was tried. */
 
 static char *origline;
-static int origcs;
+static int origcs, origll;
 
 /* wb and we hold the beginning/end position of the word we are completing. */
 
@@ -936,6 +936,7 @@
     ocs = cs;
     origline = dupstring((char *) line);
     origcs = cs;
+    origll = ll;
     if (!isfirstln && chline != NULL) {
 	/* If we are completing in a multi-line buffer (which was not  *
 	 * taken from the history), we have to prepend the stuff saved *
@@ -8272,15 +8273,11 @@
 	 * completion options.                                             */
 	do_ambig_menu();
     } else if (ainfo) {
-	int atend = (cs == we), oll = ll, la, eq, tcs;
-	VARARR(char, oline, ll);
+	int atend = (cs == we), la, eq, tcs;
 
 	minfo.cur = NULL;
 	minfo.asked = 0;
 
-	/* Copy the line buffer to be able to easily test if it changed. */
-	memcpy(oline, line, ll);
-
 	fixsuffix();
 
 	/* First remove the old string from the line. */
@@ -8299,7 +8296,7 @@
 	/* la is non-zero if listambiguous may be used. Copying and
 	 * comparing the line looks like BFI but it is the easiest
 	 * solution. Really. */
-	la = (ll != oll || strncmp(oline, (char *) line, ll));
+	la = (ll != origll || strncmp(origline, (char *) line, ll));
 
 	/* If REC_EXACT and AUTO_MENU are set and what we inserted is an  *
 	 * exact match, we want menu completion the next time round       *

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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