Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Completion/matching control problem
- X-seq: zsh-workers 7345
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: Completion/matching control problem
- Date: Mon, 2 Aug 1999 13:28:06 +0200 (MET DST)
- In-reply-to: Felix Rosencrantz's message of Wed, 28 Jul 1999 10:47:17 -0700 (PDT)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Felix Rosencrantz wrote:
> Here's a problem with matching control that I encountered. I've been
> meaning to send this patch in for some time. If I understood the code
> better, I think I provide a cleaner test case.
>
> mkdir bug
> cd bug
> touch Abc-Def-Ghij.txt
> touch Abc-def.ghi.jkl_mno.pqr.txt
> touch Abc_def_ghi_jkl_mno_pqr.txt
> compctl -M 'm:{a-z}={A-Z} r:|[.,_-]=*'
> ls a-a<TAB>
>
> I sometimes see either a hang or a core dump.
>
> The problem seems to occur when match_str is called with test=1 and abort_match
> is called, the globals matchparts&matchsubs end up pointing to free'd clines,
> which causes problems for code that attempts to append clines to the list.
It shouldn't call abort_match() at all when doing only testing (which
happens when it calls itself recursively while trying to match *-patterns).
> I another problem is if you type:
> ls a<TAB>
> you get:
> ls Abcdefghi
> which doesn't seem correct, but I figure someone who understands the code might
> be able to fix this one.
After trying word-strings and seeing that they didn't match it
compared line-strings even if they were empty (i.e. if it were in a
part of the matches that didn't have anything matching it on the
line). It should do that only at the end of the matches (which is
represented by a cline struct with an empty anchor).
That new place where CLF_MISS is set is needed to get the
cursor-placement right when the cline list was truncated.
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Mon Aug 2 13:00:10 1999
+++ Src/Zle/zle_tricky.c Mon Aug 2 13:21:55 1999
@@ -2542,9 +2542,12 @@
lm = NULL;
} else {
/* No matcher and different characters: l does not match w. */
+ if (test)
+ return 0;
+
abort_match();
- return (test ? 0 : -1);
+ return -1;
}
}
/* If this is a recursive call, we just return if l matched w or not. */
@@ -2907,7 +2910,7 @@
/* First try the exact strings. */
if ((!(o->flags & CLF_LINE) && o->wlen == n->wlen &&
(!o->word || !strncmp(o->word, n->word, o->wlen))) ||
- (line = ((!o->line && !n->line) ||
+ (line = ((!o->line && !n->line && !o->wlen && !n->wlen) ||
(o->llen == n->llen && o->line && n->line &&
!strncmp(o->line, n->line, o->llen))))) {
if (line) {
@@ -3434,6 +3437,7 @@
o->wlen = 0;
free_cline(o->next);
o->next = NULL;
+ o->flags |= CLF_MISS;
}
}
/* Ok, they are equal, now join the sub-lists. */
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author