From d85536af73dc5d327075d983abfa69d70e129d20 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Sat, 2 Jun 2001 21:46:42 +0000 Subject: Add locale-enabled strcoll function from vodz, plus supporting tool. --- libc/string/string.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libc/string/string.c') 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 ************************************/ -- cgit v1.2.3