summaryrefslogtreecommitdiff
path: root/libc/string/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string/string.c')
-rw-r--r--libc/string/string.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libc/string/string.c b/libc/string/string.c
index b3070907c..0e2df303b 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -76,7 +76,38 @@ int strcmp(const char *s1, const char *s2)
return c1 - c2;
}
+#ifndef __UCLIBC_HAS_LOCALE__
__asm__(".weak strcoll; strcoll = strcmp");
+#endif /* __UCLIBC_HAS_LOCALE__ */
+#endif
+
+/***** Function strcoll (locale only, as non-locale is alias of strcmp *****/
+
+#ifdef L_strcoll
+#ifdef __UCLIBC_HAS_LOCALE__
+
+#include "../misc/locale/_locale.h"
+
+const unsigned char *_uc_collate_b; /* NULL for no collate, strcoll->strcmp */
+
+int strcoll(const char *s1, const char *s2)
+{
+ unsigned char c1, c2;
+
+ while(1) {
+ c1 = (unsigned char) *s1;
+ c2 = (unsigned char) *s2;
+ if(_uc_collate_b) { /* setuped non-C locale? */
+ c1 = _uc_collate_b[c1];
+ c2 = _uc_collate_b[c2];
+ }
+ if (*s1 == '\0' || c1 != c2)
+ return c1 - c2;
+ s1++;
+ s2++;
+ }
+}
+#endif /* __UCLIBC_HAS_LOCALE__ */
#endif
/********************** Function strncat ************************************/