Back to index

glibc  2.9
wcscasecmp.c
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022 
00023 #include <wctype.h>
00024 #include <wchar.h>
00025 
00026 #ifndef weak_alias
00027 # define __wcscasecmp wcscasecmp
00028 # define TOLOWER(Ch) towlower (Ch)
00029 #else
00030 # ifdef USE_IN_EXTENDED_LOCALE_MODEL
00031 #  define __wcscasecmp __wcscasecmp_l
00032 #  define TOLOWER(Ch) __towlower_l ((Ch), loc)
00033 # else
00034 #  define TOLOWER(Ch) towlower (Ch)
00035 # endif
00036 #endif
00037 
00038 #ifdef USE_IN_EXTENDED_LOCALE_MODEL
00039 # define LOCALE_PARAM , loc
00040 # define LOCALE_PARAM_DECL __locale_t loc;
00041 #else
00042 # define LOCALE_PARAM
00043 # define LOCALE_PARAM_DECL
00044 #endif
00045 
00046 /* Compare S1 and S2, ignoring case, returning less than, equal to or
00047    greater than zero if S1 is lexicographically less than,
00048    equal to or greater than S2.  */
00049 int
00050 __wcscasecmp (s1, s2 LOCALE_PARAM)
00051      const wchar_t *s1;
00052      const wchar_t *s2;
00053      LOCALE_PARAM_DECL
00054 {
00055   wint_t c1, c2;
00056 
00057   if (s1 == s2)
00058     return 0;
00059 
00060   do
00061     {
00062       c1 = TOLOWER (*s1++);
00063       c2 = TOLOWER (*s2++);
00064       if (c1 == L'\0')
00065        break;
00066     }
00067   while (c1 == c2);
00068 
00069   return c1 - c2;
00070 }
00071 #ifndef __wcscasecmp
00072 weak_alias (__wcscasecmp, wcscasecmp)
00073 #endif