mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-02 08:13:58 +08:00
re PR libstdc++/12971 (Resolution of DR 328 [WP] still unimplemented)
2003-11-09 Paolo Carlini <pcarlini@suse.de> PR libstdc++/12971 * include/bits/locale_facets.tcc (money_put::do_put(..., long double)): Fix conversion specification as per DR 328 [WP]. * testsuite/22_locale/money_put/put/char/12971.cc: Add. * testsuite/22_locale/money_put/put/wchar_t/12971.cc: Ditto. * docs/html/ext/howto.html: Add entry for DR 328. From-SVN: r73389
This commit is contained in:
parent
757dc040ce
commit
7c752655e6
@ -1,3 +1,13 @@
|
||||
2003-11-09 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/12971
|
||||
* include/bits/locale_facets.tcc
|
||||
(money_put::do_put(..., long double)): Fix conversion
|
||||
specification as per DR 328 [WP].
|
||||
* testsuite/22_locale/money_put/put/char/12971.cc: Add.
|
||||
* testsuite/22_locale/money_put/put/wchar_t/12971.cc: Ditto.
|
||||
* docs/html/ext/howto.html: Add entry for DR 328.
|
||||
|
||||
2003-11-08 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/12967
|
||||
|
@ -651,6 +651,12 @@
|
||||
</dt>
|
||||
<dd>If <code>(this == &x)</code> do nothing.
|
||||
</dd>
|
||||
|
||||
<dt><a href="lwg-defects.html#328">328</a>:
|
||||
<em>Bad sprintf format modifier in money_put<>::do_put()</em>
|
||||
</dt>
|
||||
<dd>Change the format string to "%.0Lf".
|
||||
</dd>
|
||||
<!--
|
||||
<dt><a href="lwg-defects.html#"></a>:
|
||||
<em></em>
|
||||
|
@ -175,7 +175,7 @@ namespace std
|
||||
const char_type __c = *__beg;
|
||||
const char_type* __p = __traits_type::find(__lit + _S_izero, 10,
|
||||
__c);
|
||||
// NB: strchr returns true for *__beg == 0x0
|
||||
// NB: strchr returns true for __c == 0x0
|
||||
if (__p && !__traits_type::eq(__c, char_type()))
|
||||
{
|
||||
// Try first for acceptable digit; record it if found.
|
||||
@ -1328,22 +1328,23 @@ namespace std
|
||||
// First try a buffer perhaps big enough.
|
||||
int __cs_size = 64;
|
||||
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
|
||||
int __len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 328. Bad sprintf format modifier in money_put<>::do_put()
|
||||
int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
|
||||
_S_get_c_locale());
|
||||
// If the buffer was not large enough, try again with the correct size.
|
||||
if (__len >= __cs_size)
|
||||
{
|
||||
__cs_size = __len + 1;
|
||||
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
|
||||
__len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
|
||||
__len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
|
||||
_S_get_c_locale());
|
||||
}
|
||||
#else
|
||||
// max_exponent10 + 1 for the integer part, + 4 for sign, decimal point,
|
||||
// decimal digit, '\0'.
|
||||
const int __cs_size = numeric_limits<long double>::max_exponent10 + 5;
|
||||
// max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
|
||||
const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
|
||||
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
|
||||
int __len = std::__convert_from_v(__cs, 0, "%.01Lf", __units,
|
||||
int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units,
|
||||
_S_get_c_locale());
|
||||
#endif
|
||||
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
|
||||
|
50
libstdc++-v3/testsuite/22_locale/money_put/put/char/12971.cc
Normal file
50
libstdc++-v3/testsuite/22_locale/money_put/put/char/12971.cc
Normal file
@ -0,0 +1,50 @@
|
||||
// 2003-11-09 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.6.2.1 money_put members
|
||||
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/12971
|
||||
void test01()
|
||||
{
|
||||
using namespace std;
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
typedef ostreambuf_iterator<char> iterator_type;
|
||||
|
||||
long double amount = 10.8L;
|
||||
|
||||
// cache the money_put facet
|
||||
ostringstream oss;
|
||||
const money_put<char>& mon_put = use_facet<money_put<char> >(oss.getloc());
|
||||
|
||||
iterator_type os_it01 = mon_put.put(oss.rdbuf(), true, oss, ' ', amount);
|
||||
string result = oss.str();
|
||||
VERIFY( result == "11" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
// 2003-11-09 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.6.2.1 money_put members
|
||||
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/12971
|
||||
void test01()
|
||||
{
|
||||
using namespace std;
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
typedef ostreambuf_iterator<wchar_t> iterator_type;
|
||||
|
||||
long double amount = 10.8L;
|
||||
|
||||
// cache the money_put facet
|
||||
wostringstream oss;
|
||||
const money_put<wchar_t>& mon_put = use_facet<money_put<wchar_t> >(oss.getloc());
|
||||
|
||||
iterator_type os_it01 = mon_put.put(oss.rdbuf(), true, oss, L' ', amount);
|
||||
wstring result = oss.str();
|
||||
VERIFY( result == L"11" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user