summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-03-08 10:51:30 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-03-08 10:51:30 +0000
commitf1c89270e5d53efe52a6ee176a86224d60043047 (patch)
tree191b993bd45f2d350674a5b95c66bef1b4efed0b /libstdc++-v3
parentd50a16c4335e68f36982ab6e2de8744d6bcd101d (diff)
downloadgcc-f1c89270e5d53efe52a6ee176a86224d60043047.tar.gz
locale_facets.tcc (money_get<>::_M_extract): The value _space_ indicates that at least one space is required at that position.
2004-03-08 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (money_get<>::_M_extract): The value _space_ indicates that at least one space is required at that position. * testsuite/22_locale/money_get/get/char/17.cc: New. * testsuite/22_locale/money_get/get/wchar_t/17.cc: New. * testsuite/22_locale/money_get/get/char/7.cc: Minor tweaks. * testsuite/22_locale/money_get/get/wchar_t/7.cc: Likewise. * include/bits/locale_facets.tcc (money_get<>::do_get(long_double&)): Remove redundant conditional on __str.size(). From-SVN: r79111
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc10
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc71
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc13
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/17.cc71
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc13
6 files changed, 178 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ae22e7c8cfc..b105ada1a2a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2004-03-08 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/locale_facets.tcc (money_get<>::_M_extract):
+ The value _space_ indicates that at least one space is required
+ at that position.
+ * testsuite/22_locale/money_get/get/char/17.cc: New.
+ * testsuite/22_locale/money_get/get/wchar_t/17.cc: New.
+
+ * testsuite/22_locale/money_get/get/char/7.cc: Minor tweaks.
+ * testsuite/22_locale/money_get/get/wchar_t/7.cc: Likewise.
+
+ * include/bits/locale_facets.tcc (money_get<>::do_get(long_double&)):
+ Remove redundant conditional on __str.size().
+
2004-03-08 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/allocator.h: Switch defaults to mt_alloc.
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index fe4bec0beea..45913178d42 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -1293,6 +1293,11 @@ namespace std
__testvalid = false;
break;
case money_base::space:
+ // At least one space is required.
+ if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
+ ++__beg;
+ else
+ __testvalid = false;
case money_base::none:
// Only if not at the end of the pattern.
if (__i != 3)
@@ -1372,10 +1377,7 @@ namespace std
__beg = _M_extract<true>(__beg, __end, __io, __err, __str);
else
__beg = _M_extract<false>(__beg, __end, __io, __err, __str);
-
- if (__str.size())
- std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
-
+ std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
return __beg;
}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc
new file mode 100644
index 00000000000..5216b414aae
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc
@@ -0,0 +1,71 @@
+// 2004-03-08 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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.6.1.1 money_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// 22.2.6.3, p2: "The value _space_ indicates that at least one space
+// is required at that position."
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
+ VERIFY( loc_c != loc_de );
+
+ iterator_type end, end02;
+ istringstream iss;
+ iss.imbue(loc_de);
+ // cache the money_get facet
+ const money_get<char>& mon_get =
+ use_facet<money_get<char> >(iss.getloc());
+
+ iss.str("7.200.000.000,00");
+ iterator_type is_it01(iss);
+ string result1;
+ ios_base::iostate err01 = ios_base::goodbit;
+ mon_get.get(is_it01, end, true, iss, err01, result1);
+ VERIFY( err01 == (ios_base::failbit | ios_base::eofbit) );
+
+ // now try with showbase, to get currency symbol in format
+ iss.setf(ios_base::showbase);
+
+ iss.str("7.200.000.000,00EUR ");
+ iterator_type is_it02(iss);
+ string result2;
+ ios_base::iostate err02 = ios_base::goodbit;
+ end02 = mon_get.get(is_it02, end, true, iss, err02, result2);
+ VERIFY( err02 == ios_base::failbit );
+ VERIFY( *end02 == 'E' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc
index c21a9dfad74..d3d5bfe25da 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc
@@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -44,22 +44,25 @@ void test07()
ios_base::iostate err;
- const money_get<char,InIt>& mg = use_facet<money_get<char, InIt> >(loc_c);
+ const money_get<char, InIt>& mg = use_facet<money_get<char, InIt> >(loc_c);
istringstream fmt1(buffer1);
+ fmt1.imbue(loc_c);
InIt ibeg1(fmt1);
- mg.get(ibeg1,iend1,false,fmt1,err,val);
+ mg.get(ibeg1, iend1, false, fmt1, err, val);
VERIFY( val == buffer1 );
istringstream fmt2(buffer2);
+ fmt2.imbue(loc_c);
InIt ibeg2(fmt2);
- mg.get(ibeg2,iend2,false,fmt2,err,val);
+ mg.get(ibeg2, iend2, false, fmt2, err, val);
VERIFY( val == buffer2 );
val = buffer3;
istringstream fmt3(buffer3);
+ fmt3.imbue(loc_c);
InIt ibeg3(fmt3);
- mg.get(ibeg3,iend3,false,fmt3,err,val);
+ mg.get(ibeg3, iend3, false, fmt3, err, val);
VERIFY( val == buffer3 );
}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/17.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/17.cc
new file mode 100644
index 00000000000..e8affd81bb8
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/17.cc
@@ -0,0 +1,71 @@
+// 2004-03-08 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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.6.1.1 money_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// 22.2.6.3, p2: "The value _space_ indicates that at least one space
+// is required at that position."
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
+ VERIFY( loc_c != loc_de );
+
+ iterator_type end, end02;
+ wistringstream iss;
+ iss.imbue(loc_de);
+ // cache the money_get facet
+ const money_get<wchar_t>& mon_get =
+ use_facet<money_get<wchar_t> >(iss.getloc());
+
+ iss.str(L"7.200.000.000,00");
+ iterator_type is_it01(iss);
+ wstring result1;
+ ios_base::iostate err01 = ios_base::goodbit;
+ mon_get.get(is_it01, end, true, iss, err01, result1);
+ VERIFY( err01 == (ios_base::failbit | ios_base::eofbit) );
+
+ // now try with showbase, to get currency symbol in format
+ iss.setf(ios_base::showbase);
+
+ iss.str(L"7.200.000.000,00EUR ");
+ iterator_type is_it02(iss);
+ wstring result2;
+ ios_base::iostate err02 = ios_base::goodbit;
+ end02 = mon_get.get(is_it02, end, true, iss, err02, result2);
+ VERIFY( err02 == ios_base::failbit );
+ VERIFY( *end02 == L'E' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc
index c9cf0662e25..f7f3ae1d992 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc
@@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -44,22 +44,25 @@ void test07()
ios_base::iostate err;
- const money_get<wchar_t,InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c);
+ const money_get<wchar_t, InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c);
wistringstream fmt1(buffer1);
+ fmt1.imbue(loc_c);
InIt ibeg1(fmt1);
- mg.get(ibeg1,iend1,false,fmt1,err,val);
+ mg.get(ibeg1, iend1, false, fmt1, err, val);
VERIFY( val == buffer1 );
wistringstream fmt2(buffer2);
+ fmt2.imbue(loc_c);
InIt ibeg2(fmt2);
- mg.get(ibeg2,iend2,false,fmt2,err,val);
+ mg.get(ibeg2, iend2, false, fmt2, err, val);
VERIFY( val == buffer2 );
val = buffer3;
wistringstream fmt3(buffer3);
+ fmt3.imbue(loc_c);
InIt ibeg3(fmt3);
- mg.get(ibeg3,iend3,false,fmt3,err,val);
+ mg.get(ibeg3, iend3, false, fmt3, err, val);
VERIFY( val == buffer3 );
}