[libcxx-commits] [libcxx] r362508 - No longer reject inputs when using a locale that has grouping information _and_ the input has no grouping characters at all. We continue to reject cases when the input has grouping characters in the wrong place. Fixes PR#28704

Marshall Clow via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 4 08:18:47 PDT 2019


Author: marshall
Date: Tue Jun  4 08:18:46 2019
New Revision: 362508

URL: http://llvm.org/viewvc/llvm-project?rev=362508&view=rev
Log:
No longer reject inputs when using a locale that has grouping information _and_ the input has no grouping characters at all. We continue to reject cases when the input has grouping characters in the wrong place. Fixes PR#28704

Modified:
    libcxx/trunk/src/locale.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=362508&r1=362507&r2=362508&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Tue Jun  4 08:18:46 2019
@@ -4379,7 +4379,9 @@ void
 __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
                  ios_base::iostate& __err)
 {
-    if (__grouping.size() != 0)
+//  if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
+//  we always have at least a single entry in [__g, __g_end); the end of the input sequence
+	if (__grouping.size() >= 0 && __g_end - __g > 1)
     {
         reverse(__g, __g_end);
         const char* __ig = __grouping.data();

Modified: libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp?rev=362508&r1=362507&r2=362508&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp Tue Jun  4 08:18:46 2019
@@ -162,14 +162,14 @@ int main(int, char**)
     ios.imbue(std::locale(std::locale(), new my_numpunct));
     {
         v = -1;
-        const char str[] = "123";
+        const char str[] = "123"; // no separators at all
         std::ios_base::iostate err = ios.goodbit;
         input_iterator<const char*> iter =
             f.get(input_iterator<const char*>(str),
                   input_iterator<const char*>(str+sizeof(str)),
                   ios, err, v);
         assert(iter.base() == str+sizeof(str)-1);
-        assert(err == ios.failbit);
+        assert(err == ios.goodbit);
         assert(v == 123);
     }
     {




More information about the libcxx-commits mailing list