mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
libs/libc/locale/lib_localeconv.c and lib_setlocale.c: Make localeconv() and setlocale() more compliance with spec:
1. localeconvi() should return C locale not NULL by default 2. setlocale() should return "C" if new locale equals NULL
This commit is contained in:
@@ -44,6 +44,38 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_LIBC_LOCALE
|
#ifdef CONFIG_LIBC_LOCALE
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static struct lconv g_c_lconv =
|
||||||
|
{
|
||||||
|
.decimal_point = ".",
|
||||||
|
.thousands_sep = "",
|
||||||
|
.grouping = "",
|
||||||
|
.int_curr_symbol = "",
|
||||||
|
.currency_symbol = "",
|
||||||
|
.mon_decimal_point = "",
|
||||||
|
.mon_thousands_sep = "",
|
||||||
|
.mon_grouping = "",
|
||||||
|
.positive_sign = "",
|
||||||
|
.negative_sign = "",
|
||||||
|
.int_frac_digits = CHAR_MAX,
|
||||||
|
.frac_digits = CHAR_MAX,
|
||||||
|
.p_cs_precedes = CHAR_MAX,
|
||||||
|
.p_sep_by_space = CHAR_MAX,
|
||||||
|
.n_cs_precedes = CHAR_MAX,
|
||||||
|
.n_sep_by_space = CHAR_MAX,
|
||||||
|
.p_sign_posn = CHAR_MAX,
|
||||||
|
.n_sign_posn = CHAR_MAX,
|
||||||
|
.int_p_cs_precedes = CHAR_MAX,
|
||||||
|
.int_p_sep_by_space = CHAR_MAX,
|
||||||
|
.int_n_cs_precedes = CHAR_MAX,
|
||||||
|
.int_n_sep_by_space = CHAR_MAX,
|
||||||
|
.int_p_sign_posn = CHAR_MAX,
|
||||||
|
.int_n_sign_posn = CHAR_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -62,8 +94,6 @@
|
|||||||
|
|
||||||
FAR struct lconv *localeconv(void)
|
FAR struct lconv *localeconv(void)
|
||||||
{
|
{
|
||||||
/* NULL indicates the locale was not changed */
|
return &g_c_lconv;
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,12 +63,7 @@
|
|||||||
|
|
||||||
FAR char *setlocale(int category, FAR const char *locale)
|
FAR char *setlocale(int category, FAR const char *locale)
|
||||||
{
|
{
|
||||||
if (locale == NULL)
|
return ((locale == NULL || strcmp(locale, "POSIX") == 0 ||
|
||||||
{
|
strcmp(locale, "C") == 0 || strcmp(locale, "") == 0) ? "C" : NULL);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((strcmp(locale, "POSIX") == 0 || strcmp(locale, "C") == 0 ||
|
|
||||||
strcmp(locale, "") == 0) ? "C" : NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user