summaryrefslogtreecommitdiff
path: root/libstdc++-v3/config/locale
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-29 11:48:53 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-29 11:48:53 +0000
commitfbaa96d67e32888ce7e08e8647cdb4fa7cfc13e2 (patch)
tree2b6cb424d6ec5f62b07742a58556da2ccfca63d2 /libstdc++-v3/config/locale
parent66575a0b4994fa8b8c75366ccfdca82145d052ea (diff)
downloadgcc-fbaa96d67e32888ce7e08e8647cdb4fa7cfc13e2.tar.gz
2005-06-29 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/22131 * include/bits/locale_facets.tcc (num_get<>::_M_extract_int, num_get<>::_M_extract_float, money_get<>::_M_extract): Adjust to assign the result also when digit grouping is wrong (but the grammar is correct), as per 22.2.2.1.2, p11-12 (NB: consistently for money_get too). * config/locale/generic/c_locale.cc (__convert_from_v): Do not check ios_base::failbit at the outset. * config/locale/gnu/c_locale.cc: Likewise. * testsuite/22_locale/money_get/get/char/22131.cc: New. * testsuite/22_locale/money_get/get/wchar_t/22131.cc: Likewise. * testsuite/22_locale/num_get/get/char/22131.cc: Likewise. * testsuite/22_locale/num_get/get/wchar_t/22131.cc: Likewise. * testsuite/22_locale/num_get/get/char/12.cc: Adjust. * testsuite/22_locale/num_get/get/wchar_t/12.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101416 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/config/locale')
-rw-r--r--libstdc++-v3/config/locale/generic/c_locale.cc117
-rw-r--r--libstdc++-v3/config/locale/gnu/c_locale.cc54
2 files changed, 77 insertions, 94 deletions
diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc
index 4a940ee8e5b..eee8e067cd3 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -1,6 +1,7 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -50,39 +51,36 @@ namespace std
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale&)
{
- if (!(__err & ios_base::failbit))
- {
- // Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
- setlocale(LC_ALL, "C");
- char* __sanity;
- errno = 0;
+ // Assumes __s formatted for "C" locale.
+ errno = 0;
+ char* __old = strdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
+ char* __sanity;
#if defined(_GLIBCXX_HAVE_STRTOF)
- float __f = strtof(__s, &__sanity);
+ float __f = strtof(__s, &__sanity);
#else
- double __d = strtod(__s, &__sanity);
- float __f = static_cast<float>(__d);
+ double __d = strtod(__s, &__sanity);
+ float __f = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
- if (!finitef (__f))
- errno = ERANGE;
+ if (!finitef (__f))
+ errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_FINITE)
- if (!finite (static_cast<double> (__f)))
- errno = ERANGE;
+ if (!finite (static_cast<double> (__f)))
+ errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_ISINF)
- if (isinf (static_cast<double> (__f)))
- errno = ERANGE;
+ if (isinf (static_cast<double> (__f)))
+ errno = ERANGE;
#else
- if (fabs(__d) > numeric_limits<float>::max())
- errno = ERANGE;
+ if (fabs(__d) > numeric_limits<float>::max())
+ errno = ERANGE;
#endif
#endif
- if (__sanity != __s && errno != ERANGE)
- __v = __f;
- else
- __err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
- }
+ if (__sanity != __s && errno != ERANGE)
+ __v = __f;
+ else
+ __err |= ios_base::failbit;
+ setlocale(LC_ALL, __old);
+ free(__old);
}
template<>
@@ -90,21 +88,18 @@ namespace std
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale&)
{
- if (!(__err & ios_base::failbit))
- {
- // Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
- setlocale(LC_ALL, "C");
- char* __sanity;
- errno = 0;
- double __d = strtod(__s, &__sanity);
- if (__sanity != __s && errno != ERANGE)
- __v = __d;
- else
- __err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
- }
+ // Assumes __s formatted for "C" locale.
+ errno = 0;
+ char* __old = strdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
+ char* __sanity;
+ double __d = strtod(__s, &__sanity);
+ if (__sanity != __s && errno != ERANGE)
+ __v = __d;
+ else
+ __err |= ios_base::failbit;
+ setlocale(LC_ALL, __old);
+ free(__old);
}
template<>
@@ -112,31 +107,27 @@ namespace std
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&)
{
- if (!(__err & ios_base::failbit))
- {
- // Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
- setlocale(LC_ALL, "C");
+ // Assumes __s formatted for "C" locale.
+ errno = 0;
+ char* __old = strdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
#if defined(_GLIBCXX_HAVE_STRTOLD)
- char* __sanity;
- errno = 0;
- long double __ld = strtold(__s, &__sanity);
- if (__sanity != __s && errno != ERANGE)
- __v = __ld;
+ char* __sanity;
+ long double __ld = strtold(__s, &__sanity);
+ if (__sanity != __s && errno != ERANGE)
+ __v = __ld;
#else
- typedef char_traits<char>::int_type int_type;
- long double __ld;
- errno = 0;
- int __p = sscanf(__s, "%Lf", &__ld);
- if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
- && errno != ERANGE)
- __v = __ld;
+ typedef char_traits<char>::int_type int_type;
+ long double __ld;
+ int __p = sscanf(__s, "%Lf", &__ld);
+ if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
+ && errno != ERANGE)
+ __v = __ld;
#endif
- else
- __err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
- }
+ else
+ __err |= ios_base::failbit;
+ setlocale(LC_ALL, __old);
+ free(__old);
}
void
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc
index bf975b98bac..c83aa56f6ea 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.cc
+++ b/libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -1,6 +1,7 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -46,16 +47,13 @@ namespace std
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
- if (!(__err & ios_base::failbit))
- {
- char* __sanity;
- errno = 0;
- float __f = __strtof_l(__s, &__sanity, __cloc);
- if (__sanity != __s && errno != ERANGE)
- __v = __f;
- else
- __err |= ios_base::failbit;
- }
+ char* __sanity;
+ errno = 0;
+ float __f = __strtof_l(__s, &__sanity, __cloc);
+ if (__sanity != __s && errno != ERANGE)
+ __v = __f;
+ else
+ __err |= ios_base::failbit;
}
template<>
@@ -63,16 +61,13 @@ namespace std
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
- if (!(__err & ios_base::failbit))
- {
- char* __sanity;
- errno = 0;
- double __d = __strtod_l(__s, &__sanity, __cloc);
- if (__sanity != __s && errno != ERANGE)
- __v = __d;
- else
- __err |= ios_base::failbit;
- }
+ char* __sanity;
+ errno = 0;
+ double __d = __strtod_l(__s, &__sanity, __cloc);
+ if (__sanity != __s && errno != ERANGE)
+ __v = __d;
+ else
+ __err |= ios_base::failbit;
}
template<>
@@ -80,16 +75,13 @@ namespace std
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
- if (!(__err & ios_base::failbit))
- {
- char* __sanity;
- errno = 0;
- long double __ld = __strtold_l(__s, &__sanity, __cloc);
- if (__sanity != __s && errno != ERANGE)
- __v = __ld;
- else
- __err |= ios_base::failbit;
- }
+ char* __sanity;
+ errno = 0;
+ long double __ld = __strtold_l(__s, &__sanity, __cloc);
+ if (__sanity != __s && errno != ERANGE)
+ __v = __ld;
+ else
+ __err |= ios_base::failbit;
}
void