summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-05 18:23:39 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-05 18:23:39 +0000
commit299bbd0d2f006d39b387dc6887e64331248372cb (patch)
tree0e60e96ae364a94b0ae3e40ab4d61a9023b3b565 /libstdc++-v3
parente7dac3cb677448f7a7e3acea3b73846b7f0fe7eb (diff)
downloadgcc-299bbd0d2f006d39b387dc6887e64331248372cb.tar.gz
2008-12-05 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/38399 * include/bits/locale_facets_nonio.tcc (money_get<>:: _M_extract(iter_type, iter_type, ios_base&, ios_base::iostate&, string&)): Fix, reject decimal point when frac_digits <= 0. * testsuite/22_locale/money_get/get/char/38399.cc: New. * testsuite/22_locale/money_get/get/wchar_t/38399.cc: Likewise. * testsuite/22_locale/money_get/get/char/5.cc: Adjust. * testsuite/22_locale/money_get/get/wchar_t/5.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142487 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog11
-rw-r--r--libstdc++-v3/include/bits/locale_facets_nonio.tcc10
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc55
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc5
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/38399.cc55
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/5.cc5
6 files changed, 133 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f2820d92e66..d9023b8232f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,16 @@
2008-12-05 Paolo Carlini <paolo.carlini@oracle.com>
+ PR libstdc++/38399
+ * include/bits/locale_facets_nonio.tcc (money_get<>::
+ _M_extract(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ string&)): Fix, reject decimal point when frac_digits <= 0.
+ * testsuite/22_locale/money_get/get/char/38399.cc: New.
+ * testsuite/22_locale/money_get/get/wchar_t/38399.cc: Likewise.
+ * testsuite/22_locale/money_get/get/char/5.cc: Adjust.
+ * testsuite/22_locale/money_get/get/wchar_t/5.cc: Likewise.
+
+2008-12-05 Paolo Carlini <paolo.carlini@oracle.com>
+
PR libstdc++/38411
* testsuite/22_locale/numpunct/members/char/2.cc: Use is_IS instead
of fr_FR.
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1c569ba5bd0..ba75d3a01bf 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
@@ -229,6 +229,9 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
else if (__c == __lc->_M_decimal_point
&& !__testdecfound)
{
+ if (__lc->_M_frac_digits <= 0)
+ break;
+
__last_pos = __n;
__n = 0;
__testdecfound = true;
@@ -311,11 +314,10 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
}
// Iff not enough digits were supplied after the decimal-point.
- if (__testdecfound && __lc->_M_frac_digits > 0
- && __n != __lc->_M_frac_digits)
+ if (__testdecfound && __n != __lc->_M_frac_digits)
__testvalid = false;
}
-
+
// Iff valid sequence is not recognized.
if (!__testvalid)
__err |= ios_base::failbit;
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc
new file mode 100644
index 00000000000..3283f34c1f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/38399.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 22.2.6.1.1 money_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+class my_moneypunct : public std::moneypunct<char>
+{
+protected:
+ //this should disable fraction part of monetary value
+ int do_frac_digits() const { return 0; }
+};
+
+// libstdc++/38399
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale(), new my_moneypunct());
+ stringstream ss("123.455");
+ ss.imbue(loc);
+ string digits;
+ ios_base::iostate err;
+ istreambuf_iterator<char> iter =
+ use_facet<money_get<char> >(loc).get(ss, 0, false, ss, err, digits);
+
+ string rest = string(iter, istreambuf_iterator<char>());
+ VERIFY( digits == "123" );
+ VERIFY( rest == ".455" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc
index b1d735b6211..9c6cb1d58ed 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc
@@ -1,6 +1,7 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -36,7 +37,7 @@ void test05()
const ios_base::iostate goodbit = ios_base::goodbit;
ios_base::iostate err = goodbit;
const locale loc_c = locale::classic();
- const string str = "0.01Eleanor Roosevelt";
+ const string str = "1Eleanor Roosevelt";
istringstream iss;
iss.imbue(locale(loc_c, new mon_get_type));
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/38399.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/38399.cc
new file mode 100644
index 00000000000..bca8ab0bd6d
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/38399.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 22.2.6.1.1 money_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+class my_moneypunct : public std::moneypunct<wchar_t>
+{
+protected:
+ //this should disable fraction part of monetary value
+ int do_frac_digits() const { return 0; }
+};
+
+// libstdc++/38399
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale(), new my_moneypunct());
+ wstringstream ss(L"123.455");
+ ss.imbue(loc);
+ wstring digits;
+ ios_base::iostate err;
+ istreambuf_iterator<wchar_t> iter =
+ use_facet<money_get<wchar_t> >(loc).get(ss, 0, false, ss, err, digits);
+
+ wstring rest = wstring(iter, istreambuf_iterator<wchar_t>());
+ VERIFY( digits == L"123" );
+ VERIFY( rest == L".455" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/5.cc
index 70c3cec01cf..afbd1ec1a23 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/5.cc
@@ -1,6 +1,7 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -36,7 +37,7 @@ void test05()
const ios_base::iostate goodbit = ios_base::goodbit;
ios_base::iostate err = goodbit;
const locale loc_c = locale::classic();
- const wstring str = L"0.01Eleanor Roosevelt";
+ const wstring str = L"1Eleanor Roosevelt";
wistringstream iss;
iss.imbue(locale(loc_c, new mon_get_type));