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