1 // -*- C++ -*-
2 //===--------------------- support/win32/locale_win32.h -------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
12 #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
13
14 #include <crtversion.h>
15
16 #if _VC_CRT_MAJOR_VERSION < 14
17 // ctype mask table defined in msvcrt.dll
18 extern "C" unsigned short __declspec(dllimport) _ctype[];
19 #endif
20
21 #include "support/win32/support.h"
22 #include "support/win32/locale_mgmt_win32.h"
23 #include <stdio.h>
24
25 lconv *localeconv_l( locale_t loc );
26 size_t mbrlen_l( const char *__restrict s, size_t n,
27 mbstate_t *__restrict ps, locale_t loc);
28 size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
29 size_t len, mbstate_t *__restrict ps, locale_t loc );
30 size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
31 locale_t loc);
32 size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
33 size_t n, mbstate_t *__restrict ps, locale_t loc);
34 size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
35 size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc);
36 size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
37 size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);
38 wint_t btowc_l( int c, locale_t loc );
39 int wctob_l( wint_t c, locale_t loc );
40 inline _LIBCPP_ALWAYS_INLINE
decltype(MB_CUR_MAX)41 decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
42 {
43 return ___mb_cur_max_l_func(__l);
44 }
45
46 // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
47 #define mbtowc_l _mbtowc_l
48 #define strtoll_l _strtoi64_l
49 #define strtoull_l _strtoui64_l
50 #define strtof_l _strtof_l
51 #define strtod_l _strtod_l
52 #define strtold_l _strtold_l
53
54 inline _LIBCPP_INLINE_VISIBILITY
55 int
islower_l(int c,_locale_t loc)56 islower_l(int c, _locale_t loc)
57 {
58 return _islower_l((int)c, loc);
59 }
60
61 inline _LIBCPP_INLINE_VISIBILITY
62 int
isupper_l(int c,_locale_t loc)63 isupper_l(int c, _locale_t loc)
64 {
65 return _isupper_l((int)c, loc);
66 }
67
68 #define isdigit_l _isdigit_l
69 #define isxdigit_l _isxdigit_l
70 #define strcoll_l _strcoll_l
71 #define strxfrm_l _strxfrm_l
72 #define wcscoll_l _wcscoll_l
73 #define wcsxfrm_l _wcsxfrm_l
74 #define toupper_l _toupper_l
75 #define tolower_l _tolower_l
76 #define iswspace_l _iswspace_l
77 #define iswprint_l _iswprint_l
78 #define iswcntrl_l _iswcntrl_l
79 #define iswupper_l _iswupper_l
80 #define iswlower_l _iswlower_l
81 #define iswalpha_l _iswalpha_l
82 #define iswdigit_l _iswdigit_l
83 #define iswpunct_l _iswpunct_l
84 #define iswxdigit_l _iswxdigit_l
85 #define towupper_l _towupper_l
86 #define towlower_l _towlower_l
87 #define strftime_l _strftime_l
88 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
89 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
90 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
91 #define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
92 #define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
93 int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
94 int asprintf_l( char **ret, locale_t loc, const char *format, ... );
95 int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
96
97
98 // not-so-pressing FIXME: use locale to determine blank characters
isblank_l(int c,locale_t)99 inline int isblank_l( int c, locale_t /*loc*/ )
100 {
101 return ( c == ' ' || c == '\t' );
102 }
iswblank_l(wint_t c,locale_t)103 inline int iswblank_l( wint_t c, locale_t /*loc*/ )
104 {
105 return ( c == L' ' || c == L'\t' );
106 }
107
108 #if defined(_LIBCPP_MSVCRT)
isblank(int c,locale_t)109 inline int isblank( int c, locale_t /*loc*/ )
110 { return ( c == ' ' || c == '\t' ); }
iswblank(wint_t c,locale_t)111 inline int iswblank( wint_t c, locale_t /*loc*/ )
112 { return ( c == L' ' || c == L'\t' ); }
113 #endif // _LIBCPP_MSVCRT
114 #endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
115