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

Re: compctl -g not working



On Oct 8,  2:31pm, Sven Wischnowsky wrote:
} Subject: Re: compctl -g not working
}
} [ moved to -workers ]
} 
} Bart Schaefer wrote:
} 
} > Should we fix `compctl -g' so that it behaves like "ordinary" globbing?
} > (I have a suggested implementation that I won't go into here.)
} 
} Would be fine with me. (I really don't care about compctl anymore ;-)

This affects compcore as well, though, and everywhere else that zsh uses
tokenize().  That doesn't affect compsys much because we force SH_GLOB
off via $_comp_options, but it could affect other completion widgets.

Here's a patch for consideration.  It renames tokenize() as shtokenize(),
and then makes tokenize() a wrapper for shtokenize() that always turns
off SH_GLOB.  Then shtokenize() is called selectively in the places where
(as best I can tell) we really want SH_GLOB behavior to apply.

Obviously this is a little inefficient, since tokenize() is used a lot
more often than shtokenize().  There are several ways to improve this,
but this way lets us test the new behavior with a minimum of rewriting.

Of course, you shouldn't see any change in behavior unless you were using
SH_GLOB in the first place ...

Index: Src/exec.c
--- zsh-forge/current/Src/exec.c	Thu Oct 11 11:11:07 2001
+++ zsh-4.0/Src/exec.c	Sat Oct 13 12:58:11 2001
@@ -2794,7 +2794,7 @@
 
 	while (*words) {
 	    if (isset(GLOBSUBST))
-		tokenize(*words);
+		shtokenize(*words);
 	    addlinknode(ret, *words++);
 	}
     }
Index: Src/glob.c
--- zsh-forge/current/Src/glob.c	Mon Oct  8 03:04:01 2001
+++ zsh-4.0/Src/glob.c	Sat Oct 13 12:57:27 2001
@@ -2329,6 +2329,16 @@
 mod_export void
 tokenize(char *s)
 {
+    char shglob = opts[SHGLOB];
+    opts[SHGLOB] = 0;
+    shtokenize(s);
+    opts[SHGLOB] = shglob;
+}
+
+/**/
+mod_export void
+shtokenize(char *s)
+{
     char *t;
     int bslash = 0;
 
Index: Src/subst.c
--- zsh-forge/current/Src/subst.c	Mon Oct  8 03:04:01 2001
+++ zsh-4.0/Src/subst.c	Sat Oct 13 12:58:13 2001
@@ -190,7 +190,7 @@
 		continue;
 	    }
 	    if (!qt && ssub && isset(GLOBSUBST))
-		tokenize(s);
+		shtokenize(s);
 	    l1 = str2 - str3;
 	    l2 = strlen(s);
 	    if (nonempty(pl)) {
@@ -441,14 +441,14 @@
     if (!pl && (!s || !*s)) {
 	*d = dest = (copied ? src : dupstring(src));
 	if (glbsub)
-	    tokenize(dest);
+	    shtokenize(dest);
     } else {
 	*d = dest = hcalloc(pl + l + (s ? strlen(s) : 0) + 1);
 	strncpy(dest, pb, pl);
 	dest += pl;
 	strcpy(dest, src);
 	if (glbsub)
-	    tokenize(dest);
+	    shtokenize(dest);
 	dest += l;
 	if (s)
 	    strcpy(dest, s);
@@ -1509,7 +1509,7 @@
 		if (!quoteerr) {
 		    errflag = oef;
 		    if (haserr)
-			tokenize(s);
+			shtokenize(s);
 		} else if (haserr || errflag) {
 		    zerr("parse error in ${...%c...} substitution",
 			 NULL, s[-1]);
@@ -1955,7 +1955,7 @@
 		else {
 		    y = dupstring(x);
 		    if (globsubst)
-			tokenize(y);
+			shtokenize(y);
 		}
 		insertlinknode(l, n, (void *) y), incnode(n);
 	    }

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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