From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16930 invoked from network); 24 Jan 2000 15:07:37 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 24 Jan 2000 15:07:37 -0000 Received: (qmail 10316 invoked by alias); 24 Jan 2000 15:07:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9419 Received: (qmail 10308 invoked from network); 24 Jan 2000 15:07:27 -0000 To: zsh-workers@math.gatech.edu Subject: Re: playing with backreferences in list-colors References: <200001240954.KAA09754@beta.informatik.hu-berlin.de> X-Attribution: adl From: Alexandre Duret-Lutz Date: 24 Jan 2000 16:07:31 +0100 In-Reply-To: Sven Wischnowsky's message of "Mon, 24 Jan 2000 10:54:43 +0100 (MET)" Message-ID: User-Agent: Gnus/5.070096 (Pterodactyl Gnus v0.96) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii After 9408 and 9416, I have still some problems : 1) listcolor stop colorization on the first (-1,-1) backref, even if there are valid backrefs after. 2) colorization of enclosed backrefs are wrongs. Let's say O denotes color for the outer block, I the inner color, N means no color. And I am matching over a 8 letter string. ((??)??)* -> OOOONNNN (?(??)?)* -> 0IIIONNN (??(??))* -> OOIIONNN I expect the patch below to fix these two points. Sorting the end positions was needed to fix this second point (at least I didn't find any better way to do that). The test `endpos[curisbeg] < begpos[curisbeg]' of the patch is there to handle cases like : ~ % [[ fbar = (#b)f((o)#)bar ]] ~ % echo $mbegin / $mend 2 -1 / 1 -1 where the outer backref matched the empty string (empty strings don't need to be colored, I think). Index: Src/Zle/complist.c --- Src/Zle/complist.c Mon, 24 Jan 2000 13:43:41 +0100 Alexandre +++ Src/Zle/complist.c Mon, 24 Jan 2000 15:25:07 +0100 Alexandre @@ -391,7 +391,8 @@ static int nrefs; static int begpos[MAX_POS], curisbeg; -static int endpos[MAX_POS], curisend; +static int endpos[MAX_POS]; +static int sendpos[MAX_POS], curissend; /* sorted end positions */ static char **patcols, *curiscols[MAX_POS]; static int curiscol; @@ -450,29 +451,45 @@ curiscols[curiscol = 0] = *patcols++; - curisbeg = curisend = 0; + curisbeg = curissend = 0; - for (i = nrefs; i < MAX_POS; i++) - begpos[i] = endpos[i] = -1; + for (i = 0; i < nrefs; i++) + sendpos[i] = 0xfffffff; + for (; i < MAX_POS; i++) + begpos[i] = endpos[i] = sendpos[i] = 0xfffffff; } static void doiscol(Listcols c, int pos) { - if (endpos[curisend] >= 0 && pos > endpos[curisend]) { - curisend++; + int fi; + + while (pos > sendpos[curissend]) { + curissend++; if (curiscol) { zcputs(c, NULL, COL_NO); zlrputs(c, curiscols[--curiscol]); } } - if (pos == begpos[curisbeg] && *patcols) { - curisbeg++; - - zcputs(c, NULL, COL_NO); - zlrputs(c, *patcols); - - curiscols[++curiscol] = *patcols++; + while (((fi = (endpos[curisbeg] < begpos[curisbeg] || + begpos[curisbeg] == -1)) || + pos == begpos[curisbeg]) && *patcols) { + if (!fi) { + int i, j, e = endpos[curisbeg]; + + /* insert e in sendpos */ + for (i = curissend; sendpos[i] <= e; ++i) + ; + for (j = i + 1; j < MAX_POS; ++j) + sendpos[j] = sendpos[j-1]; + sendpos[i] = e; + + zcputs(c, NULL, COL_NO); + zlrputs(c, *patcols); + curiscols[++curiscol] = *patcols; + } + ++patcols; + ++curisbeg; } } -- Alexandre Duret-Lutz