From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28257 invoked by alias); 9 Feb 2012 16:16:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30194 Received: (qmail 5268 invoked from network); 9 Feb 2012 16:16:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.213.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Ta6nnl1EqP+BMtiLlSLMNTadmUgehIjQgybdQOzXvyY=; b=YToQjy10AlRLkkOFl9OJ5znNb6v9PQMKqHQPPaq6ybtytqxMlFoqPmB07TQLdC7G6L NzMymwThB1nJMj7sLYeH4Wm0uzhLmMw15M/dMXQprjmqkJTKdQv4vUskYjuNIWN0CsTI 40tJt+IsOgdFTySzHwbBDohDV6/2fXqC6+pXI= MIME-Version: 1.0 In-Reply-To: <120209073732.ZM31309@torch.brasslantern.com> References: <120209073732.ZM31309@torch.brasslantern.com> Date: Thu, 9 Feb 2012 17:16:15 +0100 Message-ID: Subject: Re: \## -> x when completing From: Mikael Magnusson To: Bart Schaefer Cc: zsh workers Content-Type: text/plain; charset=UTF-8 On 9 February 2012 16:37, Bart Schaefer wrote: > This gets a bit stream-of-consciousness but maybe that's helpful. > > On Feb 8, 11:37pm, Mikael Magnusson wrote: > } Subject: \## -> x when completing > } > } zsh -f > } touch xenon > } autoload compinit; compinit > } setopt globcomplete > } cat \## -> cat xenon > > Hmm. This is probably happening because the completion internals use > an "x" as a place-holder in some instances. See the functions > comptils.c:comp_quote, compcore.c:tildequote, and zle_tricky.c:addx, > the latter of which has a big comment explaining what's going on. > > However, I think it's more likely compcore.c:set_comp_sep that is the > culprit. We can find out by changing the 'x' to something else in one > of addx or set_comp_sep and then trying the completion again. > > Which reveals that it's neither of those; rather compcore.c:addmatches > is playing funny with us, at line 2302: > > 2293 if (comppatmatch && *comppatmatch) { > 2294 int is = (*comppatmatch == '*'); > 2295 char *tmp = (char *) zhalloc(2 + llpl + llsl + gfl); > 2296 > 2297 if (gfl) { > 2298 strcpy(tmp, globflag); > 2299 strcat(tmp, lpre); > 2300 } else > 2301 strcpy(tmp, lpre); > 2302 tmp[llpl + gfl] = 'x'; > 2303 strcpy(tmp + llpl + gfl + is, lsuf); > 2304 > 2305 tokenize(tmp); > 2306 remnulargs(tmp); > 2307 if (haswilds(tmp)) { > 2308 if (is) > 2309 tmp[llpl + gfl] = Star; > 2310 if ((cp = patcompile(tmp, 0, NULL))) > 2311 haspattern = 1; > 2312 } > 2313 } > > The problem seems to be that remnulargs() has shortened tmp so that > the count (llpl + gfl) is no longer correct. I believe we can fix > that by moving remnulargs to after line 2309. > > Index: Src/Zle/compcore.c > =================================================================== > --- Src/Zle/compcore.c 20 Dec 2011 17:13:38 -0000 1.29 > +++ Src/Zle/compcore.c 9 Feb 2012 15:33:44 -0000 > @@ -2303,10 +2303,10 @@ > strcpy(tmp + llpl + gfl + is, lsuf); > > tokenize(tmp); > - remnulargs(tmp); > if (haswilds(tmp)) { > if (is) > tmp[llpl + gfl] = Star; > + remnulargs(tmp); > if ((cp = patcompile(tmp, 0, NULL))) > haspattern = 1; > } This fix seems to work for me, I have barely tried anything but my test case so far though :). cat \##g now works in an irclogs dir to complete both files starting with g and #g though. -- Mikael Magnusson