1 /**************************************************************************** 2 * Copyright 2018,2020 Thomas E. Dickey * 3 * Copyright 2012 Free Software Foundation, Inc. * 4 * * 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: * 12 * * 13 * The above copyright notice and this permission notice shall be included * 14 * in all copies or substantial portions of the Software. * 15 * * 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. * 23 * * 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 * 27 * authorization. * 28 ****************************************************************************/ 29 30 #ifndef __WIDECHARS_H 31 #define __WIDECHARS_H 1 32 33 #include <test.priv.h> 34 35 #if USE_WIDEC_SUPPORT 36 37 #if defined(_NC_WINDOWS) && !defined(_MSC_VER) && !defined(EXP_WIN32_DRIVER) 38 /* 39 * MinGW has wide-character functions, but they do not work correctly. 40 */ 41 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) 45 46 extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); 47 #define mblen(s,n) _nc_mblen(s, n) 48 49 #endif /* _WIN32||_WIN64 */ 50 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) 56 #define state_unused 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) 62 #else 63 make an error 64 #endif 65 66 #else 67 68 #endif /* USE_WIDEC_SUPPORT */ 69 70 extern void widechars_stub(void); 71 72 #endif /* __WIDECHARS_H */ 73