mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-29 19:00:57 +02:00
25912: fix another metafication bug in completion
and remove lies about matchers
This commit is contained in:
parent
96a1f68875
commit
7f470ebcb0
3 changed files with 51 additions and 29 deletions
|
@ -1,5 +1,9 @@
|
||||||
2008-10-18 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2008-10-18 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
|
* 25912: Doc/Zsh/compwid.yo, Src/Zle/computil.c: fix yet another
|
||||||
|
Meta bug in completion with matchers in compfiles; remove 25893
|
||||||
|
because that wasn't it at all.
|
||||||
|
|
||||||
* 25911: Test/D07multibyte.ztst: see if we can work around file
|
* 25911: Test/D07multibyte.ztst: see if we can work around file
|
||||||
system idiosyncracies.
|
system idiosyncracies.
|
||||||
|
|
||||||
|
|
|
@ -942,16 +942,14 @@ line match the corresponding upper case character in the trial
|
||||||
completion you can use `tt(m:{[:lower:]}={[:upper:]})'. Although the
|
completion you can use `tt(m:{[:lower:]}={[:upper:]})'. Although the
|
||||||
matching system does not yet handle multibyte characters, this is likely
|
matching system does not yet handle multibyte characters, this is likely
|
||||||
to be a future extension, at which point this syntax will handle
|
to be a future extension, at which point this syntax will handle
|
||||||
arbitrary alphabets; until then it is safer to use the older syntax
|
arbitrary alphabets; hence this form, rather than the use of explicit
|
||||||
that only handles ASCII characters, `tt(m:{a-z}={A-Z}) as this does
|
ranges, is the recommended form. In other cases
|
||||||
not have side effects in the case of multibyte characters.
|
`tt([:)var(name)tt(:])' forms are allowed. If the two forms on the left
|
||||||
|
and right are the same, the characters must match exactly. In remaining
|
||||||
In other cases `tt([:)var(name)tt(:])' forms are allowed. If the two forms
|
cases, the corresponding tests are applied to both characters, but they
|
||||||
on the left and right are the same, the characters must match exactly. In
|
are not otherwise constrained; any matching character in one set goes
|
||||||
remaining cases, the corresponding tests are applied to both characters,
|
with any matching character in the other set: this is equivalent to the
|
||||||
but they are not otherwise constrained; any matching character in one set
|
behaviour of ordinary character classes.
|
||||||
goes with any matching character in the other set: this is equivalent to
|
|
||||||
the behaviour of ordinary character classes.
|
|
||||||
|
|
||||||
The pattern var(tpat) may also be one or two stars, `tt(*)' or
|
The pattern var(tpat) may also be one or two stars, `tt(*)' or
|
||||||
`tt(**)'. This means that the pattern on the command line can match
|
`tt(**)'. This means that the pattern on the command line can match
|
||||||
|
|
|
@ -4024,7 +4024,7 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
* management is difficult.
|
* management is difficult.
|
||||||
*/
|
*/
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (mp = ms; *add; add++, mp++) {
|
for (mp = ms; *add; ) {
|
||||||
if (!(m = *mp)) {
|
if (!(m = *mp)) {
|
||||||
/*
|
/*
|
||||||
* No matcher, so just match the character
|
* No matcher, so just match the character
|
||||||
|
@ -4034,13 +4034,13 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
* metacharacter?
|
* metacharacter?
|
||||||
*/
|
*/
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (imeta(*add)) {
|
if (*add == Meta) {
|
||||||
*p++ = Meta;
|
*p++ = Meta;
|
||||||
*p++ = *add ^ 32;
|
*p++ = add[1];
|
||||||
} else
|
} else
|
||||||
*p++ = *add;
|
*p++ = *add;
|
||||||
} else
|
} else
|
||||||
len += imeta(*add) ? 2 : 1;
|
len += (*add == Meta) ? 2 : 1;
|
||||||
} else if (m->flags & CMF_RIGHT) {
|
} else if (m->flags & CMF_RIGHT) {
|
||||||
/*
|
/*
|
||||||
* Right-anchored: match anything followed
|
* Right-anchored: match anything followed
|
||||||
|
@ -4049,15 +4049,16 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*p++ = '*';
|
*p++ = '*';
|
||||||
/* TODO: quote again? */
|
/* TODO: quote again? */
|
||||||
if (imeta(*add)) {
|
if (*add == Meta) {
|
||||||
*p++ = Meta;
|
*p++ = Meta;
|
||||||
*p++ = *add ^ 32;
|
*p++ = add[1];
|
||||||
} else
|
} else
|
||||||
*p++ = *add;
|
*p++ = *add;
|
||||||
} else
|
} else
|
||||||
len += imeta(*add) ? 3 : 2;
|
len += (*add == Meta) ? 3 : 2;
|
||||||
} else {
|
} else {
|
||||||
/* The usual set of matcher possibilities. */
|
/* The usual set of matcher possibilities. */
|
||||||
|
int chr = (*add == Meta) ? add[1] ^ 32 : *add;
|
||||||
int ind;
|
int ind;
|
||||||
if (m->line->tp == CPAT_EQUIV &&
|
if (m->line->tp == CPAT_EQUIV &&
|
||||||
m->word->tp == CPAT_EQUIV) {
|
m->word->tp == CPAT_EQUIV) {
|
||||||
|
@ -4072,21 +4073,21 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
*/
|
*/
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*p++ = '[';
|
*p++ = '[';
|
||||||
if (imeta(*add)) {
|
if (*add == Meta) {
|
||||||
*p++ = Meta;
|
*p++ = Meta;
|
||||||
*p++ = *add ^ 32;
|
*p++ = add[1];
|
||||||
} else
|
} else
|
||||||
*p++ = *add;
|
*p++ = *add;
|
||||||
} else
|
} else
|
||||||
len += imeta(*add) ? 3 : 2;
|
len += (*add == Meta) ? 3 : 2;
|
||||||
if (PATMATCHRANGE(m->line->u.str, CONVCAST(*add),
|
if (PATMATCHRANGE(m->line->u.str, CONVCAST(chr),
|
||||||
&ind, &mt)) {
|
&ind, &mt)) {
|
||||||
/*
|
/*
|
||||||
* Find the equivalent match for ind in the
|
* Find the equivalent match for ind in the
|
||||||
* word pattern.
|
* word pattern.
|
||||||
*/
|
*/
|
||||||
if ((ind = pattern_match_equivalence
|
if ((ind = pattern_match_equivalence
|
||||||
(m->word, ind, mt, CONVCAST(*add))) != -1) {
|
(m->word, ind, mt, CONVCAST(chr))) != -1) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (imeta(ind)) {
|
if (imeta(ind)) {
|
||||||
*p++ = Meta;
|
*p++ = Meta;
|
||||||
|
@ -4158,7 +4159,7 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
* if *add is ] and ] is also the first
|
* if *add is ] and ] is also the first
|
||||||
* character in the range.
|
* character in the range.
|
||||||
*/
|
*/
|
||||||
addadd = !pattern_match1(m->word, CONVCAST(*add), &mt);
|
addadd = !pattern_match1(m->word, CONVCAST(chr), &mt);
|
||||||
if (addadd && *add == ']') {
|
if (addadd && *add == ']') {
|
||||||
if (ret)
|
if (ret)
|
||||||
*p++ = *add;
|
*p++ = *add;
|
||||||
|
@ -4218,6 +4219,13 @@ cfp_matcher_range(Cmatcher *ms, char *add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (*add == Meta) {
|
||||||
|
add += 2;
|
||||||
|
mp += 2;
|
||||||
|
} else {
|
||||||
|
add++;
|
||||||
|
mp++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
@ -4236,19 +4244,19 @@ cfp_matcher_pats(char *matcher, char *add)
|
||||||
|
|
||||||
if (m && m != pcm_err) {
|
if (m && m != pcm_err) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int al = strlen(add), tl;
|
int al = strlen(add), zl = ztrlen(add), tl, cl;
|
||||||
VARARR(Cmatcher, ms, al);
|
VARARR(Cmatcher, ms, zl);
|
||||||
Cmatcher *mp;
|
Cmatcher *mp;
|
||||||
Cpattern stopp;
|
Cpattern stopp;
|
||||||
int stopl = 0;
|
int stopl = 0;
|
||||||
|
|
||||||
memset(ms, 0, al * sizeof(Cmatcher));
|
memset(ms, 0, zl * sizeof(Cmatcher));
|
||||||
|
|
||||||
for (; m && *add; m = m->next) {
|
for (; m && *add; m = m->next) {
|
||||||
stopp = NULL;
|
stopp = NULL;
|
||||||
if (!(m->flags & (CMF_LEFT|CMF_RIGHT))) {
|
if (!(m->flags & (CMF_LEFT|CMF_RIGHT))) {
|
||||||
if (m->llen == 1 && m->wlen == 1) {
|
if (m->llen == 1 && m->wlen == 1) {
|
||||||
for (tmp = add, tl = al, mp = ms; tl; tl--, tmp++, mp++) {
|
for (tmp = add, tl = al, mp = ms; tl; ) {
|
||||||
if (pattern_match(m->line, tmp, NULL, NULL)) {
|
if (pattern_match(m->line, tmp, NULL, NULL)) {
|
||||||
if (*mp) {
|
if (*mp) {
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
@ -4257,6 +4265,10 @@ cfp_matcher_pats(char *matcher, char *add)
|
||||||
} else
|
} else
|
||||||
*mp = m;
|
*mp = m;
|
||||||
}
|
}
|
||||||
|
cl = (*tmp == Meta) ? 2 : 1;
|
||||||
|
tl -= cl;
|
||||||
|
tmp += cl;
|
||||||
|
mp += cl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stopp = m->line;
|
stopp = m->line;
|
||||||
|
@ -4264,7 +4276,7 @@ cfp_matcher_pats(char *matcher, char *add)
|
||||||
}
|
}
|
||||||
} else if (m->flags & CMF_RIGHT) {
|
} else if (m->flags & CMF_RIGHT) {
|
||||||
if (m->wlen < 0 && !m->llen && m->ralen == 1) {
|
if (m->wlen < 0 && !m->llen && m->ralen == 1) {
|
||||||
for (tmp = add, tl = al, mp = ms; tl; tl--, tmp++, mp++) {
|
for (tmp = add, tl = al, mp = ms; tl; ) {
|
||||||
if (pattern_match(m->right, tmp, NULL, NULL)) {
|
if (pattern_match(m->right, tmp, NULL, NULL)) {
|
||||||
if (*mp || (tmp == add && *tmp == '.')) {
|
if (*mp || (tmp == add && *tmp == '.')) {
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
@ -4273,6 +4285,10 @@ cfp_matcher_pats(char *matcher, char *add)
|
||||||
} else
|
} else
|
||||||
*mp = m;
|
*mp = m;
|
||||||
}
|
}
|
||||||
|
cl = (*tmp == Meta) ? 2 : 1;
|
||||||
|
tl -= cl;
|
||||||
|
tmp += cl;
|
||||||
|
mp += cl;
|
||||||
}
|
}
|
||||||
} else if (m->llen) {
|
} else if (m->llen) {
|
||||||
stopp = m->line;
|
stopp = m->line;
|
||||||
|
@ -4289,12 +4305,16 @@ cfp_matcher_pats(char *matcher, char *add)
|
||||||
stopl = m->lalen;
|
stopl = m->lalen;
|
||||||
}
|
}
|
||||||
if (stopp)
|
if (stopp)
|
||||||
for (tmp = add, tl = al; tl >= stopl; tl--, tmp++)
|
for (tmp = add, tl = al; tl >= stopl; ) {
|
||||||
if (pattern_match(stopp, tmp, NULL, NULL)) {
|
if (pattern_match(stopp, tmp, NULL, NULL)) {
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
al = tmp - add;
|
al = tmp - add;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
cl = (*tmp == Meta) ? 2 : 1;
|
||||||
|
tl -= cl;
|
||||||
|
tmp += cl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (*add)
|
if (*add)
|
||||||
return cfp_matcher_range(ms, add);
|
return cfp_matcher_range(ms, add);
|
||||||
|
|
Loading…
Reference in a new issue