Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: help with matcher-list style



On Thu, 29 Jan 2009 00:52:48 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jan 28,  9:43pm, Greg Klanderman wrote:
> }
> } I'm currently using this matcher-list setting:
> } 
> } zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' '+ l:|=* r:|=*'
> 
> Interesting.  When I attempt to use that with the latest CVS (1.4529)
> I get errors:
> 
> 39: ../../../zsh-4.0/Src/Zle/compmatch.c:1181: bad matcher pattern type
> 39: ../../../zsh-4.0/Src/Zle/compmatch.c:1181: bad matcher pattern type
> (repeats a dozen times or so)
> 
> I do NOT get that error with 4.2.0 (the only older zsh I have handy
> at the moment).  It's got something to do with m:{a-zA-Z}={A-Za-z}
> appearing all by itself in that second element; if it appears along
> with an r: pattern (for example), there is no error, and if I leave
> it out, there is no error.

(Move to zsh-workers.)

I think this is it, but this is near the very heart of the fog, and a
second pair of eyes here would be very useful.  "tmpgenpat" and "wp" now
have comparable relationships to "curgenpat" and "wordcp", respectively, so
the code certainly looks better.

Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.63
diff -u -r1.63 compmatch.c
--- Src/Zle/compmatch.c	18 Nov 2008 10:07:31 -0000	1.63
+++ Src/Zle/compmatch.c	29 Jan 2009 10:59:41 -0000
@@ -1818,10 +1818,12 @@
 
 	if (sfx) {
 	    wp = wordcp - 1;
-	    curgenpat--;
-	} else
+	    tmpgenpat = curgenpat - 1;
+	} else {
+	    tmpgenpat = curgenpat;
 	    wp = wordcp;
-	if (pattern_match1(curgenpat, *wp, &wmtp))
+	}
+	if (pattern_match1(tmpgenpat, *wp, &wmtp))
 	{
 	    convchar_t lchr;
 	    /*
@@ -1831,8 +1833,8 @@
 	     * else if it's generic, keep the word character,
 	     * since we have no choice.
 	     */
-	    if (curgenpat->tp == CPAT_CHAR)
-		lchr = curgenpat->u.chr;
+	    if (tmpgenpat->tp == CPAT_CHAR)
+		lchr = tmpgenpat->u.chr;
 	    else
 		lchr = *wp;
 
@@ -1845,9 +1847,10 @@
 	    wlen--;
 	    rl++;
 
-	    if (sfx)
+	    if (sfx) {
 		wordcp = wp;
-	    else {
+		curgenpat = tmpgenpat;
+	    } else {
 		if (llen)
 		    curgenpat++;
 		wordcp++;


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



Messages sorted by: Reverse Date, Date, Thread, Author