summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/locale9
-rw-r--r--libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp12
-rw-r--r--libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp12
3 files changed, 33 insertions, 0 deletions
diff --git a/libcxx/include/locale b/libcxx/include/locale
index a81a63a72e4..adf8e2f9cfc 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -665,6 +665,15 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
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')
diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
index 4fa9b0a877f..2df395cd1d7 100644
--- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
+++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
@@ -192,6 +192,18 @@ int main()
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;
diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
index 8bcaaa9375c..8fcaaa4f87f 100644
--- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
+++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
@@ -144,6 +144,18 @@ int main()
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));
{
OpenPOWER on IntegriCloud