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] Another idea for 6015


Benjamin Kosnik wrote:

>>  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;
>>    }
>>
>First of all, I regard this as low-priority.
>
Ok.

>There has already been considerable work by this point to make sure that 
>the separator in __out is only "." regardless of locale being used. 
>
>I think undoing this is a mistake, or hacking __out so that '.' is 
>replaced by the separator expected by snprintf in it's locale is a 
>mistake, and no more thread safe than what we've currently got. (Perhaps 
>less.) 
>
Benjamin, my idea is the other way round, if I really understand you!
(honestly, I barely understand your point (perhaps because I don't know 
the history of all this)).

My idea is the following: /after/ snprintf has done its work, due to MT, 
it could be possible that __out has the wrong decimal point, that is 
/not "."/, as we expect. We expect the "C" decimal point.
Therefore, conditionalized to ("MT" && !glibc2.3) we look for the actual 
decimal point and we fix it to ".". This is thread-safe, completely.

What do you think?

Ciao,
P.


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