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

Re: Incorrect sorting of Polish characters



On Tue, 19 Jul 2016 22:05:08 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jul 18, 11:17am, Peter Stephenson wrote:
> }
> } Adding an umetafied entry to the glob match that only gets used for
> } sorting seems to do the trick.  I think an additional single pass
> } through the array of matches isn't a big deal.
> 
> Hm.  On a glob of 16794 files it's about 4% slower over 10 trials with
> the extra pass over the array of matches.  I don't suppose there's some
> way to store the original file name at the time metafication is applied
> rather than metafying and then unmetafying again?

It already works like that, and it only copies and unmetafies if there's
a Meta character.

It might be possible to squeeze this code somewhere else at the expense
of clarity and likelihood of bugs.  There are about four places where
the name is set which could be turned into a function.

Daniel pointed out strchr() would be neater.

pws

diff --git a/Src/glob.c b/Src/glob.c
index 146b4db..850405f 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1922,13 +1922,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 	 */
 	for (gmptr = matchbuf; gmptr < matchptr; gmptr++)
 	{
-	    char *nptr;
-	    for (nptr = gmptr->name; *nptr; nptr++)
-	    {
-		if (*nptr == Meta)
-		    break;
-	    }
-	    if (*nptr == Meta)
+	    if (strchr(gmptr->name, Meta))
 	    {
 		int dummy;
 		gmptr->uname = dupstring(gmptr->name);



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