OSDN Git Service

2004-03-08 Paolo Carlini <pcarlini@suse.de>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Mar 2004 10:51:30 +0000 (10:51 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Mar 2004 10:51:30 +0000 (10:51 +0000)
* 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().

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79111 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/testsuite/22_locale/money_get/get/char/17.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/money_get/get/char/7.cc
libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/17.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc

index ae22e7c..b105ada 100644 (file)
@@ -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.
index fe4bec0..4591317 100644 (file)
@@ -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 (file)
index 0000000..5216b41
--- /dev/null
@@ -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;
+}
index c21a9df..d3d5bfe 100644 (file)
@@ -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 (file)
index 0000000..e8affd8
--- /dev/null
@@ -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;
+}
index c9cf066..f7f3ae1 100644 (file)
@@ -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 );
 }