about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/sort.c6
-rw-r--r--Test/D07multibyte.ztst19
3 files changed, 25 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d2994496..9a7d28c7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-04-15  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 23278: Src/sort.c, Test/D07multibyte.ztst: Fix
+	NUMERICGLOBSORT, broken by 23118.
+
 	* users/11398: Src/zle_move.c: vi-goto-mark was broken
 	by multibyte characters.
 
diff --git a/Src/sort.c b/Src/sort.c
index f312150df..e88cc2cea 100644
--- a/Src/sort.c
+++ b/Src/sort.c
@@ -42,8 +42,8 @@ eltpcmp(const void *a, const void *b)
 {
     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 @@ eltpcmp(const void *a, const void *b)
 	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++;
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 07479539b..2e362f751 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -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