From 73a4362713b8fb624ec70a5d86d4e5d87fba2b7b Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 22 Feb 2002 17:28:04 +0000 Subject: 16620, 16697: add a and n parameter expansion flags --- Src/glob.c | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'Src/glob.c') 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 */ /**/ -- cgit 1.4.1