diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c index 15dba54737fe..fefa52d94eb8 100644 --- a/lib/libc/locale/collcmp.c +++ b/lib/libc/locale/collcmp.c @@ -26,36 +26,47 @@ #include #include +#include + +/* will be removed ***************************/ #include "collate.h" int __collcmp (c1, c2) - u_char c1, c2; + unsigned char c1, c2; +{ + return collate_range_cmp (c1, c2); +} +/* will be removed ***************************/ + +int collate_range_cmp (c1, c2) + int c1, c2; { static char s1[2], s2[2]; + c1 &= UCHAR_MAX; + c2 &= UCHAR_MAX; if (c1 == c2) return (0); if ( (isascii(c1) && isascii(c2)) || (!isalpha(c1) && !isalpha(c2)) ) - return (((int)c1) - ((int)c2)); + return (c1 - c2); if (isalpha(c1) && !isalpha(c2)) { if (isupper(c1)) - return ('A' - ((int)c2)); + return ('A' - c2); else - return ('a' - ((int)c2)); + return ('a' - c2); } else if (isalpha(c2) && !isalpha(c1)) { if (isupper(c2)) - return (((int)c1) - 'A'); + return (c1 - 'A'); else - return (((int)c1) - 'a'); + return (c1 - 'a'); } if (isupper(c1) && islower(c2)) return (-1); else if (islower(c1) && isupper(c2)) return (1); - s1[0] = (char) c1; - s2[0] = (char) c2; + s1[0] = c1; + s2[0] = c2; return strcoll(s1, s2); } -