[PATCH] D24218: [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.

2016-12-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 81010.
EricWF added a comment.

Address inline comments.


https://reviews.llvm.org/D24218

Files:
  src/locale.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp

Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -16,12 +16,11 @@
 
 // char_type thousands_sep() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +53,22 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+const char sep = ',';
+const wchar_t wsep = L',';
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.thousands_sep() == ',');
+assert(np.thousands_sep() == sep);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.thousands_sep() == L',');
+assert(np.thousands_sep() == wsep);
 }
 }
 }
Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -16,12 +16,10 @@
 
 // string grouping() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
-
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +52,20 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char* const group = "\3";
+#else
+const char* const group = "\x7f";
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() ==  group);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() == group);
 }
 }
 }
Index: test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -18,16 +18,11 @@
 
 // charT thousands_sep() const;
 
-// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
-// and U002E as mon_decimal_point.
-// TODO: U00A0 should be investigated.
-// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
-// XFAIL: linux-gnu
-
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 class Fnf
@@ -114,22 +109,34 @@
 Fwt f(LOCALE_fr_FR_UTF_8, 1);
 assert(f.thousands_sep() == L' ');
 }
-
+// The below tests work around GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: Fix thousands_sep for 'char'.
+// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+#ifndef TEST_HAS_GLIBC
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+// FIXME libc++ specifically works around \u00A0 by translating it into
+// a regular space.
+const char sep = ' ';
+const wchar_t wsep = L'\u00A0';
+#endif
 {
 Fnf f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == ' ');
+assert(f.thousands_sep() == sep);
 }
 {
 Fnt f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == ' ');
+assert(f.thousands_sep() == sep);
 }
 {
 Fwf f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == L' ');
+assert(f.thousands_sep() == wsep);
 }
 {
 Fwt f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.t

[PATCH] D24218: [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.

2016-12-05 Thread Eric van Gyzen via Phabricator via cfe-commits
vangyzen added inline comments.



Comment at: src/locale.cpp:4339
 if (loc == nullptr)
 __throw_runtime_error("numpunct_byname::numpunct_byname"
 " failed to construct for " + string(nm));

While you're here, you might change `char` to `wchar_t`.



Comment at: src/locale.cpp:4348
 __grouping_ = lc->grouping;
 // locallization for truename and falsename is not available
 }

Maybe fix the spelling of "localization".


https://reviews.llvm.org/D24218



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24218: [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "[libc++] Fix support for multibyte 
thousands_sep and decimal_point in moneypunct_byname" to "[libc++] Fix support 
for multibyte thousands_sep and decimal_point in moneypunct_byname and 
numpunct_byname.".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 70494.

https://reviews.llvm.org/D24218

Files:
  src/locale.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp

Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -16,12 +16,11 @@
 
 // char_type thousands_sep() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +53,22 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+const char sep = ',';
+const wchar_t wsep = L',';
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.thousands_sep() == ',');
+assert(np.thousands_sep() == sep);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.thousands_sep() == L',');
+assert(np.thousands_sep() == wsep);
 }
 }
 }
Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -16,12 +16,10 @@
 
 // string grouping() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
-
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +52,20 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char* const group = "\3";
+#else
+const char* const group = "\x7f";
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() ==  group);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet >(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() == group);
 }
 }
 }
Index: test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -18,16 +18,11 @@
 
 // charT thousands_sep() const;
 
-// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
-// and U002E as mon_decimal_point.
-// TODO: U00A0 should be investigated.
-// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
-// XFAIL: linux-gnu
-
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 class Fnf
@@ -114,22 +109,34 @@
 Fwt f(LOCALE_fr_FR_UTF_8, 1);
 assert(f.thousands_sep() == L' ');
 }
-
+// The below tests work around GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: Fix thousands_sep for 'char'.
+// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+#ifndef TEST_HAS_GLIBC
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+// FIXME libc++ specifically works around \u00A0 by translating it into
+// a regular space.
+const char sep = ' ';
+const wchar_t wsep = L'\u00A0';
+#endif
 {
 Fnf f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == ' ');
+assert(f.thousands_sep() == sep);
 }
 {
 Fnt f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == ' ');
+assert(f.