From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14138 invoked from network); 14 Oct 2001 01:45:15 -0000 Received: from unknown (HELO sunsite.dk) (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Oct 2001 01:45:15 -0000 Received: (qmail 10406 invoked by alias); 14 Oct 2001 01:45:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16032 Received: (qmail 10382 invoked from network); 14 Oct 2001 01:45:07 -0000 From: Bart Schaefer Message-Id: <1011014014504.ZM4574@candle.brasslantern.com> Date: Sun, 14 Oct 2001 01:45:04 +0000 In-Reply-To: <15297.40098.68834.268916@gargle.gargle.HOWL> Comments: In reply to Sven Wischnowsky "Re: compctl -g not working" (Oct 8, 2:31pm) References: <20011002225307.A13954@astaroth.sweth.net> <87adz976ru.fsf@ceramic.fifi.org> <20011002231841.B14325@astaroth.sweth.net> <1011003040449.ZM25370@candle.brasslantern.com> <20011003001256.B14675@astaroth.sweth.net> <1011003060441.ZM25764@candle.brasslantern.com> <20011003021524.A15356@astaroth.sweth.net> <1011003162422.ZM29481@candle.brasslantern.com> <20011003142330.A16765@astaroth.sweth.net> <1011004042305.ZM30162@candle.brasslantern.com> <20011004004307.C18930@astaroth.sweth.net> <1011005161336.ZM32521@candle.brasslantern.com> <15297.40098.68834.268916@gargle.gargle.HOWL> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: compctl -g not working MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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