Fix numeric and monetary decimal point and thousands separator in fa_IR and ps_AF locales
* nlsfuncs.cc (setlocaleinfo): New macro calling __setlocaleinfo. (__setlocaleinfo): New function to set a locale-specific character to an explicit wchar_t value. (__set_lc_numeric_from_win): Handle fa_IR and ps_AF locales to return same decimal point and thousands separator characters as on Linux. (__set_lc_monetary_from_win): Ditto for monetary characters. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
666a3482a5
commit
26a8b62e9a
|
@ -1,3 +1,12 @@
|
|||
2015-11-21 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* nlsfuncs.cc (setlocaleinfo): New macro calling __setlocaleinfo.
|
||||
(__setlocaleinfo): New function to set a locale-specific character
|
||||
to an explicit wchar_t value.
|
||||
(__set_lc_numeric_from_win): Handle fa_IR and ps_AF locales to return
|
||||
same decimal point and thousands separator characters as on Linux.
|
||||
(__set_lc_monetary_from_win): Ditto for monetary characters.
|
||||
|
||||
2015-11-20 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* common.din (strtold): Drop redirection to _strtold.
|
||||
|
|
|
@ -31,6 +31,8 @@ details. */
|
|||
|
||||
#define getlocaleinfo(category,type) \
|
||||
__getlocaleinfo(lcid,(type),_LC(category))
|
||||
#define setlocaleinfo(category,val) \
|
||||
__setlocaleinfo(_LC(category),(val))
|
||||
#define eval_datetimefmt(type,flags) \
|
||||
__eval_datetimefmt(lcid,(type),(flags),&lc_time_ptr,\
|
||||
lc_time_end-lc_time_ptr)
|
||||
|
@ -365,6 +367,20 @@ __getlocaleinfo (LCID lcid, LCTYPE type, char **ptr, size_t size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static wchar_t *
|
||||
__setlocaleinfo (char **ptr, size_t size, wchar_t val)
|
||||
{
|
||||
wchar_t *ret;
|
||||
|
||||
if ((uintptr_t) *ptr % 1)
|
||||
++*ptr;
|
||||
ret = (wchar_t *) *ptr;
|
||||
ret[0] = val;
|
||||
ret[1] = L'\0';
|
||||
*ptr = (char *) (ret + 2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
__charfromwchar (const wchar_t *in, char **ptr, size_t size,
|
||||
wctomb_p f_wctomb, const char *charset)
|
||||
|
@ -868,11 +884,28 @@ __set_lc_numeric_from_win (const char *name,
|
|||
memcpy (_numeric_locale, _C_numeric_locale, sizeof (struct lc_numeric_T));
|
||||
else
|
||||
{
|
||||
/* decimal_point */
|
||||
_numeric_locale->wdecimal_point = getlocaleinfo (numeric, LOCALE_SDECIMAL);
|
||||
/* decimal_point and thousands_sep */
|
||||
if (lcid == 0x0429) /* fa_IR. Windows decimal_point is slash,
|
||||
correct is dot */
|
||||
{
|
||||
_numeric_locale->wdecimal_point = setlocaleinfo (numeric, L'.');
|
||||
_numeric_locale->wthousands_sep = setlocaleinfo (numeric, L',');
|
||||
}
|
||||
else if (lcid == 0x0463) /* ps_AF. Windows decimal_point is dot,
|
||||
thousands_sep is comma, correct are
|
||||
arabic separators. */
|
||||
{
|
||||
_numeric_locale->wdecimal_point = setlocaleinfo (numeric, 0x066b);
|
||||
_numeric_locale->wthousands_sep = setlocaleinfo (numeric, 0x066c);
|
||||
}
|
||||
else
|
||||
{
|
||||
_numeric_locale->wdecimal_point = getlocaleinfo (numeric,
|
||||
LOCALE_SDECIMAL);
|
||||
_numeric_locale->wthousands_sep = getlocaleinfo (numeric,
|
||||
LOCALE_STHOUSAND);
|
||||
}
|
||||
_numeric_locale->decimal_point = charfromwchar (numeric, wdecimal_point);
|
||||
/* thousands_sep */
|
||||
_numeric_locale->wthousands_sep = getlocaleinfo (numeric, LOCALE_STHOUSAND);
|
||||
_numeric_locale->thousands_sep = charfromwchar (numeric, wthousands_sep);
|
||||
/* grouping */
|
||||
_numeric_locale->grouping = conv_grouping (lcid, LOCALE_SGROUPING,
|
||||
|
@ -953,14 +986,27 @@ __set_lc_monetary_from_win (const char *name,
|
|||
else
|
||||
_monetary_locale->currency_symbol = charfromwchar (monetary,
|
||||
wcurrency_symbol);
|
||||
/* mon_decimal_point */
|
||||
_monetary_locale->wmon_decimal_point = getlocaleinfo (monetary,
|
||||
LOCALE_SMONDECIMALSEP);
|
||||
/* mon_decimal_point and mon_thousands_sep */
|
||||
if (lcid == 0x0429 || lcid == 0x0463) /* fa_IR or ps_AF. Windows
|
||||
mon_decimal_point is slash
|
||||
and comma, mon_thousands_sep
|
||||
is comma and dot, correct
|
||||
are arabic separators. */
|
||||
{
|
||||
_monetary_locale->wmon_decimal_point = setlocaleinfo (monetary,
|
||||
0x066b);
|
||||
_monetary_locale->wmon_thousands_sep = setlocaleinfo (monetary,
|
||||
0x066c);
|
||||
}
|
||||
else
|
||||
{
|
||||
_monetary_locale->wmon_decimal_point = getlocaleinfo (monetary,
|
||||
LOCALE_SMONDECIMALSEP);
|
||||
_monetary_locale->wmon_thousands_sep = getlocaleinfo (monetary,
|
||||
LOCALE_SMONTHOUSANDSEP);
|
||||
}
|
||||
_monetary_locale->mon_decimal_point = charfromwchar (monetary,
|
||||
wmon_decimal_point);
|
||||
/* mon_thousands_sep */
|
||||
_monetary_locale->wmon_thousands_sep = getlocaleinfo (monetary,
|
||||
LOCALE_SMONTHOUSANDSEP);
|
||||
_monetary_locale->mon_thousands_sep = charfromwchar (monetary,
|
||||
wmon_thousands_sep);
|
||||
/* mon_grouping */
|
||||
|
|
|
@ -31,6 +31,9 @@ What changed:
|
|||
- setfacl(1) now allows to use the -b and -k option combined to allow reducing
|
||||
an ACL to only reflect standard POSIX permissions.
|
||||
|
||||
- Fix (numeric and monetary) decimal point and thousands separator in
|
||||
fa_IR and ps_AF locales to be aligned with Linux.
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2015-11-21 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* new-features.xml (ov-new2.4): Document fa_IR and ps_AF locale fixes.
|
||||
|
||||
2015-11-18 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* new-features.xml (ov-new2.4): Add new ACL changes.
|
||||
|
|
|
@ -40,6 +40,11 @@ setfacl(1) now allows to use the -b and -k option combined to allow reducing
|
|||
an ACL to only reflect standard POSIX permissions.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Fix (numeric and monetary) decimal point and thousands separator in
|
||||
fa_IR and ps_AF locales to be aligned with Linux.
|
||||
</para></listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</sect2>
|
||||
|
|
Loading…
Reference in New Issue