From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: ** in match specs
Date: Thu, 30 Mar 2000 16:42:16 +0200 (MET DST) [thread overview]
Message-ID: <200003301442.QAA02892@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Thu, 30 Mar 2000 12:40:25 +0200 (MET DST)
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
next reply other threads:[~2000-03-30 14:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-30 14:42 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-03-30 10:40 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200003301442.QAA02892@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).