summaryrefslogtreecommitdiff
path: root/Src/Zle/complete.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-03-21 18:49:04 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-03-21 18:49:04 +0000
commit24699f961dc3757ddf692413028a4c0f03abe0fd (patch)
treeab3dcc66fd6656b5e43c7e925b06ecc65adeb007 /Src/Zle/complete.c
parentf1d0ca4d80b53aaba81909ba220de64eb77408a4 (diff)
downloadzsh-24699f961dc3757ddf692413028a4c0f03abe0fd.tar.gz
zsh-24699f961dc3757ddf692413028a4c0f03abe0fd.zip
21045: fix some uses of Meta characters in completion
Diffstat (limited to 'Src/Zle/complete.c')
-rw-r--r--Src/Zle/complete.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 717be8896..d1f3366e7 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -821,18 +821,32 @@ do_comp_vars(int test, int na, char *sa, int nb, char *sb, int mod)
add = -1;
} else {
p = compprefix + 1;
+ if (*p == Meta)
+ p++;
add = 1;
}
- for (; l; l--, p += add) {
+ for (;;) {
sav = *p;
*p = '\0';
test = pattry(pp, compprefix);
*p = sav;
if (test && !--na)
break;
+ if (add > 0) {
+ if (p == compprefix + l)
+ return 0;
+ if (*p == Meta)
+ p += 2;
+ else
+ p++;
+ } else {
+ if (p == compprefix)
+ return 0;
+ p--;
+ if (p > compprefix && p[-1] == Meta)
+ p--;
+ }
}
- if (!l)
- return 0;
if (mod)
ignore_prefix(p - compprefix);
} else {
@@ -847,14 +861,30 @@ do_comp_vars(int test, int na, char *sa, int nb, char *sb, int mod)
add = 1;
} else {
p = compsuffix + l - 1;
+ if (p > compsuffix && p[-1] == Meta)
+ p--;
add = -1;
}
- for (; l; l--, p += add)
+ for (;;) {
if (pattry(pp, p) && !--na)
break;
- if (!l)
- return 0;
+ if (add > 0) {
+ if (p == compsuffix + l)
+ return 0;
+ if (*p == Meta)
+ p += 2;
+ else
+ p++;
+ } else {
+ if (p == compsuffix)
+ return 0;
+ p--;
+ if (p > compsuffix && p[-1] == Meta)
+ p--;
+ }
+ }
+
if (mod)
ignore_suffix(ol - (p - compsuffix));
}