From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24468 invoked by alias); 6 Jun 2014 02:21:02 -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: 32723 Received: (qmail 1087 invoked from network); 6 Jun 2014 02:20:58 -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.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140605192047.ZM16957@torch.brasslantern.com> Date: Thu, 05 Jun 2014 19:20:47 -0700 In-reply-to: <25969.1402010685@thecus.kiddle.eu> Comments: In reply to Oliver Kiddle "Re: [PATCH] Re: (Y) modifier: up to N matches?" (Jun 6, 1:24am) References: <20140602182346.GB1858@tarsus.local2> <140602204603.ZM26905@torch.brasslantern.com> <20140604020804.GA2032@tarsus.local2> <140603234229.ZM29030@torch.brasslantern.com> <20140604230835.GD1970@tarsus.local2> <25969.1402010685@thecus.kiddle.eu> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [PATCH] Re: (Y) modifier: up to N matches? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jun 6, 1:24am, Oliver Kiddle wrote: } } Are the sort flags actually affecting the order in which directories are } visited or only the order in which matches are output? Entirely independent of (Y) ... the sort flags only apply to the order of outputs. The actual scan is always in breadth-first order no matter what flags have been passed in. Looking at this leads me to believe that the (Y) patch may have been missing some curly braces. Either that or the indendation is wrong. There's one extra hunk at the top here to skip initializing a data structure if it's never going to be used. diff --git a/Src/glob.c b/Src/glob.c index c6cb3d2..15a5f70 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -462,18 +462,19 @@ scanner(Complist q, int shortcircuit) int errssofar = errsfound; struct dirsav ds; - init_dirsav(&ds); if (!q) return; + init_dirsav(&ds); if ((closure = q->closure)) { /* (foo/)# - match zero or more dirs */ if (q->closure == 2) /* (foo/)## - match one or more dirs */ q->closure = 1; - else + else { scanner(q->next, shortcircuit); if (shortcircuit && shortcircuit == matchct) return; + } } p = q->pat; /* Now the actual matching for the current path section. */ @@ -518,10 +519,11 @@ scanner(Complist q, int shortcircuit) } if (add) { addpath(str, l); - if (!closure || !statfullpath("", NULL, 1)) + if (!closure || !statfullpath("", NULL, 1)) { scanner((q->closure) ? q : q->next, shortcircuit); if (shortcircuit && shortcircuit == matchct) return; + } pathbuf[pathpos = oppos] = '\0'; } } @@ -618,11 +620,12 @@ scanner(Complist q, int shortcircuit) memcpy(subdirs + subdirlen, (char *)&errsfound, sizeof(int)); subdirlen += sizeof(int); - } else + } else { /* if the last filename component, just add it */ insert(fn, 1); if (shortcircuit && shortcircuit == matchct) return; + } } } closedir(lock);