* PATCH: numericglobsort
@ 2007-04-15 21:44 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2007-04-15 21:44 UTC (permalink / raw)
To: Zsh hackers list
Here's something else I broke (in 23118). There's already a test for
numericglobsort, but it turns out it works in the C locale. I've
duplicated the test in the multibyte code, although the problem is not
strictly dependent on multibyte support. For some reason in the UTF-8
locales zero sorts ahead of dot instead of vice versa; goodness knows
why but ls confirms this isn't just zsh.
Index: Src/sort.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/sort.c,v
retrieving revision 1.3
diff -u -r1.3 sort.c
--- Src/sort.c 22 Jan 2007 17:28:16 -0000 1.3
+++ Src/sort.c 15 Apr 2007 21:20:35 -0000
@@ -42,8 +42,8 @@
{
const SortElt ae = *(const SortElt *)a;
const SortElt be = *(const SortElt *)b;
- const char *as = ae->cmp;
- const char *bs = be->cmp;
+ const char *as = ae->cmp, *bs = be->cmp;
+ const char *ao = as;
int cmp;
if (ae->len != -1 || be->len != -1) {
@@ -122,7 +122,7 @@
cmp = (int)STOUC(*as) - (int)STOUC(*bs);
#endif
if (idigit(*as) || idigit(*bs)) {
- for (; as > *(char **)a && idigit(as[-1]); as--, bs--);
+ for (; as > ao && idigit(as[-1]); as--, bs--);
if (idigit(*as) && idigit(*bs)) {
while (*as == '0')
as++;
Index: Test/D07multibyte.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v
retrieving revision 1.15
diff -u -r1.15 D07multibyte.ztst
--- Test/D07multibyte.ztst 10 Feb 2007 22:12:59 -0000 1.15
+++ Test/D07multibyte.ztst 15 Apr 2007 21:20:35 -0000
@@ -358,3 +358,22 @@
>1 148
>1 149
>1 150
+
+ touch ngs1.txt ngs2.txt ngs10.txt ngs20.txt ngs100.txt ngs200.txt
+ setopt numericglobsort
+ print -l ngs*
+ unsetopt numericglobsort
+ print -l ngs*
+0:NUMERIC_GLOB_SORT option in UTF-8 locale
+>ngs1.txt
+>ngs2.txt
+>ngs10.txt
+>ngs20.txt
+>ngs100.txt
+>ngs200.txt
+>ngs100.txt
+>ngs10.txt
+>ngs1.txt
+>ngs200.txt
+>ngs20.txt
+>ngs2.txt
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-15 21:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-15 21:44 PATCH: numericglobsort Peter Stephenson
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).