| 1 | /*
 | 
|---|
| 2 |  * wctype.h
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  * Functions for wide character classification and conversion.
 | 
|---|
| 5 |  *
 | 
|---|
| 6 |  * $Id: wctype.h,v e38eed5e2087 2016/07/09 20:53:41 keithmarshall $
 | 
|---|
| 7 |  *
 | 
|---|
| 8 |  * Written by Mumit Khan <khan@xraylith.wisc.edu>
 | 
|---|
| 9 |  * Copyright (C) 1999-2003, 2005-2007, 2016, MinGW.org Project
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *
 | 
|---|
| 12 |  * Permission is hereby granted, free of charge, to any person obtaining a
 | 
|---|
| 13 |  * copy of this software and associated documentation files (the "Software"),
 | 
|---|
| 14 |  * to deal in the Software without restriction, including without limitation
 | 
|---|
| 15 |  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 | 
|---|
| 16 |  * and/or sell copies of the Software, and to permit persons to whom the
 | 
|---|
| 17 |  * Software is furnished to do so, subject to the following conditions:
 | 
|---|
| 18 |  *
 | 
|---|
| 19 |  * The above copyright notice, this permission notice, and the following
 | 
|---|
| 20 |  * disclaimer shall be included in all copies or substantial portions of
 | 
|---|
| 21 |  * the Software.
 | 
|---|
| 22 |  *
 | 
|---|
| 23 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 | 
|---|
| 24 |  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
|---|
| 25 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 | 
|---|
| 26 |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
|---|
| 27 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 | 
|---|
| 28 |  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
 | 
|---|
| 29 |  * DEALINGS IN THE SOFTWARE.
 | 
|---|
| 30 |  *
 | 
|---|
| 31 |  */
 | 
|---|
| 32 | #ifndef _WCTYPE_H
 | 
|---|
| 33 | #pragma GCC system_header
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #ifndef __CTYPE_H_SOURCED__
 | 
|---|
| 36 | /* Perversely, (since they provide <wctype.h> themselves), Microsoft
 | 
|---|
| 37 |  * say that most of the definitions and declarations which follow are
 | 
|---|
| 38 |  * provided by <ctype.h>, rather than here; (this conflicts with both
 | 
|---|
| 39 |  * ISO-C and POSIX).  We prefer to provide them here, for ISO-C/POSIX
 | 
|---|
| 40 |  * conformance, while also exposing them for selective inclusion by
 | 
|---|
| 41 |  * <ctype.h>, to maintain Microsoft compatibility.
 | 
|---|
| 42 |  *
 | 
|---|
| 43 |  * We define the <wctype.h> multiple inclusion guard macro only when
 | 
|---|
| 44 |  * <wctype.h> is included directly, NOT when included via <ctype.h>
 | 
|---|
| 45 |  */
 | 
|---|
| 46 | #define _WCTYPE_H
 | 
|---|
| 47 | 
 | 
|---|
| 48 | /* All MinGW headers must include <_mingw.h>; when sourced by <ctype.h>,
 | 
|---|
| 49 |  * we may delegate that responsibility to it, but in the case of direct
 | 
|---|
| 50 |  * inclusion, we must address it ourselves.
 | 
|---|
| 51 |  */
 | 
|---|
| 52 | #include <_mingw.h>
 | 
|---|
| 53 | #endif
 | 
|---|
| 54 | 
 | 
|---|
| 55 | /* The following flags are used to tell iswctype() and _isctype() what
 | 
|---|
| 56 |  * character classes are to be matched; (note that _BLANK will match for
 | 
|---|
| 57 |  * SP and non-ASCII horizontal space chars -- e.g. for "no-break space",
 | 
|---|
| 58 |  * 0xA0, in CP1250 -- but NOT for HT).
 | 
|---|
| 59 |  *
 | 
|---|
| 60 |  * These are defined such that they will be made visible by inclusion
 | 
|---|
| 61 |  * of either <wctype.h> (this file), or <ctype.h>:
 | 
|---|
| 62 |  */
 | 
|---|
| 63 | #define _ALPHA          0x0103
 | 
|---|
| 64 | #define _LOWER          0x0002
 | 
|---|
| 65 | #define _UPPER          0x0001
 | 
|---|
| 66 | #define _DIGIT          0x0004
 | 
|---|
| 67 | #define _SPACE          0x0008          /* HT  LF  VT  FF  CR  SP */
 | 
|---|
| 68 | #define _PUNCT          0x0010
 | 
|---|
| 69 | #define _CONTROL        0x0020
 | 
|---|
| 70 | #define _BLANK          0x0040
 | 
|---|
| 71 | #define _HEX            0x0080
 | 
|---|
| 72 | 
 | 
|---|
| 73 | #ifndef RC_INVOKED
 | 
|---|
| 74 | 
 | 
|---|
| 75 | /* ISO-C and POSIX specify that <wctype.h> must define wint_t, wctype_t,
 | 
|---|
| 76 |  * and the WEOF macro, (which also requires wchar_t), as they are defined
 | 
|---|
| 77 |  * in <wchar.h>; since <wchar.h> gets wint_t, (and wchar_t), from <stddef.h>,
 | 
|---|
| 78 |  * we do likewise here.  Furthermore, to maintain Microsoft compatibility,
 | 
|---|
| 79 |  * we must also do this on behalf of <ctype.h>; however...
 | 
|---|
| 80 |  */
 | 
|---|
| 81 | #if !(defined _WCTYPE_H && defined _CTYPE_H)
 | 
|---|
| 82 | /* ...we need not incur the overhead of doing it twice, when both <ctype.h>
 | 
|---|
| 83 |  * and <wctype.h> have been included.
 | 
|---|
| 84 |  */
 | 
|---|
| 85 | #define __need_wint_t
 | 
|---|
| 86 | #define __need_wchar_t
 | 
|---|
| 87 | #include <stddef.h>
 | 
|---|
| 88 | 
 | 
|---|
| 89 | typedef wchar_t  wctype_t;
 | 
|---|
| 90 | #define WEOF    (wchar_t)(0xffff)
 | 
|---|
| 91 | 
 | 
|---|
| 92 | _BEGIN_C_DECLS
 | 
|---|
| 93 | 
 | 
|---|
| 94 | /* Wide character classification functions.  In typically perverse
 | 
|---|
| 95 |  * fashion, and contrary to both ISO-C and POSIX, Microsoft specify
 | 
|---|
| 96 |  * that these should be declared in <ctype.h>; thus, to accommodate
 | 
|---|
| 97 |  * this persersity, we make them visible here, irrespective of any
 | 
|---|
| 98 |  * selective inclusion filter macro.
 | 
|---|
| 99 |  */
 | 
|---|
| 100 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswalnum (wint_t);
 | 
|---|
| 101 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswalpha (wint_t);
 | 
|---|
| 102 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswascii (wint_t);
 | 
|---|
| 103 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswcntrl (wint_t);
 | 
|---|
| 104 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswctype (wint_t, wctype_t);
 | 
|---|
| 105 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswdigit (wint_t);
 | 
|---|
| 106 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswgraph (wint_t);
 | 
|---|
| 107 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswlower (wint_t);
 | 
|---|
| 108 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswprint (wint_t);
 | 
|---|
| 109 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswpunct (wint_t);
 | 
|---|
| 110 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswspace (wint_t);
 | 
|---|
| 111 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswupper (wint_t);
 | 
|---|
| 112 | _CRTIMP __cdecl __MINGW_NOTHROW  int iswxdigit (wint_t);
 | 
|---|
| 113 | 
 | 
|---|
| 114 | __MINGW_ATTRIB_DEPRECATED
 | 
|---|
| 115 | /* This function is exported by all versions of MSVCRT.DLL, (up to and
 | 
|---|
| 116 |  * including that in Windows-7), and in all non-free counterparts up to
 | 
|---|
| 117 |  * and including MSVCR120.DLL, but as of MSVC-2013, Microsoft declare
 | 
|---|
| 118 |  * it to be obsolete.  DO NOT USE IT!  Use iswctype() instead.
 | 
|---|
| 119 |  */
 | 
|---|
| 120 | _CRTIMP __cdecl __MINGW_NOTHROW  int is_wctype (wint_t, wctype_t);
 | 
|---|
| 121 | 
 | 
|---|
| 122 | #if __STDC_VERSION__>=199901L || !defined __STRICT_ANSI__ || defined __cplusplus
 | 
|---|
| 123 | __cdecl __MINGW_NOTHROW  int iswblank (wint_t);
 | 
|---|
| 124 | #endif
 | 
|---|
| 125 | 
 | 
|---|
| 126 | /* Wide character case transliteration functions; the following conform
 | 
|---|
| 127 |  * to the ISO-C and POSIX standard declarations; Microsoft, at one time,
 | 
|---|
| 128 |  * specified both as taking a wchar_t argument, and returning a wchar_t
 | 
|---|
| 129 |  * result, but now take a wint_t argument, and return int.
 | 
|---|
| 130 |  */
 | 
|---|
| 131 | _CRTIMP __cdecl __MINGW_NOTHROW  wint_t towlower (wint_t);
 | 
|---|
| 132 | _CRTIMP __cdecl __MINGW_NOTHROW  wint_t towupper (wint_t);
 | 
|---|
| 133 | 
 | 
|---|
| 134 | #if !(defined __NO_INLINE__ || defined __NO_CTYPE_INLINES)
 | 
|---|
| 135 | /* Provide inline alternatives to the DLL-exported isw*() functions.
 | 
|---|
| 136 |  * Note that POSIX stipulates that these alternatives should be macros;
 | 
|---|
| 137 |  * we prefer __CRT_INLINEs, (which GCC effectively treats as macros),
 | 
|---|
| 138 |  * because they do not interfere with C++ namespace qualification.
 | 
|---|
| 139 |  */
 | 
|---|
| 140 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswalnum (wint_t wc)
 | 
|---|
| 141 | { return (iswctype (wc, _ALPHA | _DIGIT)); }
 | 
|---|
| 142 | 
 | 
|---|
| 143 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswalpha (wint_t wc)
 | 
|---|
| 144 | { return (iswctype (wc, _ALPHA )); }
 | 
|---|
| 145 | 
 | 
|---|
| 146 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswascii (wint_t wc)
 | 
|---|
| 147 | { return ((wc & ~0x7F) == 0); }
 | 
|---|
| 148 | 
 | 
|---|
| 149 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswcntrl (wint_t wc)
 | 
|---|
| 150 | { return (iswctype (wc, _CONTROL)); }
 | 
|---|
| 151 | 
 | 
|---|
| 152 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswdigit (wint_t wc)
 | 
|---|
| 153 | { return (iswctype (wc, _DIGIT)); }
 | 
|---|
| 154 | 
 | 
|---|
| 155 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswgraph (wint_t wc)
 | 
|---|
| 156 | { return (iswctype (wc, _PUNCT | _ALPHA | _DIGIT)); }
 | 
|---|
| 157 | 
 | 
|---|
| 158 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswlower (wint_t wc)
 | 
|---|
| 159 | { return (iswctype (wc, _LOWER)); }
 | 
|---|
| 160 | 
 | 
|---|
| 161 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswprint (wint_t wc)
 | 
|---|
| 162 | { return (iswctype (wc, _BLANK | _PUNCT | _ALPHA | _DIGIT)); }
 | 
|---|
| 163 | 
 | 
|---|
| 164 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswpunct (wint_t wc)
 | 
|---|
| 165 | { return (iswctype (wc, _PUNCT)); }
 | 
|---|
| 166 | 
 | 
|---|
| 167 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswspace (wint_t wc)
 | 
|---|
| 168 | { return (iswctype (wc, _SPACE)); }
 | 
|---|
| 169 | 
 | 
|---|
| 170 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswupper (wint_t wc)
 | 
|---|
| 171 | { return (iswctype (wc, _UPPER)); }
 | 
|---|
| 172 | 
 | 
|---|
| 173 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswxdigit (wint_t wc)
 | 
|---|
| 174 | { return (iswctype (wc, _HEX)); }
 | 
|---|
| 175 | 
 | 
|---|
| 176 | #if __STDC_VERSION__>=199901L || !defined __STRICT_ANSI__ || defined __cplusplus
 | 
|---|
| 177 | __CRT_INLINE __cdecl __MINGW_NOTHROW  int iswblank (wint_t wc)
 | 
|---|
| 178 | { return (iswctype (wc, _BLANK) || wc == L'\t'); }
 | 
|---|
| 179 | #endif
 | 
|---|
| 180 | #endif  /* !__NO_CTYPE_INLINES */
 | 
|---|
| 181 | 
 | 
|---|
| 182 | _END_C_DECLS
 | 
|---|
| 183 | 
 | 
|---|
| 184 | #endif  /* !(_WCTYPE_H && _CTYPE_H) */
 | 
|---|
| 185 | 
 | 
|---|
| 186 | #ifdef _WCTYPE_H
 | 
|---|
| 187 | /* Although Microsoft make most of the content, which ISO-C and POSIX say
 | 
|---|
| 188 |  * should be in <wctype.h>, available through <ctype.h>, the declarations
 | 
|---|
| 189 |  * in this section are exclusive to <wctype.h>
 | 
|---|
| 190 |  */
 | 
|---|
| 191 | typedef wchar_t  wctrans_t;
 | 
|---|
| 192 | 
 | 
|---|
| 193 | _BEGIN_C_DECLS
 | 
|---|
| 194 | 
 | 
|---|
| 195 | /* These are provided in libmingwex.a.  Note, that they are also exported
 | 
|---|
| 196 |  * by the MS C++ runtime lib (MSVCP60.DLL).  The MSVCP60.DLL implementations
 | 
|---|
| 197 |  * of wctrans and towctrans are not C99 compliant in that wctrans("tolower")
 | 
|---|
| 198 |  * returns 0, while C99 specifies that a non-zero value should be returned
 | 
|---|
| 199 |  * for a valid string descriptor.  If you want the MS behaviour (and you
 | 
|---|
| 200 |  * have MSVCP60.DLL in your path) add -lmsvcp60 to your command line.
 | 
|---|
| 201 |  */
 | 
|---|
| 202 | __cdecl __MINGW_NOTHROW  wint_t towctrans (wint_t, wctrans_t);
 | 
|---|
| 203 | __cdecl __MINGW_NOTHROW  wctrans_t wctrans (const char*);
 | 
|---|
| 204 | __cdecl __MINGW_NOTHROW  wctype_t wctype (const char*);
 | 
|---|
| 205 | 
 | 
|---|
| 206 | _END_C_DECLS
 | 
|---|
| 207 | 
 | 
|---|
| 208 | #endif  /* _WCTYPE_H */
 | 
|---|
| 209 | #endif  /* ! RC_INVOKED */
 | 
|---|
| 210 | #endif  /* !_WCTYPE_H: $RCSfile: wctype.h,v $: end of file */
 | 
|---|