summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-08-12 19:12:40 +0000
committerache <ache@FreeBSD.org>1996-08-12 19:12:40 +0000
commit1563880d65c4bda89a2d4c4504dd8b0f834322d4 (patch)
treeb437f72d86724f3099f35375ef5f8c44a907f610
parent62d22e65bdcc1a114ff10a64c5d89c2bda26339b (diff)
downloadFreeBSD-src-1563880d65c4bda89a2d4c4504dd8b0f834322d4.zip
FreeBSD-src-1563880d65c4bda89a2d4c4504dd8b0f834322d4.tar.gz
Convert to newly aded collate compare function
-rw-r--r--games/fortune/strfile/strfile.c35
-rw-r--r--gnu/usr.bin/sort/sort.c26
2 files changed, 4 insertions, 57 deletions
diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c
index a432e05..71f4780 100644
--- a/games/fortune/strfile/strfile.c
+++ b/games/fortune/strfile/strfile.c
@@ -350,35 +350,6 @@ void do_order()
Tbl.str_flags |= STR_ORDERED;
}
-int collcmp (c1, c2)
-int c1, c2;
-{
- static char s1[2], s2[2];
-
- if ( (isascii(c1) && isascii(c2))
- || (!isalpha(c1) && !isalpha(c2))
- )
- return (c1 - c2);
- if (isalpha(c1) && !isalpha(c2)) {
- if (isupper(c1))
- return ('A' - c2);
- else
- return ('a' - c2);
- } else if (isalpha(c2) && !isalpha(c1)) {
- if (isupper(c2))
- return (c1 - 'A');
- else
- return (c1 - 'a');
- }
- if (isupper(c1) && islower(c2))
- return (-1);
- else if (islower(c1) && isupper(c2))
- return (1);
- s1[0] = c1;
- s2[0] = c2;
- return strcoll(s1, s2);
-}
-
/*
* cmp_str:
* Compare two strings in the file
@@ -395,7 +366,7 @@ STR *p1, *p2;
c1 = (unsigned char) p1->first;
c2 = (unsigned char) p2->first;
- if ((r = collcmp(c1, c2)) != 0)
+ if ((r = collate_range_cmp(c1, c2)) != 0)
return r;
(void) fseek(Sort_1, p1->pos, 0);
@@ -415,7 +386,7 @@ STR *p1, *p2;
if (isupper(c2))
c2 = tolower(c2);
}
- if ((r = collcmp(c1, c2)) != 0)
+ if ((r = collate_range_cmp(c1, c2)) != 0)
return r;
SET_N(n1, c1);
SET_N(n2, c2);
@@ -426,7 +397,7 @@ STR *p1, *p2;
c1 = 0;
if (IS_END(c2, n2))
c2 = 0;
- return collcmp(c1, c2);
+ return collate_range_cmp(c1, c2);
}
/*
diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c
index 0dbc719..f4d6127 100644
--- a/gnu/usr.bin/sort/sort.c
+++ b/gnu/usr.bin/sort/sort.c
@@ -203,31 +203,7 @@ static int collates[UCHAR_LIM];
static int
collcompare (const void *sa, const void *sb)
{
- int A = *((int *)sa), B = *((int *)sb);
- static char s1[2], s2[2];
-
- if (A == B)
- return (0);
- if (isascii(A) && isascii(B) || !isalpha(A) && !isalpha(B))
- return (A - B);
- if (isupper(A) && islower(B))
- return (-1);
- else if (islower(A) && isupper(B))
- return (1);
- if (isalpha(A) && !isalpha(B)) {
- if (isupper(A))
- return ('A' - B);
- else
- return ('a' - B);
- } else if (isalpha(B) && !isalpha(A)) {
- if (isupper(B))
- return (A - 'A');
- else
- return (A - 'a');
- }
- s1[0] = A;
- s2[0] = B;
- return strcoll(s1, s2);
+ return collate_range_cmp (*((int *)sa), *((int *)sb));
}
static void
OpenPOWER on IntegriCloud