summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-08-12 18:38:49 +0000
committerache <ache@FreeBSD.org>1996-08-12 18:38:49 +0000
commit956383bed878377c60fa07ec47955f81a6ee5833 (patch)
tree4c16aa6af5c8b1a6d0f6f45ddc240a18586a1873 /lib
parent9d1e0928b13cff2524bded1e91ac4687fb3a05c8 (diff)
downloadFreeBSD-src-956383bed878377c60fa07ec47955f81a6ee5833.zip
FreeBSD-src-956383bed878377c60fa07ec47955f81a6ee5833.tar.gz
There is so many places where range comparation (using collate)
needed (much more than I think initially), so I forced to add new user-visible non-standard function to libc.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/locale/collcmp.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c
index 15dba54..fefa52d 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);
}
-
OpenPOWER on IntegriCloud