imlib and language (was: pixmaps and LANG..)




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.

ObRetrocomputing:
I once found a similar error in the SCO C compiler. They used fprintf
in the C compiler to write floating point constant into the assembler
file. The assembler didn't use fscanf to read the file, but a hand
written parser. Of course the programs were written by english
speaking people, but the whole system supported locales (even it was
~10 years ago). Now it happened that i wrote one of the rare programs
using floating point values. double f = 199.50 was converted to
.float 1,995e+3  by the C compielr and written in the assembler
file. The assembler happily parsed this to a value of 1. This had some 
strange effect on the program (it was a DVI converter to a dot matrix
printer). So using a LANG setting other then en_... during compiling
software under SCO unix was a bad thing to do. Nobody at SCO could
reproduce this bug (you know why? :-)

--
Michael Lausch/g.a.m.s. edv dienstleistungen gmbh
See my web page <http://www.gams.net/~mla> 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]