OSDN Git Service

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