1 /****************************************************************************
2 * Copyright 2018,2020 Thomas E. Dickey *
3 * Copyright 2012 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
31 #define __WIDECHARS_H 1
33 #include <test.priv.h>
37 #if defined(_NC_WINDOWS) && !defined(_MSC_VER) && !defined(EXP_WIN32_DRIVER)
39 * MinGW has wide-character functions, but they do not work correctly.
42 extern int _nc_mbtowc(wchar_t *pwc, const char *s, size_t n);
43 extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *pwc, const char *s, size_t n);
44 #define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n)
46 extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
47 #define mblen(s,n) _nc_mblen(s, n)
49 #endif /* _WIN32||_WIN64 */
51 #if HAVE_MBTOWC && HAVE_MBLEN
52 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, 0)), IGNORE_RC(mbtowc(NULL, NULL, 0))
53 #define count_mbytes(buffer,length,state) mblen(buffer,length)
54 #define check_mbytes(wch,buffer,length,state) \
55 (int) mbtowc(&wch, buffer, length)
57 #elif HAVE_MBRTOWC && HAVE_MBRLEN
58 #define reset_mbytes(state) init_mb(state)
59 #define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
60 #define check_mbytes(wch,buffer,length,state) \
61 (int) mbrtowc(&wch, buffer, length, &state)
68 #endif /* USE_WIDEC_SUPPORT */
70 extern void widechars_stub(void);
72 #endif /* __WIDECHARS_H */