blob: 6be80acecb633d6159590f432e5e9377783e3010 [file] [log] [blame]
Howard Hinnant3c78ca02011-09-22 19:10:18 +00001// -*- C++ -*-
2//===--------------------------- support/win32/locale.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// Locale stuff
12// FIXME: the *_l functions are fairly new, only available on Vista?/7+
13#include <xlocinfo.h> //
14#define locale_t _locale_t
15#define strtoll_l _strtoi64_l
16#define strtoull_l _strtoui64_l
17// FIXME: current msvcrt does not know about long double
18#define strtold_l _strtod_l
19#define isdigit_l _isdigit_l
20#define isxdigit_l _isxdigit_l
Howard Hinnantdbe81112011-09-23 16:11:27 +000021#define strcoll_l _strcoll_l
22#define strxfrm_l _strxfrm_l
23#define wcscoll_l _wcscoll_l
24#define wcsxfrm_l _wcsxfrm_l
25#define toupper_l _toupper_l
26#define tolower_l _tolower_l
27#define iswspace_l _iswspace_l
28#define iswprint_l _iswprint_l
29#define iswcntrl_l _iswcntrl_l
30#define iswupper_l _iswupper_l
31#define iswlower_l _iswlower_l
32#define iswalpha_l _iswalpha_l
33#define iswdigit_l _iswdigit_l
34#define iswpunct_l _iswpunct_l
35#define iswxdigit_l _iswxdigit_l
36#define towupper_l _towupper_l
37#define towlower_l _towlower_l
38#define strftime_l _strftime_l
39inline int isblank_l( int c, locale_t /*loc*/ )
40{
41 return ( c == ' ' || c == '\t' );
42}
43inline int iswblank_l( wint_t c, locale_t /*loc*/ )
44{
45 return ( c == L' ' || c == L'\t' );
46}
Howard Hinnant3c78ca02011-09-22 19:10:18 +000047#define freelocale _free_locale
Howard Hinnantdbe81112011-09-23 16:11:27 +000048// ignore base; it is always 0 in libc++ code
49inline locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
50{
51 return _create_locale( mask, locale );
52}
53
Howard Hinnant3c78ca02011-09-22 19:10:18 +000054// FIXME: first call _configthreadlocale(_ENABLE_PER_THREAD_LOCALE) somewhere
55// FIXME: return types are different, need to make locale_t from char*
56inline locale_t uselocale(locale_t newloc)
57{
Howard Hinnantdbe81112011-09-23 16:11:27 +000058 return _create_locale( LC_ALL, setlocale(LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale) );
Howard Hinnant3c78ca02011-09-22 19:10:18 +000059}
60
61#define LC_COLLATE_MASK _M_COLLATE
62#define LC_CTYPE_MASK _M_CTYPE
63#define LC_MONETARY_MASK _M_MONETARY
64#define LC_NUMERIC_MASK _M_NUMERIC
65#define LC_TIME_MASK _M_TIME
66#define LC_MESSAGES_MASK _M_MESSAGES
Howard Hinnantdbe81112011-09-23 16:11:27 +000067#define LC_ALL_MASK ( LC_COLLATE_MASK \
68 | LC_CTYPE_MASK \
69 | LC_MESSAGES_MASK \
70 | LC_MONETARY_MASK \
71 | LC_NUMERIC_MASK \
72 | LC_TIME_MASK )