From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25043 invoked from network); 2 Aug 1999 11:28:17 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 2 Aug 1999 11:28:17 -0000 Received: (qmail 5582 invoked by alias); 2 Aug 1999 11:28:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7345 Received: (qmail 5575 invoked from network); 2 Aug 1999 11:28:08 -0000 Date: Mon, 2 Aug 1999 13:28:06 +0200 (MET DST) Message-Id: <199908021128.NAA12989@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Felix Rosencrantz's message of Wed, 28 Jul 1999 10:47:17 -0700 (PDT) Subject: Re: PATCH: Completion/matching control problem 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 > > 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 > 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@informatik.hu-berlin.de