Re: [gtk-list] imlib and language (was: pixmaps and LANG..)

On Fri, 28 Aug 1998, Michael Lausch wrote:

> I think i found a problem i the parsing of the ~/.imrc file. This
> problem applys to all programs which store and read floating point
> values to/from files.
> Floating point values are written using one of the printf functions
> and a format of %f, %g,... The format of the floating point number
> depends on the LANG variable. for english the floating point value is
> written in a format like 99999.999999 (see the point as the decimal
> marker). The whgole german countries are using a comma `,' as the
> decimal marker, therfore the number lokks like 99999,999999 if you
> choose a german locale. Now reading such a file with a different
> locale is a problem. Using any of scanf() or atof(), will misinterpret 
> the number. It doesn't give you problems with numbers like 1.0000000
> or 9.0000000 but it fails horrible with numbers like
> 0.999999999999. This number will be interpreted as `0' (zero) when you 
> try to convert it  to a numerical value and a german locale.
> now take a look into the ~/.imrc file reader and you will reckognize
> quite some places where atof() is used. Then take a look at the .imrc
> file and you'll find lines in the form `Brightness
> 0.980469'. Bingo. atof returns 0 for brightness if the locale choosen
> during reading the file is german.
> I don't have a solution handy which is clean and not a hack.

i came across the same problem last december or so when i converted the
gtkrc.c parsing code to use GScanner.
since then, glib provides g_strtod(), which tries to match the string
for the current locale and if that fails, it also tries to match the string
for the "C" numeric locale, then the best match is taken.

so, using g_strtod() instead of atof() in the imlib parsing code should fix
your problem.

> --
> Michael Lausch/g.a.m.s. edv dienstleistungen gmbh
> See my web page <> or query PGP key server for PGP key.
> "Reality is that which, when you stop believing in it, doesn't go away".
>                 -- Philip K. Dick


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]