zsh-workers
 help / color / mirror / code / Atom feed
* Bug in completion with menucomplete and no insertion
@ 1999-06-07 15:21 Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1999-06-07 15:21 UTC (permalink / raw)
  To: Zsh hackers list

I was just testing the closing-stdin code and I got a command wrong and it
caused a (repeatable) crash.  Then I found it works even if I got the
command right(ish).

What I tried first was

% _foo() { compgen -s; }              # mistake, of course
% compdef _foo foo
% foo <TAB>
compgen: command string expected after -s
+4:53% foo
compgen: command string expected after -s

Hitting up arrow and immediately typing any insertion key causes the shell
to crash every time.  Then I found it did the same with

% _foo() { compgen -s ''; }

(except it was a little more erratic getting it to crash).

Presumably something nasty is happening to memory somewhere before that
point.  I checked and it's not even specific to -s: other mistakes in the
get_compctl() called from bin_compgen() do the same thing.  The common
factor seems to be that none of the commands produce matches or insert
anything.  It seems to need menucomplete set as well; I've reproduced it
after zsh -f, compinit, setopt nobeep menucomplete (nobeep is only
necessary for sanity).

Maybe more will turn up after I compile the new version on a system where I
can use mem-debug.

By the way, I've applied the following trivial patch to zle_tricky.c
for shared-library purposes.

--- Src/Zle/zle_tricky.c.csu	Mon Jun  7 13:29:37 1999
+++ Src/Zle/zle_tricky.c	Mon Jun  7 14:43:00 1999
@@ -5077,7 +5077,7 @@
 	}
 	compquote = ztrdup(compquote);
 	compquoting = ztrdup(compquoting);
-	comp_setunset(0, 0, set, unset);
+	comp_setunsetptr(0, 0, set, unset);
 
 	if (unset(COMPLETEINWORD)) {
 	    untokenize(ns);


-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in completion with menucomplete and no insertion
@ 1999-06-08  6:58 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-06-08  6:58 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Presumably something nasty is happening to memory somewhere before that
> point.  I checked and it's not even specific to -s: other mistakes in the
> get_compctl() called from bin_compgen() do the same thing.  The common
> factor seems to be that none of the commands produce matches or insert
> anything.  It seems to need menucomplete set as well; I've reproduced it
> after zsh -f, compinit, setopt nobeep menucomplete (nobeep is only
> necessary for sanity).

Right. For the quote-code I had to add to restore the command line
when no completion could be generated (because get_comp_string()
removes the quote from the line and changing that would have changed
all command line positions held by the completion code). It had
planned to look at this again and then forgot to do so.

> By the way, I've applied the following trivial patch to zle_tricky.c
> for shared-library purposes.

Oh no... I'm sorry.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Mon Jun  7 13:00:08 1999
+++ Src/Zle/zle_tricky.c	Tue Jun  8 08:51:11 1999
@@ -66,7 +66,7 @@
 /* The line before completion was tried. */
 
 static char *origline;
-static int origll, origcs;
+static int origcs;
 
 /* wb and we hold the beginning/end position of the word we are completing. */
 
@@ -864,7 +864,6 @@
     /* Get the word to complete. */
     noerrs = 1;
     origline = dupstring((char *) line);
-    origll = ll;
     origcs = cs;
     s = get_comp_string();
     DPUTS(wb < 0 || cs < wb || cs > we,
@@ -4337,9 +4336,9 @@
 	/* Make sure we have the completion list and compctl. */
 	if (makecomplist(s, incmd, lst)) {
 	    /* Error condition: feeeeeeeeeeeeep(). */
-	    zsfree((char *) line);
-	    line = (unsigned char *) ztrdup(origline);
-	    ll = origll;
+	    cs = 0;
+	    foredel(ll);
+	    inststr(origline);
 	    cs = origcs;
 	    feep();
 	    clearlist = 1;

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-08  7:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-07 15:21 Bug in completion with menucomplete and no insertion Peter Stephenson
1999-06-08  6:58 Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).