Menu

#12 bogus change of locale in pslib

open
nobody
None
5
2011-10-29
2011-10-29
No

By using setlocale(LC_ALL, ""); in PS_boot() and ps_printf() the pslib is changing locale of the program using the library.
In may have a very bad result:

- parent program is run in environment with decimal separator set to "comma"
- parent program switches to C locale (or remain in it as it's the default one) to ensure a "dot" as decimal separator
- parent program does some calls to pslib which switches to the "comma"-locale by doing setlocale(LC_ALL, "");
- parent program has the locale changed

A solution would be to first check the previous locale (setlocale(NULL,"")) and revert to the previous one before returning the control to the parent program.

This problem was reported for GNU Data Language:
http://sourceforge.net/tracker/?func=detail&aid=3428043&group_id=97659&atid=618683

Discussion


Log in to post a comment.