diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1996-08-12 18:38:49 +0000 | 
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1996-08-12 18:38:49 +0000 | 
| commit | 883a3266d1879a3c6161c27eb85dd1996b9857e9 (patch) | |
| tree | 4c16aa6af5c8b1a6d0f6f45ddc240a18586a1873 | |
| parent | 806af72bd98609af2edae9872f5111c1830b8337 (diff) | |
Notes
| -rw-r--r-- | lib/libc/locale/collcmp.c | 29 | 
1 files changed, 20 insertions, 9 deletions
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 <ctype.h>  #include <string.h> +#include <locale.h> + +/* 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);  } -  | 
