1 1.2 christos /* $NetBSD: wcscasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $ */ 2 1.2 christos 3 1.2 christos /* 4 1.2 christos * Copyright (C) 2006 Aleksey Cheusov 5 1.2 christos * 6 1.2 christos * This material is provided "as is", with absolutely no warranty expressed 7 1.2 christos * or implied. Any use is at your own risk. 8 1.2 christos * 9 1.2 christos * Permission to use or copy this software for any purpose is hereby granted 10 1.2 christos * without fee. Permission to modify the code and to distribute modified 11 1.2 christos * code is also granted without any restrictions. 12 1.2 christos */ 13 1.1 christos 14 1.1 christos #include <sys/cdefs.h> 15 1.1 christos #if defined(LIBC_SCCS) && !defined(lint) 16 1.2 christos __RCSID("$NetBSD: wcscasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $"); 17 1.1 christos #endif /* LIBC_SCCS and not lint */ 18 1.1 christos 19 1.1 christos #include "namespace.h" 20 1.1 christos #include <assert.h> 21 1.1 christos #include <wchar.h> 22 1.1 christos #include <wctype.h> 23 1.1 christos 24 1.1 christos __weak_alias(wcscasecmp,_wcscasecmp) 25 1.1 christos 26 1.1 christos int 27 1.1 christos wcscasecmp(const wchar_t *s1, const wchar_t *s2) 28 1.1 christos { 29 1.1 christos int lc1 = 0; 30 1.1 christos int lc2 = 0; 31 1.1 christos int diff = 0; 32 1.1 christos 33 1.1 christos _DIAGASSERT(s1); 34 1.1 christos _DIAGASSERT(s2); 35 1.1 christos 36 1.1 christos for (;;) { 37 1.1 christos lc1 = towlower(*s1); 38 1.1 christos lc2 = towlower(*s2); 39 1.1 christos 40 1.1 christos diff = lc1 - lc2; 41 1.1 christos if (diff) 42 1.1 christos return diff; 43 1.1 christos 44 1.1 christos if (!lc1) 45 1.1 christos return 0; 46 1.1 christos 47 1.1 christos ++s1; 48 1.1 christos ++s2; 49 1.1 christos } 50 1.1 christos } 51