Back to index

glibc  2.9
wcfuncs_l.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996,1997,2000-2002,2004,2005 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 #include <ctype.h>
00020 #include <wctype.h>
00021 #include <stdint.h>
00022 #include <locale.h>
00023 #include <locale/localeinfo.h>
00024 
00025 #define USE_IN_EXTENDED_LOCALE_MODEL
00026 #include "wchar-lookup.h"
00027 
00028 /* Provide real-function versions of all the wctype macros.  */
00029 
00030 #define       func(name, type) \
00031   int __isw##name (wint_t wc, __locale_t locale)                     \
00032   {                                                                  \
00033     if (isascii (wc))                                                       \
00034       return is##name ((int) wc, locale);                            \
00035     size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \
00036     const char *desc = locale->__locales[LC_CTYPE]->values[i].string;       \
00037     return wctype_table_lookup (desc, wc);                                  \
00038   }                                                                  \
00039   libc_hidden_def (__isw##name)                                             \
00040   weak_alias (__isw##name, isw##name)
00041 
00042 func (alnum_l, __ISwalnum)
00043 func (alpha_l, __ISwalpha)
00044 func (blank_l, __ISwblank)
00045 func (cntrl_l, __ISwcntrl)
00046 #undef iswdigit_l
00047 #undef __iswdigit_l
00048 func (digit_l, __ISwdigit)
00049 func (lower_l, __ISwlower)
00050 func (graph_l, __ISwgraph)
00051 func (print_l, __ISwprint)
00052 func (punct_l, __ISwpunct)
00053 func (space_l, __ISwspace)
00054 func (upper_l, __ISwupper)
00055 func (xdigit_l, __ISwxdigit)
00056 
00057 wint_t
00058 (__towlower_l) (wint_t wc, __locale_t locale)
00059 {
00060   size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_tolower;
00061   const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
00062   return wctrans_table_lookup (desc, wc);
00063 }
00064 libc_hidden_def (__towlower_l)
00065 weak_alias (__towlower_l, towlower_l)
00066 
00067 wint_t
00068 (__towupper_l) (wint_t wc, __locale_t locale)
00069 {
00070   size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_toupper;
00071   const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
00072   return wctrans_table_lookup (desc, wc);
00073 }
00074 libc_hidden_def (__towupper_l)
00075 weak_alias (__towupper_l, towupper_l)