summaryrefslogtreecommitdiffstats
path: root/libcxx/include/support/win32/locale.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/support/win32/locale.h')
-rw-r--r--libcxx/include/support/win32/locale.h91
1 files changed, 62 insertions, 29 deletions
diff --git a/libcxx/include/support/win32/locale.h b/libcxx/include/support/win32/locale.h
index 6be80acecb6..dd56a049020 100644
--- a/libcxx/include/support/win32/locale.h
+++ b/libcxx/include/support/win32/locale.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===--------------------------- support/win32/locale.h --------------------------===//
+//===------------------------ support/win32/locale.h ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,10 +8,56 @@
//
//===----------------------------------------------------------------------===//
-// Locale stuff
-// FIXME: the *_l functions are fairly new, only available on Vista?/7+
-#include <xlocinfo.h> //
+#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_H
+#define _LIBCPP_SUPPORT_WIN32_LOCALE_H
+
+#include "support/win32/support.h"
+#include <memory>
+#include <xlocinfo.h> // _locale_t
#define locale_t _locale_t
+#define LC_COLLATE_MASK _M_COLLATE
+#define LC_CTYPE_MASK _M_CTYPE
+#define LC_MONETARY_MASK _M_MONETARY
+#define LC_NUMERIC_MASK _M_NUMERIC
+#define LC_TIME_MASK _M_TIME
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_ALL_MASK ( LC_COLLATE_MASK \
+ | LC_CTYPE_MASK \
+ | LC_MESSAGES_MASK \
+ | LC_MONETARY_MASK \
+ | LC_NUMERIC_MASK \
+ | LC_TIME_MASK )
+#define freelocale _free_locale
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t base );
+locale_t uselocale( locale_t newloc );
+lconv *localeconv_l( locale_t loc );
+size_t mbrlen_l( const char *__restrict__ s, size_t n,
+ mbstate_t *__restrict__ ps, locale_t loc);
+size_t mbsrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src,
+ size_t len, mbstate_t *__restrict__ ps, locale_t loc );
+size_t wcrtomb_l( char *__restrict__ s, wchar_t wc, mbstate_t *__restrict__ ps,
+ locale_t loc);
+size_t mbrtowc_l( wchar_t *__restrict__ pwc, const char *__restrict__ s,
+ size_t n, mbstate_t *__restrict__ ps, locale_t loc);
+size_t mbsnrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src,
+ size_t nms, size_t len, mbstate_t *__restrict__ ps, locale_t loc);
+size_t wcsnrtombs_l( char *__restrict__ dst, const wchar_t **__restrict__ src,
+ size_t nwc, size_t len, mbstate_t *__restrict__ ps, locale_t loc);
+wint_t btowc_l( int c, locale_t loc );
+int wctob_l( wint_t c, locale_t loc );
+typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
+typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
+_LIBCPP_ALWAYS_INLINE inline
+decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
+{
+ __locale_raii __current( uselocale(__l), uselocale );
+ return MB_CUR_MAX;
+}
+
+// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
+#include <stdio.h>
+#define mbtowc_l _mbtowc_l
#define strtoll_l _strtoi64_l
#define strtoull_l _strtoui64_l
// FIXME: current msvcrt does not know about long double
@@ -36,6 +82,17 @@
#define towupper_l _towupper_l
#define towlower_l _towlower_l
#define strftime_l _strftime_l
+#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
+#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
+#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
+#define snprintf_l( __s, __n, __l, __f, ... ) _snprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
+#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
+#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
+int asprintf_l( char **ret, locale_t loc, const char *format, ... );
+int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
+
+
+// not-so-pressing FIXME: use locale to determine blank characters
inline int isblank_l( int c, locale_t /*loc*/ )
{
return ( c == ' ' || c == '\t' );
@@ -44,29 +101,5 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ )
{
return ( c == L' ' || c == L'\t' );
}
-#define freelocale _free_locale
-// ignore base; it is always 0 in libc++ code
-inline locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
-{
- return _create_locale( mask, locale );
-}
-// FIXME: first call _configthreadlocale(_ENABLE_PER_THREAD_LOCALE) somewhere
-// FIXME: return types are different, need to make locale_t from char*
-inline locale_t uselocale(locale_t newloc)
-{
- return _create_locale( LC_ALL, setlocale(LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale) );
-}
-
-#define LC_COLLATE_MASK _M_COLLATE
-#define LC_CTYPE_MASK _M_CTYPE
-#define LC_MONETARY_MASK _M_MONETARY
-#define LC_NUMERIC_MASK _M_NUMERIC
-#define LC_TIME_MASK _M_TIME
-#define LC_MESSAGES_MASK _M_MESSAGES
-#define LC_ALL_MASK ( LC_COLLATE_MASK \
- | LC_CTYPE_MASK \
- | LC_MESSAGES_MASK \
- | LC_MONETARY_MASK \
- | LC_NUMERIC_MASK \
- | LC_TIME_MASK )
+#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_H \ No newline at end of file
OpenPOWER on IntegriCloud