| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | #define _CTYPE_DISABLE_MACROS |
| 8 | #include <wctype.h> |
| 9 | |
| 10 | /** |
| 11 | * CRT's `iswctype` has inconsistent behavior for TAB character when used with |
| 12 | * `wctype_t` objects returned by `wctype` function which contain `_BLANK` bit. |
| 13 | * |
| 14 | * In all CRTs up to msvcrt.dll version 6.1, it returns zero in "C" locale |
| 15 | * and non-zero otherwise. |
| 16 | * |
| 17 | * Since msvcr70.dll up to msvcr110.dll it always returns non-zero; |
| 18 | * OS-specific versions of msvcrt.dll follow this behavior. |
| 19 | * |
| 20 | * In msvcr120.dll and UCRT it always returns zero. |
| 21 | * |
| 22 | * This behavior affects both `iswblank` and `iswprint` functions; |
| 23 | * either or both of them have non-conforming behavior. |
| 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * This is CRT's `iswctype` renamed to `__msvcrt_iswctype`. |
| 28 | */ |
| 29 | extern int (__cdecl *__MINGW_IMP_SYMBOL(__msvcrt_iswctype)) (wint_t, wctype_t); |
| 30 | |
| 31 | int iswctype (wint_t _C, wctype_t _Type) { |
| 32 | /** |
| 33 | * `wctype_t` object returned for "print" character class contains _BLANK; |
| 34 | * make sure TAB is handled correctly. |
| 35 | */ |
| 36 | if (_C == L'\t' && (_Type & _BLANK)) { |
| 37 | return (_Type == _BLANK ? _BLANK : 0); |
| 38 | } |
| 39 | |
| 40 | return __MINGW_IMP_SYMBOL (__msvcrt_iswctype) (_C, _Type); |
| 41 | } |
| 42 | |
| 43 | int (__cdecl *__MINGW_IMP_SYMBOL (iswctype)) (wint_t, wctype_t) = iswctype; |