* append mark qualifier disturbs sort qualifier?
@ 2014-09-24 9:24 Han Pingtian
2014-09-24 9:49 ` Peter Stephenson
2014-09-24 18:27 ` Peter Stephenson
0 siblings, 2 replies; 5+ messages in thread
From: Han Pingtian @ 2014-09-24 9:24 UTC (permalink / raw)
To: zsh-user
Hi,
I noticed this result:
% zsh -f
localhost% print -l **/*(T)
2/
2/3/
2/3/4/
2/3/4/5.txt
2/3/4/6.txt
localhost% print -l **/*(odon)
2/3/4/5.txt
2/3/4/6.txt
2/3/4
2/3
2
localhost% print -l **/*(odT)
2/3/4/5.txt
2/3/4/6.txt
2/3/4/
2/3/
2/
localhost% print -l **/*(odonT)
2/3/4/
2/3/4/5.txt
2/3/4/6.txt
2/
2/3/
Here, looks like "(T)" disturbs the sorting of "(odon)"?
Thanks in advance!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: append mark qualifier disturbs sort qualifier?
2014-09-24 9:24 append mark qualifier disturbs sort qualifier? Han Pingtian
@ 2014-09-24 9:49 ` Peter Stephenson
2014-09-24 16:30 ` Bart Schaefer
2014-09-24 18:27 ` Peter Stephenson
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2014-09-24 9:49 UTC (permalink / raw)
To: zsh-user
On Wed, 24 Sep 2014 17:24:04 +0800
Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> localhost% print -l **/*(odonT)
> 2/3/4/
> 2/3/4/5.txt
> 2/3/4/6.txt
> 2/
> 2/3/
>
> Here, looks like "(T)" disturbs the sorting of "(odon)"?
I've reproduced this but haven't looked in detail yet.
It looks vaguely like the extra / is confusing it into thinking 2/3/4/
is an empty file in the directory 2/3/4.
However, that doesn't explain why 2/ comes before 2/3/.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: append mark qualifier disturbs sort qualifier?
2014-09-24 9:49 ` Peter Stephenson
@ 2014-09-24 16:30 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2014-09-24 16:30 UTC (permalink / raw)
To: zsh-user
On Sep 24, 10:49am, Peter Stephenson wrote:
}
} On Wed, 24 Sep 2014 17:24:04 +0800
} Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
} > localhost% print -l **/*(odonT)
} > 2/3/4/
} > 2/3/4/5.txt
} > 2/3/4/6.txt
} > 2/
} > 2/3/
} >
} > Here, looks like "(T)" disturbs the sorting of "(odon)"?
}
} I've reproduced this but haven't looked in detail yet.
}
} It looks vaguely like the extra / is confusing it into thinking 2/3/4/
} is an empty file in the directory 2/3/4.
Not an empty file, but a file named (empty string).
} However, that doesn't explain why 2/ comes before 2/3/.
Empty string sorts before 3 the same as empty string sorts before 5 and
6. This is all the same side-effect.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: append mark qualifier disturbs sort qualifier?
2014-09-24 9:24 append mark qualifier disturbs sort qualifier? Han Pingtian
2014-09-24 9:49 ` Peter Stephenson
@ 2014-09-24 18:27 ` Peter Stephenson
2014-09-25 2:32 ` Han Pingtian
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2014-09-24 18:27 UTC (permalink / raw)
To: zsh-user
On Wed, 24 Sep 2014 17:24:04 +0800
Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> localhost% print -l **/*(odonT)
> 2/3/4/
> 2/3/4/5.txt
> 2/3/4/6.txt
> 2/
> 2/3/
>
> Here, looks like "(T)" disturbs the sorting of "(odon)"?
Aha.
diff --git a/Src/glob.c b/Src/glob.c
index c24bfec..ca7bc44 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -900,6 +900,9 @@ gmatchcmp(Gmatch a, Gmatch b)
/* Count slashes. Trailing slashes don't count. */
while (*aptr && *aptr == *bptr)
aptr++, bptr++;
+ /* Like I just said... */
+ if ((!*aptr || !*bptr) && aptr > a->name && aptr[-1] == '/')
+ aptr--, bptr--;
if (*aptr)
for (; aptr[1]; aptr++)
if (*aptr == '/') {
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: append mark qualifier disturbs sort qualifier?
2014-09-24 18:27 ` Peter Stephenson
@ 2014-09-25 2:32 ` Han Pingtian
0 siblings, 0 replies; 5+ messages in thread
From: Han Pingtian @ 2014-09-25 2:32 UTC (permalink / raw)
To: zsh-users
On Wed, Sep 24, 2014 at 07:27:57PM +0100, Peter Stephenson wrote:
> On Wed, 24 Sep 2014 17:24:04 +0800
> Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> > localhost% print -l **/*(odonT)
> > 2/3/4/
> > 2/3/4/5.txt
> > 2/3/4/6.txt
> > 2/
> > 2/3/
> >
> > Here, looks like "(T)" disturbs the sorting of "(odon)"?
>
> Aha.
>
> diff --git a/Src/glob.c b/Src/glob.c
> index c24bfec..ca7bc44 100644
> --- a/Src/glob.c
> +++ b/Src/glob.c
> @@ -900,6 +900,9 @@ gmatchcmp(Gmatch a, Gmatch b)
> /* Count slashes. Trailing slashes don't count. */
> while (*aptr && *aptr == *bptr)
> aptr++, bptr++;
> + /* Like I just said... */
> + if ((!*aptr || !*bptr) && aptr > a->name && aptr[-1] == '/')
> + aptr--, bptr--;
> if (*aptr)
> for (; aptr[1]; aptr++)
> if (*aptr == '/') {
>
This patch works just fine. Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-25 2:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 9:24 append mark qualifier disturbs sort qualifier? Han Pingtian
2014-09-24 9:49 ` Peter Stephenson
2014-09-24 16:30 ` Bart Schaefer
2014-09-24 18:27 ` Peter Stephenson
2014-09-25 2:32 ` Han Pingtian
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).