summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/locale
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-09-16 22:26:52 +0000
committerdim <dim@FreeBSD.org>2015-09-16 22:26:52 +0000
commitea5248cdc11d47e16b420831d52143ca4afb904a (patch)
treeaaccdba1a8c990ea730287a164e76e70733b424a /contrib/libc++/include/locale
parent5cc32d7f18f18fb3a5f4155b7f748cc7be60d2da (diff)
parent50ffe587e08aebe69879f2e5b67ba1304ff781b3 (diff)
downloadFreeBSD-src-ea5248cdc11d47e16b420831d52143ca4afb904a.zip
FreeBSD-src-ea5248cdc11d47e16b420831d52143ca4afb904a.tar.gz
Update libc++ to 3.7.0 release.
Diffstat (limited to 'contrib/libc++/include/locale')
-rw-r--r--contrib/libc++/include/locale65
1 files changed, 32 insertions, 33 deletions
diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale
index 0d01002..e683ba3 100644
--- a/contrib/libc++/include/locale
+++ b/contrib/libc++/include/locale
@@ -198,7 +198,8 @@ template <class charT> class messages_byname;
// include of <sys/cdefs.h> once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
// has had a chance to bake for a bit
#include <support/newlib/xlocale.h>
-#elif !defined(__ANDROID__)
+#endif
+#ifdef _LIBCPP_HAS_CATOPEN
#include <nl_types.h>
#endif
@@ -216,7 +217,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if defined(__APPLE__) || defined(__FreeBSD__)
# define _LIBCPP_GET_C_LOCALE 0
-#elif defined(__NetBSD__)
+#elif defined(__CloudABI__) || defined(__NetBSD__)
# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
#else
# define _LIBCPP_GET_C_LOCALE __cloc()
@@ -235,7 +236,7 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
// locale. Linux, not so much. The following functions avoid the locale when
// that's possible and otherwise do the wrong thing. FIXME.
#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \
- defined(_NEWLIB_VERSION)
+ defined(_NEWLIB_VERSION) || defined(__GLIBC__)
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
@@ -1190,7 +1191,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
#else
- if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1)
+ if (__sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
#endif
__err = ios_base::failbit;
// EOF checked
@@ -1560,7 +1561,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
+ int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1585,12 +1586,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
this->__format_int(__fmt+1, __len, true, __iob.flags());
const unsigned __nbuf = (numeric_limits<long long>::digits / 3)
+ ((numeric_limits<long long>::digits % 3) != 0)
- + 1;
+ + 2;
char __nar[__nbuf];
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
+ int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1620,7 +1621,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
+ int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1650,7 +1651,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
+ int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1682,14 +1683,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#else
- __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
- (int)__iob.precision(), __v);
+ __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
+ (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
+ __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
unique_ptr<char, void(*)(void*)> __nbh(0, free);
if (__nc > static_cast<int>(__nbuf-1))
@@ -1698,14 +1699,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#else
- __nc = __asprintf_l(&__nb, __cloc(), __fmt,
- (int)__iob.precision(), __v);
+ __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- __nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision(), __v);
+ __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
if (__nb == 0)
__throw_bad_alloc();
@@ -1751,14 +1751,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#else
- __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
- (int)__iob.precision(), __v);
+ __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
+ (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
+ __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
unique_ptr<char, void(*)(void*)> __nbh(0, free);
if (__nc > static_cast<int>(__nbuf-1))
@@ -1767,14 +1767,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#else
- __nc = __asprintf_l(&__nb, __cloc(), __fmt,
- (int)__iob.precision(), __v);
+ __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- __nc = __asprintf_l(&__nb, __cloc(), __fmt, __v);
+ __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
if (__nb == 0)
__throw_bad_alloc();
@@ -1814,7 +1813,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
- int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
+ int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -3527,7 +3526,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__n = static_cast<size_t>(asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
#else
- __n = __asprintf_l(&__bb, __cloc(), "%.0Lf", __units);
+ __n = __asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
#endif
if (__bb == 0)
__throw_bad_alloc();
@@ -3681,14 +3680,14 @@ template <class _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
{
-#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
- return -1;
-#else // _WIN32 || __ANDROID__
+#ifdef _LIBCPP_HAS_CATOPEN
catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
if (__cat != -1)
__cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
return __cat;
-#endif // _WIN32 || __ANDROID__
+#else // !_LIBCPP_HAS_CATOPEN
+ return -1;
+#endif // _LIBCPP_HAS_CATOPEN
}
template <class _CharT>
@@ -3696,9 +3695,7 @@ typename messages<_CharT>::string_type
messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
const string_type& __dflt) const
{
-#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
- return __dflt;
-#else // _WIN32
+#ifdef _LIBCPP_HAS_CATOPEN
string __ndflt;
__narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
__dflt.c_str(),
@@ -3711,19 +3708,21 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
__widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
__n, __n + strlen(__n));
return __w;
-#endif // _WIN32
+#else // !_LIBCPP_HAS_CATOPEN
+ return __dflt;
+#endif // _LIBCPP_HAS_CATOPEN
}
template <class _CharT>
void
messages<_CharT>::do_close(catalog __c) const
{
-#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#ifdef _LIBCPP_HAS_CATOPEN
if (__c != -1)
__c <<= 1;
nl_catd __cat = (nl_catd)__c;
catclose(__cat);
-#endif // !_WIN32
+#endif // _LIBCPP_HAS_CATOPEN
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>)
OpenPOWER on IntegriCloud