This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] Another idea for 6015
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 04 Apr 2002 14:56:48 +0200
- Subject: Re: [RFC] Another idea for 6015
Hi again...
(unpolitely replying to myself ;-)
> After the call to snprintf, on MT systems indeed (all of this may be
> conditionalized to only (MT && !glibc2.3)), we have a c-string __out,
> which possibly may be formatted according to a locale /different/ from
> "C". Ok. What about "cleaning" it? Of course I have to study in detail
> the C-locale documentation, but it should be not that difficult: a scan
> right to left adjusting the decimal separator and removing any thousands
> separators (anything different from a number counts) should be 90% of
> the work...
Thinkink more about this... Is'nt really even easier?
From the C99 Standard, 7.11.1.1,1:
"LC_NUMERIC affects the decimal point character for the formatted
input-output functions..."
So!
No matter what another thread can do in-between
template<typename _Tv>
int
__convert_from_v(char* __out, const int __size, const char* __fmt,
_Tv __v, const __c_locale&, int __prec = -1)
{
int __ret;
const char* __old = setlocale(LC_ALL, "C");
if (__prec >= 0)
and
__ret = snprintf(__out, __size, __fmt, __prec, __v);
else
__ret = snprintf(__out, __size, __fmt, __v);
setlocale(LC_ALL, __old);
return __ret;
}
is'nt just a matter of adjusting to "." the decimal separator?
Ciao, Paolo.