1 /* $NetBSD: wcsncasecmp.c,v 1.1 2006/08/22 20:50:46 christos Exp $ */ 2 3 #include <sys/cdefs.h> 4 #if defined(LIBC_SCCS) && !defined(lint) 5 __RCSID("$NetBSD: wcsncasecmp.c,v 1.1 2006/08/22 20:50:46 christos Exp $"); 6 #endif /* LIBC_SCCS and not lint */ 7 8 #include "namespace.h" 9 #include <assert.h> 10 #include <wchar.h> 11 #include <wctype.h> 12 13 __weak_alias(wcsncasecmp,_wcsncasecmp) 14 15 int 16 wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) 17 { 18 int lc1 = 0; 19 int lc2 = 0; 20 int diff = 0; 21 22 _DIAGASSERT(s1); 23 _DIAGASSERT(s2); 24 25 while (n--) { 26 lc1 = towlower (*s1); 27 lc2 = towlower (*s2); 28 29 diff = lc1 - lc2; 30 if (diff) 31 return diff; 32 33 if (!lc1) 34 return 0; 35 36 ++s1; 37 ++s2; 38 } 39 40 return 0; 41 } 42