mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Improve radix point (decimal point/comma) handling
The GETDECIMAL(x) macro in src/cmd/ksh93/features/locale uses a global static variable 'lp' to get the localeconv() results. Several functions in ksh use local variables called 'lp'. It's dumb luck that this hasn't conflicted yet; it's a bug waiting to happen. It's also slightly inefficient as it calls localeconv() every time. In addition there is a redundant 'sh.decomma' flag that is set to 1 if the radix point is a comma, but only once, by sh_init(). It is not updated if the locale changes. That is not correct. This commit gets rid of both and implements a new approach instead: store the radix point in sh.radixpoint at init time in sh_init(), and in the put_lang() locale discipline function, reinitialise sh.radixpoint whenever LC_ALL or LC_NUMERIC changes. The rest of the code can then simply use sh.radixpoint without worry.
This commit is contained in:
parent
6dbde5ec7c
commit
f0386a8794
9 changed files with 25 additions and 26 deletions
|
|
@ -32,14 +32,4 @@ cat{
|
|||
# endif /* LC_MESSAGES */
|
||||
# endif /* _hdr_locale */
|
||||
#endif /* _PACKAGE_ast */
|
||||
#ifdef _hdr_locale
|
||||
# ifdef _lib_localeconv
|
||||
static struct lconv *lp;
|
||||
# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
|
||||
# else
|
||||
# define GETDECIMAL(x) ('.')
|
||||
# endif /* _lib_localeconv */
|
||||
#else
|
||||
# define GETDECIMAL(x) ('.')
|
||||
#endif /* _hdr_locale */
|
||||
}end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue