Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Quoting after completion fix
- X-seq: zsh-workers 1804
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hacking and development)
- Subject: Quoting after completion fix
- Date: Sun, 28 Jul 1996 23:40:31 +0200 (MET DST)
Here is an other attempt to fix quoting after a completion. The bug:
% echo '*'_<TAB>
% echo *_
Obviously it should be
% echo \*_
In pre3 a wrong fix was included which did
% echo foo*_<TAB>
% 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;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author