c_locale.h (__convert_from_v): Don't use a default for __prec, assume __prec >= 0 and simplify.
2004-08-07 Paolo Carlini <pcarlini@suse.de> * config/locale/generic/c_locale.h (__convert_from_v): Don't use a default for __prec, assume __prec >= 0 and simplify. * config/locale/gnu/c_locale.h (__convert_from_v): Likewise. * include/bits/locale_facets.tcc (money_put<>::do_put(long double)): Pass format "%.*Lf" + precision == 0, equivalent to "%.0Lf". From-SVN: r85669
This commit is contained in:
parent
cbf8a6ab5d
commit
49864a8255
@ -1,3 +1,11 @@
|
||||
2004-08-07 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* config/locale/generic/c_locale.h (__convert_from_v): Don't
|
||||
use a default for __prec, assume __prec >= 0 and simplify.
|
||||
* config/locale/gnu/c_locale.h (__convert_from_v): Likewise.
|
||||
* include/bits/locale_facets.tcc (money_put<>::do_put(long double)):
|
||||
Pass format "%.*Lf" + precision == 0, equivalent to "%.0Lf".
|
||||
|
||||
2004-08-04 Phil Edwards <phil@codesourcery.com>
|
||||
|
||||
* docs/html/configopts.html: Emphasize that options change.
|
||||
|
@ -57,24 +57,17 @@ namespace std
|
||||
__convert_from_v(char* __out,
|
||||
const int __size __attribute__((__unused__)),
|
||||
const char* __fmt,
|
||||
_Tv __v, const __c_locale&, int __prec = -1)
|
||||
_Tv __v, const __c_locale&, int __prec)
|
||||
{
|
||||
char* __old = std::setlocale(LC_ALL, NULL);
|
||||
char* __sav = new char[std::strlen(__old) + 1];
|
||||
std::strcpy(__sav, __old);
|
||||
std::setlocale(LC_ALL, "C");
|
||||
|
||||
int __ret;
|
||||
#ifdef _GLIBCXX_USE_C99
|
||||
if (__prec >= 0)
|
||||
__ret = std::snprintf(__out, __size, __fmt, __prec, __v);
|
||||
else
|
||||
__ret = std::snprintf(__out, __size, __fmt, __v);
|
||||
const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
|
||||
#else
|
||||
if (__prec >= 0)
|
||||
__ret = std::sprintf(__out, __fmt, __prec, __v);
|
||||
else
|
||||
__ret = std::sprintf(__out, __fmt, __v);
|
||||
const int __ret = std::sprintf(__out, __fmt, __prec, __v);
|
||||
#endif
|
||||
std::setlocale(LC_ALL, __sav);
|
||||
delete [] __sav;
|
||||
|
@ -68,11 +68,11 @@ namespace std
|
||||
int
|
||||
__convert_from_v(char* __out, const int __size, const char* __fmt,
|
||||
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
|
||||
_Tv __v, const __c_locale& __cloc, int __prec = -1)
|
||||
_Tv __v, const __c_locale& __cloc, int __prec)
|
||||
{
|
||||
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
|
||||
#else
|
||||
_Tv __v, const __c_locale&, int __prec = -1)
|
||||
_Tv __v, const __c_locale&, int __prec)
|
||||
{
|
||||
char* __old = std::setlocale(LC_ALL, NULL);
|
||||
char* __sav = new char[std::strlen(__old) + 1];
|
||||
@ -80,17 +80,10 @@ namespace std
|
||||
std::setlocale(LC_ALL, "C");
|
||||
#endif
|
||||
|
||||
int __ret;
|
||||
#ifdef _GLIBCXX_USE_C99
|
||||
if (__prec >= 0)
|
||||
__ret = std::snprintf(__out, __size, __fmt, __prec, __v);
|
||||
else
|
||||
__ret = std::snprintf(__out, __size, __fmt, __v);
|
||||
const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
|
||||
#else
|
||||
if (__prec >= 0)
|
||||
__ret = std::sprintf(__out, __fmt, __prec, __v);
|
||||
else
|
||||
__ret = std::sprintf(__out, __fmt, __v);
|
||||
const int __ret = std::sprintf(__out, __fmt, __prec, __v);
|
||||
#endif
|
||||
|
||||
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
|
||||
|
@ -1689,22 +1689,22 @@ namespace std
|
||||
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
|
||||
// _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());
|
||||
int __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units,
|
||||
_S_get_c_locale(), 0);
|
||||
// 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, "%.0Lf", __units,
|
||||
_S_get_c_locale());
|
||||
__len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units,
|
||||
_S_get_c_locale(), 0);
|
||||
}
|
||||
#else
|
||||
// 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, "%.0Lf", __units,
|
||||
_S_get_c_locale());
|
||||
int __len = std::__convert_from_v(__cs, 0, "%.*Lf", __units,
|
||||
_S_get_c_locale(), 0);
|
||||
#endif
|
||||
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
|
||||
* __cs_size));
|
||||
|
Loading…
Reference in New Issue
Block a user