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
This commit is contained in:
parent
ed8d88031c
commit
1b4513069a
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
72
libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
Normal file
72
libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
Normal file
@ -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;
|
||||
}
|
65
libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
Normal file
65
libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
Normal file
@ -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;
|
||||
}
|
72
libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
Normal file
72
libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
Normal file
@ -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;
|
||||
}
|
65
libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
Normal file
65
libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
Normal file
@ -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;
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user