Chris Cannam wrote:
>
> On Saturday 12 Feb 2005 11:47, Pedro Lopez-Cabanillas wrote:
>> When RG GUI is initialized, it has already POSIX or C locale, so the
>> workaround proposed by William doesn't help. When NoteFontMap()
>> constructor is reached, the program has changed to es_ES locale. But
>> there isn't a single call to setLocale() in RG code.
> 
> Perhaps, since we always want to use '.' as decimal point when reading 
> from our own XML files, we ought in any case to be avoiding a function 
> whose interpretation might depend on the locale.
> 
> Since we don't care about exponents or bases or anything much else here, 
> we can easily throw in a crappy reimplementation of atof to do the work 
> here, and perhaps we should do that anyway.  Unless you can suggest an 
> alternative library function that's guaranteed to be i18n-free.

Rather than writing conversion functions completely from scratch,
it should be possible to write a simple locale-independent wrapper function
for each of strtod(), atoi() and atof(), e.g.

   double
   RosegardenString::atof(char *str)
   {
      char *saved_locale = setlocale(LC_NUMERIC, NULL);
      if (saved_locale) {
          saved_locale = strdup(saved_locale);
          setlocale(LC_NUMERIC, "C");
      }
      double value = atof(str, NULL);
      ...
      if (saved_locale) {
          setlocale(LC_NUMERIC, saved_locale);
          free(saved_locale);
      }
      return value;
   }

A rough call count (some of these may not actually matter):
   185 toInt() (different separators for 1000s in different locales)
    27 atoi()
    18 toDouble()
    10 toFloat()
     1 atof()

>> The big question remains. Why should it differ between cvs-01/19 and
>> 02/09? Research continues.
> 
> Of course, I'd still like to know this.

So would I.

William


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to