iostream changes locale to format a number
Stephen M.Webb
stephenw@cryptocard.com
Fri May 3 06:11:00 GMT 2002
On May 3, 2002 08:30 am, Paolo Carlini wrote:
> Paolo Carlini wrote:
> > Are you willing to contribute a patch against the current mainline
> > libstdc++-v3 sources for public discussion (that setlocale ...
> > setlocale pattern is present in quite a few different places) ?
>
> Let me point out, however, that, assuming your analysis is correct (I
> believe is) the solution cannot be as simple as you seems to assume:
> the string returned by the first setlocale must be saved!
That's not correct. The first call with an empty string will set the
global locale object to that of the operating environment (eg. the
value of the LC_ALL environment variable in a POSIX environment).
The remaining calls, with a NULL locale value, are simply queries.
The problem described is that writing a numeric value to a standard
IOStream will alter the global POSIX locale. The fix would be for the
IOStreams that set the POSIX locale to save and restore the existing
values instead of treading all over user data.
I can't spot anywhere in the trunk code where this is done
improperly. I'll set up a test case and see if (a) it's still
happening and (b) isolate the cause.
--
Stephen M. Webb
More information about the Libstdc++
mailing list