diff options
author | ache <ache@FreeBSD.org> | 1996-06-09 18:55:57 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-06-09 18:55:57 +0000 |
commit | 3973c485bd3c9ad043575f0f636e55bc2ad116ac (patch) | |
tree | 3693ce962d1fadba06c9e9b66b14de0d069ecbbf /gnu/usr.bin/sort | |
parent | 7f880a4a3399287cffa3317a5f87c613f910c894 (diff) | |
download | FreeBSD-src-3973c485bd3c9ad043575f0f636e55bc2ad116ac.zip FreeBSD-src-3973c485bd3c9ad043575f0f636e55bc2ad116ac.tar.gz |
Follow alphabetical order more closely, now ISO8859-1 characters
sorted properly too.
Diffstat (limited to 'gnu/usr.bin/sort')
-rw-r--r-- | gnu/usr.bin/sort/sort.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c index 3a9bc97..995ed62 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); |