Back to index

glibc  2.9
wcfuncs.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996-2001, 2002, 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 <locale/localeinfo.h>
00022 
00023 #include "wchar-lookup.h"
00024 
00025 /* Provide real-function versions of all the wctype macros.  */
00026 
00027 #define       func(name, type)                                              \
00028   extern int __isw##name (wint_t __wc);                                     \
00029   int                                                                \
00030   __isw##name (wint_t wc)                                            \
00031   {                                                                  \
00032     if (isascii (wc))                                                       \
00033       return is##name ((int) wc);                                    \
00034     size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET) + type;    \
00035     const char *desc = _NL_CURRENT (LC_CTYPE, i);                           \
00036     return wctype_table_lookup (desc, wc);                                  \
00037   }                                                                  \
00038   weak_alias (__isw##name, isw##name)
00039 
00040 #undef iswalnum
00041 func (alnum, __ISwalnum)
00042 libc_hidden_weak (iswalnum)
00043 #undef iswalpha
00044 func (alpha, __ISwalpha)
00045 libc_hidden_weak (iswalpha)
00046 #undef iswblank
00047 func (blank, __ISwblank)
00048 #undef iswcntrl
00049 func (cntrl, __ISwcntrl)
00050 #undef iswdigit
00051 func (digit, __ISwdigit)
00052 libc_hidden_weak (iswdigit)
00053 #undef iswlower
00054 func (lower, __ISwlower)
00055 libc_hidden_weak (iswlower)
00056 #undef iswgraph
00057 func (graph, __ISwgraph)
00058 #undef iswprint
00059 func (print, __ISwprint)
00060 #undef iswpunct
00061 func (punct, __ISwpunct)
00062 #undef iswspace
00063 func (space, __ISwspace)
00064 libc_hidden_weak (iswspace)
00065 #undef iswupper
00066 func (upper, __ISwupper)
00067 #undef iswxdigit
00068 func (xdigit, __ISwxdigit)
00069 libc_hidden_weak (iswxdigit)
00070 
00071 #undef towlower
00072 wint_t
00073 towlower (wc)
00074      wint_t wc;
00075 {
00076   size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + __TOW_tolower;
00077   const char *desc = _NL_CURRENT (LC_CTYPE, i);
00078   return wctrans_table_lookup (desc, wc);
00079 }
00080 libc_hidden_def (towlower)
00081 
00082 #undef towupper
00083 wint_t
00084 towupper (wc)
00085      wint_t wc;
00086 {
00087   size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + __TOW_toupper;
00088   const char *desc = _NL_CURRENT (LC_CTYPE, i);
00089   return wctrans_table_lookup (desc, wc);
00090 }
00091 libc_hidden_def (towupper)