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:

>>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.
>>
>I thought that snprintf would fail due to the expected separator in the
>current locale differing from the "C" separator in __out, so that __v
>wouldn't even be valid. 
>
Benjamin, now perhaps I begin to understand your doubts... but I think 
we are safe!
Consider this:

#include <locale.h>
#include <stdio.h>

int main()
{
  setlocale(LC_ALL, "it_IT");

  printf("%g\n", 30.34);

  return 0;
}

The decimal point in Italy is ",", but this does /not/ fail! Quite to 
the contrary, it is only this way that it works well! It would /not/ 
work correctly this way:

#include <locale.h>
#include <stdio.h>

int main()
{
  setlocale(LC_ALL, "it_IT");

  printf("%g\n", 30,34);
                   ^
  return 0;        |____________
}

I this that worried you?
Benjamin I want your approval, I do not feel like working without your 
general approval of the approach.

>At this point, I'm not quite sure I understand you. The testsuites test 
>for this situation, so if you feel like you have a solution that would 
>work, I suggest you experiment, hack the code, and see if the testsuites 
>pass. If they do, let me know about what you've got.....
>
Sure.

>I remain convinced that the best solution is your first one.
>
The problem is that sadly Ulrich convincingly argued that in general is 
not at all easy...

Ciao,
Paolo.



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