From: Stefan J. <st...@gr...> - 2006-07-03 11:05:43
|
Am Mo, 3.07.2006, 10:05, schrieb Raimund 'Raimi' Jacob: > morning! hi there again, >> i just made up my mind about this topic. i would like to summarize: >> >> you have somehow set your locale to "de_DE.utf8", correct? thus the >> qucs program failed to read e.g "1.2e8" data, because it uses strtod() >> which expects "1,2e8" with this locale set? a solution was to >> >> setlocale (LC_NUMERIC, "C"); >> >> in the graph constructor. >> >> so far for the problem (and its kinda solution). >> >> first thing i don't understand is this: how does the program get this >> locale state? there is now statement in the program which >> >> setlocale (LC_ALL, "de_DE.utf8"); >> >> and with >> >> $ export LC_ALL=de_DE.utf8 >> >> I can't reproduce the problem. so how does this work? anyone an idea? > > the locale setting is a process-wide setting just like for example the > current working directory. i think you just hit one of the weak points > of low-level programming that evolved with the invention of > international languages after everyone got used to using ASCII. > > while it is very reasonable for a user to set LANG or LC_* to something > sane for his/her environment, programmers must take extra precautions so > that their (plain text) file formats dont get b0rked. > > so the "bug" is actually that you are using a parsing funtion that is > influenced by a locale setting while your file format is not localized > and defined to contain (in this case) numerical values as externalized > by the C/POSIX locale. to be precise: the file formats should be portable, thus we must stay with the "C" locale representation of numbers. >> anyway. I think the actual solution should not be placed in the graph >> constructor but in the main program. thus I sent Raimund a patch for >> CVS which >> >> setlocale (LC_NUMERIC, "C"); > > see above, it is a process-wide setting. so watch out for side-effects. > are there any places where users can user numbers according to their > locale? as said: any inputs into qucs should be locale "C". parsing numbers should fail if the user tries to enter "1,23" instead of "1.23". bottom line: you missed the problem i described. at my computer i can set LANG=de_DE.utf in the environment. this does *not* change the behaviour of the program at all. but setlocale(LC_NUMERIC,"de_DE.utf") *does* change it! also it seems that at christopher's laptop the environment is setup using LANG=de_AT.UTF-8 and this *does* change the program behaviour. this is what i don't understand. cheers, stefan. |