Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 1 | // -*- 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 Hinnant | dbe8111 | 2011-09-23 16:11:27 +0000 | [diff] [blame^] | 21 | #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 |
| 39 | inline int isblank_l( int c, locale_t /*loc*/ ) |
| 40 | { |
| 41 | return ( c == ' ' || c == '\t' ); |
| 42 | } |
| 43 | inline int iswblank_l( wint_t c, locale_t /*loc*/ ) |
| 44 | { |
| 45 | return ( c == L' ' || c == L'\t' ); |
| 46 | } |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 47 | #define freelocale _free_locale |
Howard Hinnant | dbe8111 | 2011-09-23 16:11:27 +0000 | [diff] [blame^] | 48 | // ignore base; it is always 0 in libc++ code |
| 49 | inline locale_t newlocale( int mask, const char * locale, locale_t /*base*/ ) |
| 50 | { |
| 51 | return _create_locale( mask, locale ); |
| 52 | } |
| 53 | |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 54 | // FIXME: first call _configthreadlocale(_ENABLE_PER_THREAD_LOCALE) somewhere |
| 55 | // FIXME: return types are different, need to make locale_t from char* |
| 56 | inline locale_t uselocale(locale_t newloc) |
| 57 | { |
Howard Hinnant | dbe8111 | 2011-09-23 16:11:27 +0000 | [diff] [blame^] | 58 | return _create_locale( LC_ALL, setlocale(LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale) ); |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 59 | } |
| 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 Hinnant | dbe8111 | 2011-09-23 16:11:27 +0000 | [diff] [blame^] | 67 | #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 ) |