[libcxx-commits] [PATCH] D56702: [libc++] Use runtime rather then compile-time glibc version check
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 28 12:41:02 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX352425: [libc++] Use runtime rather then compile-time glibc version check (authored by phosek, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D56702?vs=183164&id=183941#toc
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56702/new/
https://reviews.llvm.org/D56702
Files:
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
Index: test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
===================================================================
--- test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
+++ test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -61,6 +61,20 @@
: std::moneypunct_byname<wchar_t, true>(nm, refs) {}
};
+#if defined(_CS_GNU_LIBC_VERSION)
+static bool glibc_version_less_than(char const* version) {
+ std::string test_version = std::string("glibc ") + version;
+
+ size_t n = confstr(_CS_GNU_LIBC_VERSION, nullptr, (size_t)0);
+ char *current_version = new char[n];
+ confstr(_CS_GNU_LIBC_VERSION, current_version, n);
+
+ bool result = strverscmp(current_version, test_version.c_str()) < 0;
+ delete[] current_version;
+ return result;
+}
+#endif
+
int main()
{
{
@@ -116,17 +130,14 @@
{
Fnf f(LOCALE_ru_RU_UTF_8, 1);
+#if defined(_CS_GNU_LIBC_VERSION)
// GLIBC <= 2.23 uses currency_symbol="<U0440><U0443><U0431>"
// GLIBC >= 2.24 uses currency_symbol="<U20BD>"
// See also: http://www.fileformat.info/info/unicode/char/20bd/index.htm
-#if defined(TEST_GLIBC_PREREQ)
- #if TEST_GLIBC_PREREQ(2, 24)
- #define TEST_GLIBC_2_24_CURRENCY_SYMBOL
- #endif
-#endif
-
-#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
- assert(f.curr_symbol() == " \u20BD");
+ if (!glibc_version_less_than("2.24"))
+ assert(f.curr_symbol() == " \u20BD");
+ else
+ assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
#else
assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
#endif
@@ -137,8 +148,11 @@
}
{
Fwf f(LOCALE_ru_RU_UTF_8, 1);
-#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
- assert(f.curr_symbol() == L" \u20BD");
+#if defined(_CS_GNU_LIBC_VERSION)
+ if (!glibc_version_less_than("2.24"))
+ assert(f.curr_symbol() == L" \u20BD");
+ else
+ assert(f.curr_symbol() == L" \x440\x443\x431");
#else
assert(f.curr_symbol() == L" \x440\x443\x431");
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56702.183941.patch
Type: text/x-patch
Size: 2218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190128/2a1aab80/attachment-0001.bin>
More information about the libcxx-commits
mailing list