* Re: PATCH: ** in match specs
@ 2000-03-30 14:42 Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-03-30 14:42 UTC (permalink / raw)
To: zsh-workers
I wrote:
> I knew trouble would come of that...
>
> compdef foo foo
> foo() { compadd -M 'r:|.=** r:|=*' test.old.ps test.ps }
>
> And trying `foo t.p<TAB>' removed the `p'. This should fix it.
This broke things like `com/cor<TAB>' in some cases.
Anyone interested? The problem was to find the right cline struct to
stick the CLF_MISS flag (indicating missing characters) on. And then I
had totally forgotten to modify the min/max fields of the changed
cline in some cases.
Bye
Sven
diff -ru ../z.old/Src/Zle/compmatch.c Src/Zle/compmatch.c
--- ../z.old/Src/Zle/compmatch.c Thu Mar 30 13:33:02 2000
+++ Src/Zle/compmatch.c Thu Mar 30 16:37:42 2000
@@ -134,6 +134,7 @@
r->slen = 0;
r->flags = fl;
r->prefix = r->suffix = NULL;
+ r->min = r->max = 0;
return r;
}
@@ -1676,7 +1677,7 @@
* didn't. */
/**/
-static void
+static int
sub_join(Cline a, Cline b, Cline e, int anew)
{
if (!e->suffix && a->prefix) {
@@ -1705,27 +1706,22 @@
if (anew) {
join_psfx(e, a, NULL, NULL, 0);
- if (e->prefix) {
- e->min += min;
- e->max += max;
- break;
- }
+ if (e->prefix)
+ return max - min;
} else {
- join_psfx(e, a, NULL, NULL, 0);
- if (a->prefix) {
- a->min += min;
- a->max += max;
- break;
- }
+ join_psfx(a, e, NULL, NULL, 0);
+ if (a->prefix)
+ return max - min;
}
min -= n->min;
- max -= n->max;
if (n == op)
break;
n = n->next;
}
+ return max - min;
}
+ return 0;
}
/* This simplifies the cline list given as the first argument so that
@@ -1742,7 +1738,8 @@
if (!o)
return n;
else {
- Cline oo = o, nn = n, po = NULL, pn = NULL;
+ Cline oo = o, nn = n, po = NULL, pn = NULL, x;
+ int diff;
/* Walk through the lists. */
while (o && n) {
@@ -1754,7 +1751,7 @@
for (t = o; (tn = t->next) && (tn->flags & CLF_NEW); t = tn);
if (tn && cmp_anchors(tn, n, 0)) {
- sub_join(n, o, tn, 1);
+ diff = sub_join(n, o, tn, 1);
if (po)
po->next = tn;
@@ -1762,11 +1759,15 @@
oo = tn;
t->next = NULL;
free_cline(o);
+ x = o;
o = tn;
- if (po)
+ if (po && cmp_anchors(x, po, 0)) {
po->flags |= CLF_MISS;
- else
+ po->max += diff;
+ } else {
o->flags |= CLF_MISS;
+ o->max += diff;
+ }
continue;
}
}
@@ -1775,13 +1776,16 @@
for (t = n; (tn = t->next) && (tn->flags & CLF_NEW); t = tn);
if (tn && cmp_anchors(o, tn, 0)) {
- sub_join(o, n, tn, 0);
+ diff = sub_join(o, n, tn, 0);
- n = tn;
- if (po)
+ if (po && cmp_anchors(n, pn, 0)) {
po->flags |= CLF_MISS;
- else
+ po->max += diff;
+ } else {
o->flags |= CLF_MISS;
+ o->max += diff;
+ }
+ n = tn;
continue;
}
}
@@ -1809,6 +1813,7 @@
t = tn);
if (tn && cmp_anchors(tn, n, 1)) {
sub_join(n, o, tn, 1);
+
if (po)
po->next = tn;
else
@@ -1837,14 +1842,16 @@
for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
if (tn) {
- sub_join(o, n, tn, 0);
+ diff = sub_join(o, n, tn, 0);
- n = tn;
- if (po)
+ if (po && cmp_anchors(n, pn, 0)) {
po->flags |= CLF_MISS;
- else
+ po->max += diff;
+ } else {
o->flags |= CLF_MISS;
-
+ o->max += diff;
+ }
+ n = tn;
po = o;
o = o->next;
pn = n;
@@ -1855,17 +1862,21 @@
t = tn);
if (tn) {
- sub_join(n, o, tn, 1);
+ diff = sub_join(n, o, tn, 1);
if (po)
po->next = tn;
else
oo = tn;
+ x = o;
o = tn;
- if (po)
+ if (po && cmp_anchors(x, po, 0)) {
po->flags |= CLF_MISS;
- else
+ po->max += diff;
+ } else {
o->flags |= CLF_MISS;
+ o->max += diff;
+ }
continue;
} else {
if (o->flags & CLF_SUF)
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: ** in match specs
@ 2000-03-30 10:40 Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-03-30 10:40 UTC (permalink / raw)
To: zsh-workers
I knew trouble would come of that...
compdef foo foo
foo() { compadd -M 'r:|.=** r:|=*' test.old.ps test.ps }
And trying `foo t.p<TAB>' removed the `p'. This should fix it.
Bye
Sven
diff -ru ../z.old/Src/Zle/compmatch.c Src/Zle/compmatch.c
--- ../z.old/Src/Zle/compmatch.c Thu Mar 30 09:58:19 2000
+++ Src/Zle/compmatch.c Thu Mar 30 11:55:18 2000
@@ -1699,7 +1699,7 @@
*p = e->prefix;
ca = a->prefix;
- while (n != op) {
+ while (n) {
e->prefix = cp_cline(n, 0);
a->prefix = cp_cline(ca, 0);
@@ -1721,6 +1721,8 @@
min -= n->min;
max -= n->max;
+ if (n == op)
+ break;
n = n->next;
}
}
@@ -1761,7 +1763,10 @@
t->next = NULL;
free_cline(o);
o = tn;
- o->flags |= CLF_MISS;
+ if (po)
+ po->flags |= CLF_MISS;
+ else
+ o->flags |= CLF_MISS;
continue;
}
}
@@ -1773,7 +1778,10 @@
sub_join(o, n, tn, 0);
n = tn;
- o->flags |= CLF_MISS;
+ if (po)
+ po->flags |= CLF_MISS;
+ else
+ o->flags |= CLF_MISS;
continue;
}
}
@@ -1832,7 +1840,15 @@
sub_join(o, n, tn, 0);
n = tn;
- o->flags |= CLF_MISS;
+ if (po)
+ po->flags |= CLF_MISS;
+ else
+ o->flags |= CLF_MISS;
+
+ po = o;
+ o = o->next;
+ pn = n;
+ n = n->next;
continue;
} else {
for (t = o; (tn = t->next) && !cmp_anchors(n, tn, 1);
@@ -1846,7 +1862,10 @@
else
oo = tn;
o = tn;
- o->flags |= CLF_MISS;
+ if (po)
+ po->flags |= CLF_MISS;
+ else
+ o->flags |= CLF_MISS;
continue;
} else {
if (o->flags & CLF_SUF)
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-03-30 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-30 14:42 PATCH: ** in match specs Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
2000-03-30 10:40 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).