[libcxx-commits] [PATCH] D100510: [libc++] money_get::do_get() set failbit and eofbit if iterator begin equals end

Jason Liu via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 28 19:23:27 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG363a8a05988d: [libc++] money_get::do_get() set failbit and eofbit if iterator begin equals end (authored by jasonliu).
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.

Changed prior to commit:
  https://reviews.llvm.org/D100510?vs=337887&id=362605#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100510/new/

https://reviews.llvm.org/D100510

Files:
  libcxx/include/locale
  libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
  libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp


Index: libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
===================================================================
--- libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
+++ libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
@@ -729,6 +729,17 @@
             assert(ex == L"");
         }
     }
+    {
+      // test for err
+      const my_facet f(1);
+      std::string v = "1.23";
+      typedef cpp17_input_iterator<const char*> I;
+      std::string ex = "NULL";
+      std::ios_base::iostate err = std::ios_base::goodbit;
+      f.get(I(v.data()), I(v.data()), false, ios, err, ex);
+      assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+      assert(ex == "NULL");
+    }
 
   return 0;
 }
Index: libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
===================================================================
--- libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
+++ libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
@@ -721,6 +721,17 @@
             assert(err == std::ios_base::failbit);
         }
     }
+    {
+      // test for err
+      const my_facet f(1);
+      std::string v = "1.23";
+      typedef cpp17_input_iterator<const char*> I;
+      long double ex = -1L;
+      std::ios_base::iostate err = std::ios_base::goodbit;
+      f.get(I(v.data()), I(v.data()), false, ios, err, ex);
+      assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+      assert(ex == -1L);
+    }
 
   return 0;
 }
Index: libcxx/include/locale
===================================================================
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -2891,6 +2891,10 @@
                                             unique_ptr<char_type, void(*)(void*)>& __wb,
                                             char_type*& __wn, char_type* __we)
 {
+    if (__b == __e) {
+        __err |= ios_base::failbit;
+        return false;
+    }
     const unsigned __bz = 100;
     unsigned __gbuf[__bz];
     unique_ptr<unsigned, void(*)(void*)> __gb(__gbuf, __do_nothing);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100510.362605.patch
Type: text/x-patch
Size: 2540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210729/7cceee67/attachment-0001.bin>


More information about the libcxx-commits mailing list