From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id IAA01549 for ; Mon, 29 Jul 1996 08:05:22 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id RAA04810; Sun, 28 Jul 1996 17:47:37 -0400 (EDT) Resent-Date: Sun, 28 Jul 1996 17:47:37 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199607282140.XAA02973@hzoli.ppp.cs.elte.hu> Subject: Quoting after completion fix To: zsh-workers@math.gatech.edu (Zsh hacking and development) Date: Sun, 28 Jul 1996 23:40:31 +0200 (MET DST) X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"j4_Uf1.0.0B1.u_z-n"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1804 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Here is an other attempt to fix quoting after a completion. The bug: % echo '*'_ % echo *_ Obviously it should be % echo \*_ In pre3 a wrong fix was included which did % echo foo*_ % echo foo\*_ The patch below is an other attempt. Zoltan --- zle_tricky.c 1996/07/27 20:24:36 2.67 +++ zle_tricky.c 1996/07/28 21:02:57 @@ -715,11 +715,11 @@ *p = ztokens[*p - Pound]; else if (p[1] == Inbrace) p++, skipparens(Inbrace, Outbrace, &p); - docompletion(s, lst, lincmd); + docompletion(s, lst, lincmd, 1); } } else /* Just do completion. */ - docompletion(s, lst, lincmd); + docompletion(s, lst, lincmd, 0); zsfree(s); } /* Reset the lexer state, pop the heap. */ @@ -1175,7 +1175,7 @@ /* If expansion didn't change the word, try completion if * * expandorcomplete was called, otherwise, just beep. */ if (lst == COMP_EXPAND_COMPLETE) - docompletion(s, COMP_COMPLETE, explincmd); + docompletion(s, COMP_COMPLETE, explincmd, 0); else feep(); goto end; @@ -2105,7 +2105,7 @@ /**/ void -docompletion(char *s, int lst, int incmd) +docompletion(char *s, int lst, int incmd, int untokenized) { static int delit, compadd; @@ -2113,7 +2113,7 @@ pushheap(); /* Make sure we have the completion list and compctl. */ - if(makecomplist(s, incmd, &delit, &compadd)) { + if(makecomplist(s, incmd, &delit, &compadd, untokenized)) { /* Error condition: feeeeeeeeeeeeep(). */ feep(); goto compend; @@ -2179,7 +2179,7 @@ /**/ int -makecomplist(char *s, int incmd, int *delit, int *compadd) +makecomplist(char *s, int incmd, int *delit, int *compadd, int untokenized) { Compctl cc = NULL; int oloffs = offs, owe = we, owb = wb, ocs = cs, isf = 1; @@ -2222,11 +2222,9 @@ * beginning of the word. */ wb += *compadd; s += *compadd; - if ((offs -= *compadd) < 0) { + if ((offs -= *compadd) < 0) /* It's bigger than our word prefix, so we can't help here... */ - feep(); return 1; - } /* Insert the prefix (compctl -P), if any. */ if (cc->prefix) { @@ -2952,8 +2950,6 @@ validlist = 1; if(nmatches && !errflag) return 0; - /* No matches: restore the command line. */ - strcpy((char *)line, (char *)ol); if ((isf || cc->xor) && !parampre) { /* We found no matches, but there is a xor'ed completion: * @@ -2964,6 +2960,7 @@ wb = owb; we = owe; cs = ocs; + strcpy((char *)line, (char *)ol); offs = oloffs; s = dupstring(os); free(amatches); @@ -2981,6 +2978,10 @@ goto xorrec; } + /* No matches and xor'ed completion: restore the command line if * + * it was alredy quoted, which is the case when s is untokenized. */ + if (untokenized) + strcpy((char *)line, (char *)ol); return 1; }