Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-11-21 18:51:12 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-11-21 18:51:12 +0300
commit26a8b62e9a3398bc0308e13edfa053a01eb0cc21 (patch)
treea533ba1279229b5622a252550e418cc789646e64 /winsup/cygwin/nlsfuncs.cc
parent666a3482a5a24f93cf691b7b38c395241d38b34c (diff)
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>
Diffstat (limited to 'winsup/cygwin/nlsfuncs.cc')
-rw-r--r--winsup/cygwin/nlsfuncs.cc66
1 files changed, 56 insertions, 10 deletions
diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc
index 1b2b2d790..9dbd9b16d 100644
--- a/winsup/cygwin/nlsfuncs.cc
+++ b/winsup/cygwin/nlsfuncs.cc
@@ -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 */