zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Re: (Y) modifier: up to N matches?
Date: Thu, 05 Jun 2014 19:20:47 -0700	[thread overview]
Message-ID: <140605192047.ZM16957@torch.brasslantern.com> (raw)
In-Reply-To: <25969.1402010685@thecus.kiddle.eu>

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);


  reply	other threads:[~2014-06-06  2:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-02 18:23 Daniel Shahaf
2014-06-03  3:46 ` Bart Schaefer
2014-06-04  2:08   ` [PATCH] " Daniel Shahaf
2014-06-04  6:01     ` Mikael Magnusson
2014-06-04  6:54       ` Bart Schaefer
2014-06-04  6:42     ` Bart Schaefer
2014-06-04  9:25       ` Peter Stephenson
2014-06-04 23:08       ` Daniel Shahaf
2014-06-04 23:16         ` Bart Schaefer
2014-06-05  4:45           ` Bart Schaefer
2014-06-05 23:24           ` Oliver Kiddle
2014-06-06  2:20             ` Bart Schaefer [this message]
2014-06-06  2:40               ` Daniel Shahaf
2014-06-06  2:45             ` Daniel Shahaf
2014-06-06  4:24               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=140605192047.ZM16957@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).