aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2003-12-19 09:35:24 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2003-12-19 09:35:24 +0000
commit1b4513069a1ba56abff09f27977da3d10ffcd7f3 (patch)
tree85a14266411b4a664f0e48d4aec9dde4fee5d49f /libstdc++-v3
parented8d88031c395a0029393904e44afe077d7a5b93 (diff)
downloadgcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.zip
gcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.tar.gz
gcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.tar.bz2
locale_facets.tcc (num_get::_M_extract_float): When __found_sci becomes true stop eating thousands separators and the decimal...
2003-12-19 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (num_get::_M_extract_float): When __found_sci becomes true stop eating thousands separators and the decimal radix separator. * testsuite/22_locale/num_get/get/char/9.cc: New. * testsuite/22_locale/num_get/get/wchar_t/9.cc: Likewise. * config/locale/generic/c_locale.cc (__convert_to_v): Don't check that *__sanity == '\0': parsing may stop earlier, still be successful. * config/locale/gnu/c_locale.cc: Likewise. * testsuite/22_locale/num_get/get/char/10.cc: New. * testsuite/22_locale/num_get/get/wchar_t/10.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc: Tweak in one place accordingly. * testsuite/22_locale/money_get/get/char/1.cc: Fix typo. * testsuite/22_locale/money_get/get/wchar_t/1.cc: Likewise. From-SVN: r74826
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog20
-rw-r--r--libstdc++-v3/config/locale/generic/c_locale.cc6
-rw-r--r--libstdc++-v3/config/locale/gnu/c_locale.cc6
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc7
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc72
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc65
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc72
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc6
11 files changed, 309 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index faba7f1..441ed54 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,23 @@
+2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/locale_facets.tcc (num_get::_M_extract_float):
+ When __found_sci becomes true stop eating thousands separators
+ and the decimal radix separator.
+ * testsuite/22_locale/num_get/get/char/9.cc: New.
+ * testsuite/22_locale/num_get/get/wchar_t/9.cc: Likewise.
+
+ * config/locale/generic/c_locale.cc (__convert_to_v): Don't
+ check that *__sanity == '\0': parsing may stop earlier, still
+ be successful.
+ * config/locale/gnu/c_locale.cc: Likewise.
+ * testsuite/22_locale/num_get/get/char/10.cc: New.
+ * testsuite/22_locale/num_get/get/wchar_t/10.cc: Likewise.
+ * testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc:
+ Tweak in one place accordingly.
+
+ * testsuite/22_locale/money_get/get/char/1.cc: Fix typo.
+ * testsuite/22_locale/money_get/get/wchar_t/1.cc: Likewise.
+
2003-12-18 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_list.h: Formatting tweaks.
diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc
index 92b01c2..a214e00 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -76,7 +76,7 @@ namespace std
errno = ERANGE;
#endif
#endif
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __f;
else
__err |= ios_base::failbit;
@@ -98,7 +98,7 @@ namespace std
char* __sanity;
errno = 0;
double __d = strtod(__s, &__sanity);
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __d;
else
__err |= ios_base::failbit;
@@ -121,7 +121,7 @@ namespace std
char* __sanity;
errno = 0;
long double __ld = strtold(__s, &__sanity);
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __ld;
#else
typedef char_traits<char>::int_type int_type;
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc
index 2dc6d73..b808f70 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.cc
+++ b/libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -51,7 +51,7 @@ namespace std
char* __sanity;
errno = 0;
float __f = __strtof_l(__s, &__sanity, __cloc);
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __f;
else
__err |= ios_base::failbit;
@@ -68,7 +68,7 @@ namespace std
char* __sanity;
errno = 0;
double __d = __strtod_l(__s, &__sanity, __cloc);
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __d;
else
__err |= ios_base::failbit;
@@ -85,7 +85,7 @@ namespace std
char* __sanity;
errno = 0;
long double __ld = __strtold_l(__s, &__sanity, __cloc);
- if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
+ if (__sanity != __s && errno != ERANGE)
__v = __ld;
else
__err |= ios_base::failbit;
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index f6240d11..8f79d9e 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -183,8 +183,9 @@ namespace std
++__sep_pos;
++__beg;
}
- else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
- && __lc->_M_use_grouping && !__found_dec)
+ else if (__lc->_M_use_grouping
+ && __traits_type::eq(__c, __lc->_M_thousands_sep)
+ && !__found_dec && !__found_sci)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
@@ -201,7 +202,7 @@ namespace std
}
}
else if (__traits_type::eq(__c, __lc->_M_decimal_point)
- && !__found_dec)
+ && !__found_dec && !__found_sci)
{
// According to the standard, if no grouping chars are seen,
// no grouping check is applied. Therefore __found_grouping
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc
index 39dca1d..fd2c1e5 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc
@@ -100,7 +100,7 @@ void test01()
ios_base::iostate err04 = ios_base::goodbit;
mon_get.get(is_it04, end, true, iss, err04, result4);
VERIFY( result4 == empty );
- VERIFY( err04 == ios_base::failbit | ios_base::eofbit );
+ VERIFY( err04 == (ios_base::failbit | ios_base::eofbit) );
iss.str("working for enlightenment and peace in a mad world");
iterator_type is_it05(iss);
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc
index 0a7f90b..a895072 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc
@@ -100,7 +100,7 @@ void test01()
ios_base::iostate err04 = ios_base::goodbit;
mon_get.get(is_it04, end, true, iss, err04, result4);
VERIFY( result4 == empty );
- VERIFY( err04 == ios_base::failbit | ios_base::eofbit );
+ VERIFY( err04 == (ios_base::failbit | ios_base::eofbit) );
iss.str(L"working for enlightenment and peace in a mad world");
iterator_type is_it05(iss);
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
new file mode 100644
index 0000000..259dea9
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
@@ -0,0 +1,72 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.2.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ istringstream iss;
+ const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ float f = 0.0f;
+ double d = 0.0;
+ long double ld = 0.0l;
+ float f1 = 1.0f;
+ double d1 = 3.0;
+ long double ld1 = 6.0l;
+
+ iss.str("1e.");
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, f);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == '.' );
+ VERIFY( f == f1 );
+
+ iss.str("3e+");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d1 );
+
+ iss.str("6e ");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, ld);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == ' ' );
+ VERIFY( ld == ld1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
new file mode 100644
index 0000000..5934b61
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
@@ -0,0 +1,65 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.2.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ istringstream iss;
+ iss.imbue(loc_de);
+
+ const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ double d = 0.0;
+ double d1 = 1e1;
+ double d2 = 3e1;
+
+ iss.str("1e1,");
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == ',' );
+ VERIFY( d == d1 );
+
+ iss.str("3e1.");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == '.' );
+ VERIFY( d == d2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
new file mode 100644
index 0000000..85fa574
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
@@ -0,0 +1,72 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.2.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ wistringstream iss;
+ const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ float f = 0.0f;
+ double d = 0.0;
+ long double ld = 0.0l;
+ float f1 = 1.0f;
+ double d1 = 3.0;
+ long double ld1 = 6.0l;
+
+ iss.str(L"1e.");
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, f);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L'.' );
+ VERIFY( f == f1 );
+
+ iss.str(L"3e+");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d1 );
+
+ iss.str(L"6e ");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, ld);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L' ' );
+ VERIFY( ld == ld1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
new file mode 100644
index 0000000..df3db53
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
@@ -0,0 +1,65 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.2.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ wistringstream iss;
+ iss.imbue(loc_de);
+
+ const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ double d = 0.0;
+ double d1 = 1e1;
+ double d2 = 3e1;
+
+ iss.str(L"1e1,");
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L',' );
+ VERIFY( d == d1 );
+
+ iss.str(L"3e1.");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L'.' );
+ VERIFY( d == d2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
index 5df68d5..08c39ee 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
@@ -127,13 +127,13 @@ bool test10() {
is_05 >> f;
VERIFY( f == 0 );
is_05 >> f;
- VERIFY( f == 0 );
- VERIFY( is_05.rdstate() == std::ios_base::failbit );
+ VERIFY( f == 5.0 );
+ VERIFY( is_05.rdstate() == std::ios_base::goodbit );
is_05.clear();
is_05 >> c;
VERIFY( c == 'a' );
is_05 >> f;
- VERIFY( f == 0 );
+ VERIFY( f == 5.0 );
VERIFY( is_05.rdstate() == std::ios_base::failbit );
is_05.clear();
is_05.ignore();