about summary refs log tree commit diff
path: root/Src/glob.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-02-22 17:28:04 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-02-22 17:28:04 +0000
commit73a4362713b8fb624ec70a5d86d4e5d87fba2b7b (patch)
treede3a8e80a0823da8c1ce6313f0f5ba674184ff4f /Src/glob.c
parente3b5e1356c601cf894b06311814060b66cb30f78 (diff)
downloadzsh-73a4362713b8fb624ec70a5d86d4e5d87fba2b7b.tar.gz
zsh-73a4362713b8fb624ec70a5d86d4e5d87fba2b7b.tar.xz
zsh-73a4362713b8fb624ec70a5d86d4e5d87fba2b7b.zip
16620, 16697: add a and n parameter expansion flags
Diffstat (limited to 'Src/glob.c')
-rw-r--r--Src/glob.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/Src/glob.c b/Src/glob.c
index aa82b91c1..75509fee5 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -854,7 +854,10 @@ gmatchcmp(Gmatch a, Gmatch b)
     for (i = gf_nsorts, s = gf_sortlist; i; i--, s++) {
 	switch (*s & ~GS_DESC) {
 	case GS_NAME:
-	    r = notstrcmp(&a->name, &b->name);
+	    if (gf_numsort)
+	    	r = nstrpcmp(&b->name, &a->name);
+	    else
+	    	r = strpcmp(&b->name, &a->name);
 	    break;
 	case GS_DEPTH:
 	    {
@@ -1611,46 +1614,6 @@ zglob(LinkList list, LinkNode np, int nountok)
     restore_globstate(saved);
 }
 
-/* Return the order of two strings, taking into account *
- * possible numeric order if NUMERICGLOBSORT is set.    *
- * The comparison here is reversed.                     */
-
-/**/
-static int
-notstrcmp(char **a, char **b)
-{
-    char *c = *b, *d = *a;
-    int cmp;
-
-#ifdef HAVE_STRCOLL
-    cmp = strcoll(c, d);
-#endif
-    for (; *c == *d && *c; c++, d++);
-#ifndef HAVE_STRCOLL
-    cmp = (int)STOUC(*c) - (int)STOUC(*d);
-#endif
-    if (gf_numsort && (idigit(*c) || idigit(*d))) {
-	for (; c > *b && idigit(c[-1]); c--, d--);
-	if (idigit(*c) && idigit(*d)) {
-	    while (*c == '0')
-		c++;
-	    while (*d == '0')
-		d++;
-	    for (; idigit(*c) && *c == *d; c++, d++);
-	    if (idigit(*c) || idigit(*d)) {
-		cmp = (int)STOUC(*c) - (int)STOUC(*d);
-		while (idigit(*c) && idigit(*d))
-		    c++, d++;
-		if (idigit(*c) && !idigit(*d))
-		    return 1;
-		if (idigit(*d) && !idigit(*c))
-		    return -1;
-	    }
-	}
-    }
-    return cmp;
-}
-
 /* Return the trailing character for marking file types */
 
 /**/