Cleanup: prefer _LIBCPP_GET_C_LOCALE over __cloc().
The __cloc() function is only present in case the environment does not
provide a way to refer to the C locale using a compile-time constant
expression. _LIBCPP_GET_C_LOCALE seems to be defined unconditionally.
This improves compilation of the locale code on CloudABI.
Differential Revision: http://reviews.llvm.org/D10690
Reviewed by: jroelofs
llvm-svn: 241454
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 2a7ab629e5d44ca69fa66b36549117ace5e9b063
diff --git a/src/locale.cpp b/src/locale.cpp
index abf7ecf..ed383e4 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -813,7 +813,7 @@
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
#else
- return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c;
+ return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
#endif
}
@@ -827,7 +827,7 @@
*low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
: *low;
#else
- *low = (isascii(*low) && islower_l(*low, __cloc())) ? (*low-L'a'+L'A') : *low;
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low;
#endif
return low;
}
@@ -840,7 +840,7 @@
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
#else
- return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
#endif
}
@@ -854,7 +854,7 @@
*low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
: *low;
#else
- *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-L'A'+L'a' : *low;
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low;
#endif
return low;
}
@@ -923,7 +923,7 @@
return isascii(c) ?
static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
#else
- return (isascii(c) && islower_l(c, __cloc())) ? c-'a'+'A' : c;
+ return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
#endif
}
@@ -940,7 +940,7 @@
*low = isascii(*low) ?
static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
#else
- *low = (isascii(*low) && islower_l(*low, __cloc())) ? *low-'a'+'A' : *low;
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low;
#endif
return low;
}
@@ -957,7 +957,7 @@
return isascii(c) ?
static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
#else
- return (isascii(c) && isupper_l(c, __cloc())) ? c-'A'+'a' : c;
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c;
#endif
}
@@ -972,7 +972,7 @@
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
*low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
#else
- *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low;
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
#endif
return low;
}
@@ -1105,7 +1105,7 @@
#elif defined(__NetBSD__)
return _C_ctype_tab_ + 1;
#elif defined(__GLIBC__)
- return __cloc()->__ctype_b;
+ return _LIBCPP_GET_C_LOCALE->__ctype_b;
#elif __sun__
return __ctype_mask;
#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
@@ -1134,13 +1134,13 @@
const int*
ctype<char>::__classic_lower_table() _NOEXCEPT
{
- return __cloc()->__ctype_tolower;
+ return _LIBCPP_GET_C_LOCALE->__ctype_tolower;
}
const int*
ctype<char>::__classic_upper_table() _NOEXCEPT
{
- return __cloc()->__ctype_toupper;
+ return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
}
#elif __NetBSD__
const short*