From 9cca9761a626a16dcfe14da71adcbbf730296349 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 9 Jun 1996 18:55:57 +0000 Subject: [PATCH] Follow alphabetical order more closely, now ISO8859-1 characters sorted properly too. --- gnu/usr.bin/sort/sort.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c index 3a9bc9724f05..995ed623b930 100644 --- a/gnu/usr.bin/sort/sort.c +++ b/gnu/usr.bin/sort/sort.c @@ -201,12 +201,25 @@ colldiff (unsigned char A, unsigned char B) { static unsigned char s1[2], s2[2]; - if (isascii(A) || isascii(B) || !isalpha(A) || !isalpha(B)) + if (A == B) + return (0); + if (isascii(A) && isascii(B) || !isalpha(A) && !isalpha(B)) return ((int)A - (int)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' - (int)B); + else + return ('a' - (int)B); + } else if (isalpha(B) && !isalpha(A)) { + if (isupper(B)) + return ((int)A - 'A'); + else + return ((int)A - 'a'); + } s1[0] = A; s2[0] = B; return strcoll(s1, s2);