Remove building with NOCRYPTO option
[minix3.git] / lib / libc / string / wcsncasecmp.c
blob7500e511e5fb74c80bb739de7fbc09025e570195
1 /* $NetBSD: wcsncasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $ */
3 /*
4 * Copyright (C) 2006 Aleksey Cheusov
6 * This material is provided "as is", with absolutely no warranty expressed
7 * or implied. Any use is at your own risk.
9 * Permission to use or copy this software for any purpose is hereby granted
10 * without fee. Permission to modify the code and to distribute modified
11 * code is also granted without any restrictions.
14 #include <sys/cdefs.h>
15 #if defined(LIBC_SCCS) && !defined(lint)
16 __RCSID("$NetBSD: wcsncasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $");
17 #endif /* LIBC_SCCS and not lint */
19 #include "namespace.h"
20 #include <assert.h>
21 #include <wchar.h>
22 #include <wctype.h>
23 #include <locale.h>
24 #include "setlocale_local.h"
26 __weak_alias(wcsncasecmp,_wcsncasecmp)
27 __weak_alias(wcsncasecmp_l,_wcsncasecmp_l)
29 int
30 wcsncasecmp_l(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t loc)
32 int lc1 = 0;
33 int lc2 = 0;
34 int diff = 0;
36 _DIAGASSERT(s1);
37 _DIAGASSERT(s2);
39 while (n--) {
40 lc1 = towlower_l(*s1, loc);
41 lc2 = towlower_l(*s2, loc);
43 diff = lc1 - lc2;
44 if (diff)
45 return diff;
47 if (!lc1)
48 return 0;
50 ++s1;
51 ++s2;
54 return 0;
57 int
58 wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
60 return wcsncasecmp_l(s1, s2, n, _current_locale());