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