This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] PR 6015: number formatting is not mt-safe


On Fri, Mar 22, 2002 at 11:38:22AM +0100, Paolo Carlini wrote:
> first blush (I'm not a MT expert) this PR seems sound. The current 
> __convert_from_v has the following structure (which may be found also 
> described on some glibc guidelines): save-current-locale; setlocale "C"; 
> sprintf; setlocale back .
> 
> Indeed this seems /not/ MT safe.
> 
> OTOH, I think the current standard is completely silent about MT issues.
> 
> What do you all think? Is this a pure QoI issue? Is there something we 
> can do about it?

Yes.  You are correct that it's not MT-safe.  One solution is to use
sprintf to produce one known format (probably %.17e), and treat all
those characters that are not ASCII digits just as delimiters, and 
then treat the result as a source of raw digits, rather than as a 
finished format.  (It isn't anyhow.)  Then you don't care what the 
current global locale is.

The main pitfall is that those might be multibyte characters, so you 
have to be prepared to skip over more than one before you get to the 
digits following.  Also, of course, it might not really be ASCII, 
but we can probably afford to discount that for now; MT safety is 
probably more important right now than portability to EBCDIC encoding 
environments.  

Nathan Myers
ncm at cantrip dot org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]