diff options
author | ache <ache@FreeBSD.org> | 1996-06-09 14:56:08 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-06-09 14:56:08 +0000 |
commit | ec6853868b71426ea726e839f93e1cc8f3c5b761 (patch) | |
tree | b328dc5a7b9ebe2656d1aaacc4c7a2a0c75a8664 /lib/libc/string/strcoll.c | |
parent | 2fe7739b977266bf3a61a8078e5a5ffb70b3cc6d (diff) | |
download | FreeBSD-src-ec6853868b71426ea726e839f93e1cc8f3c5b761.zip FreeBSD-src-ec6853868b71426ea726e839f93e1cc8f3c5b761.tar.gz |
Use better approximation if collate info not available.
Fix bug: strxfrm+strcmp != strcoll, if collate info not available
Diffstat (limited to 'lib/libc/string/strcoll.c')
-rw-r--r-- | lib/libc/string/strcoll.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/libc/string/strcoll.c b/lib/libc/string/strcoll.c index 915e649..c8fff23 100644 --- a/lib/libc/string/strcoll.c +++ b/lib/libc/string/strcoll.c @@ -24,11 +24,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: strcoll.c,v 1.3 1995/02/18 01:38:58 ache Exp $ + * $Id: strcoll.c,v 1.4 1995/04/16 22:43:45 ache Exp $ */ #include <stdlib.h> #include <string.h> +#include <ctype.h> #include "collate.h" int @@ -38,8 +39,23 @@ strcoll(s, s2) int len, len2, prim, prim2, sec, sec2, ret, ret2; char *tt, *t, *tt2, *t2; - if (__collate_load_error) - return strcasecmp(s, s2); + if (__collate_load_error) { + register const u_char + *us1 = (const u_char *)s, + *us2 = (const u_char *)s2; + + while (tolower(*us1) == tolower(*us2)) { + if (*us1 == '\0') + return (0); + if (isupper(*us1) && islower(*us2)) + return (-1); + else if (islower(*us1) && isupper(*us2)) + return (1); + *us1++; + *us2++; + } + return (tolower(*us1) - tolower(*us2)); + } len = len2 = 1; ret = ret2 = 0; |