blob: 9df9be59cadf2891391fc6c92d8833be46cb9883 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
* Copyright (C) 2002 Manuel Novoa III
* Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "_string.h"
#include <ctype.h>
#include <locale.h>
#ifdef WANT_WIDE
# define strncasecmp wcsncasecmp
# define strncasecmp_l wcsncasecmp_l
libc_hidden_proto(wcsncasecmp)
# if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
libc_hidden_proto(wcsncasecmp_l)
# endif
# ifdef __UCLIBC_DO_XLOCALE
libc_hidden_proto(towlower_l)
# define TOLOWER(C) towlower_l((C), locale_arg)
# else
libc_hidden_proto(towlower)
# define TOLOWER(C) towlower((C))
# endif
#else
/* Experimentally off - libc_hidden_proto(strncasecmp) */
/* Experimentally off - libc_hidden_proto(strncasecmp_l) */
# ifdef __UCLIBC_DO_XLOCALE
libc_hidden_proto(tolower_l)
# define TOLOWER(C) tolower_l((C), locale_arg)
# else
#if !defined __UCLIBC_HAS_XLOCALE__ && defined __UCLIBC_HAS_CTYPE_TABLES__
/* libc_hidden_proto(__ctype_tolower) */
#endif
/* libc_hidden_proto(tolower) */
# define TOLOWER(C) tolower((C))
# endif
#endif
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
}
libc_hidden_def(strncasecmp)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
/* Experimentally off - libc_hidden_proto(__XL_NPP(strncasecmp)) */
int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
size_t n __LOCALE_PARAM )
{
#ifdef WANT_WIDE
while (n && ((*s1 == *s2) || (TOLOWER(*s1) == TOLOWER(*s2)))) {
if (!*s1++) {
return 0;
}
++s2;
--n;
}
return (n == 0)
? 0
: ((((Wuchar)TOLOWER(*s1)) < ((Wuchar)TOLOWER(*s2))) ? -1 : 1);
/* TODO -- should wide cmp funcs do wchar or Wuchar compares? */
#else
int r = 0;
while ( n
&& ((s1 == s2) ||
!(r = ((int)( TOLOWER(*((unsigned char *)s1))))
- TOLOWER(*((unsigned char *)s2))))
&& (--n, ++s2, *s1++));
return r;
#endif
}
libc_hidden_def(__XL_NPP(strncasecmp))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
|