[cfe-commits] [libcxx] r150609 - in /libcxx/trunk: include/locale test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp

Howard Hinnant hhinnant at apple.com
Wed Feb 15 11:19:38 PST 2012


Author: hhinnant
Date: Wed Feb 15 13:19:37 2012
New Revision: 150609

URL: http://llvm.org/viewvc/llvm-project?rev=150609&view=rev
Log:
Do not parse sign if a sign is not the next legal character when parsing floating point from an input stream.  Fixes http://llvm.org/bugs/show_bug.cgi?id=11871

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

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=150609&r1=150608&r2=150609&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Wed Feb 15 13:19:37 2012
@@ -665,6 +665,15 @@
     if (__f >= 32)
         return -1;
     char __x = __src[__f];
+    if (__x == '-' || __x == '+')
+    {
+        if (__a_end == __a || (__a_end[-1] & 0xDF) == __exp)
+        {
+            *__a_end++ = __x;
+            return 0;
+        }
+        return -1;
+    }
     if (__a_end-__a < __num_get_buf_sz - 1)
         *__a_end++ = __x;
     if (__x == 'x' || __x == 'X')

Modified: libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp?rev=150609&r1=150608&r2=150609&view=diff
==============================================================================
--- libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp (original)
+++ libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp Wed Feb 15 13:19:37 2012
@@ -192,6 +192,18 @@
         assert(err == ios.goodbit);
         assert(v == 123);
     }
+    {
+        v = -1;
+        const char str[] = "2-";
+        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+1);
+        assert(err == ios.goodbit);
+        assert(v == 2);
+    }
     ios.imbue(std::locale(std::locale(), new my_numpunct));
     {
         v = -1;

Modified: libcxx/trunk/test/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/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp?rev=150609&r1=150608&r2=150609&view=diff
==============================================================================
--- libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp (original)
+++ libcxx/trunk/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp Wed Feb 15 13:19:37 2012
@@ -144,6 +144,18 @@
         assert(err == ios.goodbit);
         assert(v == 83);
     }
+    {
+        const char str[] = "2-";
+        ios.setf(0, ios.basefield);
+        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+1);
+        assert(err == ios.goodbit);
+        assert(v == 2);
+    }
     dec(ios);
     ios.imbue(std::locale(std::locale(), new my_numpunct));
     {





More information about the cfe-commits mailing list