Commit 20da06ef by Paolo Carlini Committed by Paolo Carlini

locale_facets.tcc (money_put<>::_M_insert): Restructure formatting of value component...

2004-02-22  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.tcc (money_put<>::_M_insert):
	Restructure formatting of value component, first dealing with
	the non-decimal digits; use reserve.

2004-02-22  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.h (class money_get): Inherit
	from money_base too; tweak declaration of _M_extract, now
	parameterized on _Intl too.
	* include/bits/locale_facets.tcc (money_get<>::_M_extract):
	Update definition to use the cache; call reserve on __res to
	avoid multiple reallocations; fix parsing of sign component
	according to 22.2.6.1.2, p3.
	(money_get<>::do_get(long double&),
	money_get<>::do_get(string_type&)): Update calls of _M_extract.
	* src/locale-inst.cc:  Add instantiations of
	money_get::_M_extract<false> and money_get::_M_extract<true>.
	* testsuite/22_locale/money_get/get/char/14.cc: New.
	* testsuite/22_locale/money_get/get/wchar_t/14.cc: Ditto.

From-SVN: r78253
parent 5904e65f
2004-02-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (money_put<>::_M_insert):
Restructure formatting of value component, first dealing with
the non-decimal digits; use reserve.
2004-02-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.h (class money_get): Inherit
from money_base too; tweak declaration of _M_extract, now
parameterized on _Intl too.
* include/bits/locale_facets.tcc (money_get<>::_M_extract):
Update definition to use the cache; call reserve on __res to
avoid multiple reallocations; fix parsing of sign component
according to 22.2.6.1.2, p3.
(money_get<>::do_get(long double&),
money_get<>::do_get(string_type&)): Update calls of _M_extract.
* src/locale-inst.cc: Add instantiations of
money_get::_M_extract<false> and money_get::_M_extract<true>.
* testsuite/22_locale/money_get/get/char/14.cc: New.
* testsuite/22_locale/money_get/get/wchar_t/14.cc: Ditto.
2004-02-21 Mark Mitchell <mark@codesourcery.com>
* libsupc++/vterminate.cc
......@@ -180,13 +202,13 @@
2004-02-12 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/13731 (final part: writev)
* config/io/basic_file_stdio.cc (__gnu_internal::xwrite):
* config/io/basic_file_stdio.cc (__gnu_internal::xwritev):
New, a wrapper around writev() handling partial writes.
(__basic_file<char>::xwrite): Move to __gnu_internal and make
static.
(__basic_file<char>::xsputn): Update call.
(__basic_file<char>::xsputn_2): Likewise.
* config/io/basic_file_stdio.h (__basic_file<char>::write):
* config/io/basic_file_stdio.h (__basic_file<char>::xwrite):
Don't declare, now static.
2004-02-11 Stefan Olsson <stefan@xapa.se>
......
......@@ -4012,7 +4012,7 @@ namespace std
* the money_get facet.
*/
template<typename _CharT, typename _InIter>
class money_get : public locale::facet
class money_get : public locale::facet, public money_base
{
public:
// Types:
......@@ -4125,9 +4125,10 @@ namespace std
do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const;
iter_type
_M_extract(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const;
template<bool _Intl>
iter_type
_M_extract(iter_type __s, iter_type __end, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const;
};
template<typename _CharT, typename _InIter>
......
......@@ -51,6 +51,18 @@ namespace std
template class money_get<C, istreambuf_iterator<C> >;
template class money_put<C, ostreambuf_iterator<C> >;
template
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<true>(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&, string_type&) const;
template
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<false>(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&, string_type&) const;
template
ostreambuf_iterator<C>
money_put<C, ostreambuf_iterator<C> >::
_M_insert<true>(ostreambuf_iterator<C>, ios_base&, C,
......
// 2004-02-21 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>
struct My_money : public std::moneypunct<char, false>
{
std::string do_positive_sign() const { return "+"; }
std::string do_negative_sign() const { return ""; }
};
void test01()
{
using namespace std;
typedef istreambuf_iterator<char> InIt;
bool test __attribute__((unused)) = true;
locale loc(locale::classic(), new My_money);
string buffer("69");
InIt iend;
ios_base::iostate err;
string val;
const money_get<char, InIt>& mg =
use_facet<money_get<char, InIt> >(loc);
istringstream fmt(buffer);
fmt.imbue(loc);
InIt ibeg(fmt);
mg.get(ibeg, iend, false, fmt, err, val);
VERIFY( val == "-69" );
}
int main()
{
test01();
return 0;
}
// 2004-02-21 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>
struct My_money : public std::moneypunct<wchar_t, false>
{
std::wstring do_positive_sign() const { return L"+"; }
std::wstring do_negative_sign() const { return L""; }
};
void test01()
{
using namespace std;
typedef istreambuf_iterator<wchar_t> InIt;
bool test __attribute__((unused)) = true;
locale loc(locale::classic(), new My_money);
wstring buffer(L"69");
InIt iend;
ios_base::iostate err;
wstring val;
const money_get<wchar_t, InIt>& mg =
use_facet<money_get<wchar_t, InIt> >(loc);
wistringstream fmt(buffer);
fmt.imbue(loc);
InIt ibeg(fmt);
mg.get(ibeg, iend, false, fmt, err, val);
VERIFY( val == L"-69" );
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment