mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 02:50:25 +08:00
Move lconv into struct __locale_t and implement __localeconv_l
Based on FreeBSD, just don't export symbol yet, unless required. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
c1b7d9d93d
commit
fb4fb921c6
@ -223,6 +223,13 @@ const struct __locale_t __C_locale =
|
||||
__ascii_mbtowc,
|
||||
0,
|
||||
NULL,
|
||||
{
|
||||
".", "", "", "", "", "", "", "", "", "",
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX
|
||||
},
|
||||
#ifndef __HAVE_LOCALE_INFO__
|
||||
"\1",
|
||||
"ASCII",
|
||||
@ -256,6 +263,13 @@ struct __locale_t __global_locale =
|
||||
#endif
|
||||
0,
|
||||
NULL,
|
||||
{
|
||||
".", "", "", "", "", "", "", "", "", "",
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX
|
||||
},
|
||||
#ifndef __HAVE_LOCALE_INFO__
|
||||
"\1",
|
||||
"ASCII",
|
||||
|
@ -2,65 +2,65 @@
|
||||
#include <reent.h>
|
||||
#include "setlocale.h"
|
||||
|
||||
static
|
||||
struct lconv lconv =
|
||||
struct lconv *
|
||||
__localeconv_l (struct __locale_t *locale)
|
||||
{
|
||||
".", "", "", "", "", "", "", "", "", "",
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
||||
CHAR_MAX, CHAR_MAX
|
||||
};
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
struct lconv *lconv = &locale->lconv;
|
||||
const struct lc_numeric_T *n = __get_numeric_locale (locale);
|
||||
const struct lc_monetary_T *m = __get_monetary_locale (locale);
|
||||
|
||||
lconv->decimal_point = (char *) n->decimal_point;
|
||||
lconv->thousands_sep = (char *) n->thousands_sep;
|
||||
lconv->grouping = (char *) n->grouping;
|
||||
lconv->int_curr_symbol = (char *) m->int_curr_symbol;
|
||||
lconv->currency_symbol = (char *) m->currency_symbol;
|
||||
lconv->mon_decimal_point = (char *) m->mon_decimal_point;
|
||||
lconv->mon_thousands_sep = (char *) m->mon_thousands_sep;
|
||||
lconv->mon_grouping = (char *) m->mon_grouping;
|
||||
lconv->positive_sign = (char *) m->positive_sign;
|
||||
lconv->negative_sign = (char *) m->negative_sign;
|
||||
lconv->int_frac_digits = m->int_frac_digits[0];
|
||||
lconv->frac_digits = m->frac_digits[0];
|
||||
lconv->p_cs_precedes = m->p_cs_precedes[0];
|
||||
lconv->p_sep_by_space = m->p_sep_by_space[0];
|
||||
lconv->n_cs_precedes = m->n_cs_precedes[0];
|
||||
lconv->n_sep_by_space = m->n_sep_by_space[0];
|
||||
lconv->p_sign_posn = m->p_sign_posn[0];
|
||||
lconv->n_sign_posn = m->n_sign_posn[0];
|
||||
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
|
||||
lconv->int_p_cs_precedes = m->int_p_cs_precedes[0];
|
||||
lconv->int_p_sep_by_space = m->int_p_sep_by_space[0];
|
||||
lconv->int_n_cs_precedes = m->int_n_cs_precedes[0];
|
||||
lconv->int_n_sep_by_space = m->int_n_sep_by_space[0];
|
||||
lconv->int_n_sign_posn = m->int_n_sign_posn[0];
|
||||
lconv->int_p_sign_posn = m->int_p_sign_posn[0];
|
||||
#else /* !__HAVE_LOCALE_INFO_EXTENDED__ */
|
||||
lconv->int_p_cs_precedes = m->p_cs_precedes[0];
|
||||
lconv->int_p_sep_by_space = m->p_sep_by_space[0];
|
||||
lconv->int_n_cs_precedes = m->n_cs_precedes[0];
|
||||
lconv->int_n_sep_by_space = m->n_sep_by_space[0];
|
||||
lconv->int_n_sign_posn = m->n_sign_posn[0];
|
||||
lconv->int_p_sign_posn = m->p_sign_posn[0];
|
||||
#endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */
|
||||
#endif /* __HAVE_LOCALE_INFO__ */
|
||||
return lconv;
|
||||
}
|
||||
|
||||
struct lconv *
|
||||
_DEFUN (_localeconv_r, (data),
|
||||
struct _reent *data)
|
||||
{
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
const struct lc_numeric_T *n = __get_current_numeric_locale ();
|
||||
const struct lc_monetary_T *m = __get_current_monetary_locale ();
|
||||
|
||||
lconv.decimal_point = (char *) n->decimal_point;
|
||||
lconv.thousands_sep = (char *) n->thousands_sep;
|
||||
lconv.grouping = (char *) n->grouping;
|
||||
lconv.int_curr_symbol = (char *) m->int_curr_symbol;
|
||||
lconv.currency_symbol = (char *) m->currency_symbol;
|
||||
lconv.mon_decimal_point = (char *) m->mon_decimal_point;
|
||||
lconv.mon_thousands_sep = (char *) m->mon_thousands_sep;
|
||||
lconv.mon_grouping = (char *) m->mon_grouping;
|
||||
lconv.positive_sign = (char *) m->positive_sign;
|
||||
lconv.negative_sign = (char *) m->negative_sign;
|
||||
lconv.int_frac_digits = m->int_frac_digits[0];
|
||||
lconv.frac_digits = m->frac_digits[0];
|
||||
lconv.p_cs_precedes = m->p_cs_precedes[0];
|
||||
lconv.p_sep_by_space = m->p_sep_by_space[0];
|
||||
lconv.n_cs_precedes = m->n_cs_precedes[0];
|
||||
lconv.n_sep_by_space = m->n_sep_by_space[0];
|
||||
lconv.p_sign_posn = m->p_sign_posn[0];
|
||||
lconv.n_sign_posn = m->n_sign_posn[0];
|
||||
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
|
||||
lconv.int_p_cs_precedes = m->int_p_cs_precedes[0];
|
||||
lconv.int_p_sep_by_space = m->int_p_sep_by_space[0];
|
||||
lconv.int_n_cs_precedes = m->int_n_cs_precedes[0];
|
||||
lconv.int_n_sep_by_space = m->int_n_sep_by_space[0];
|
||||
lconv.int_n_sign_posn = m->int_n_sign_posn[0];
|
||||
lconv.int_p_sign_posn = m->int_p_sign_posn[0];
|
||||
#else /* !__HAVE_LOCALE_INFO_EXTENDED__ */
|
||||
lconv.int_p_cs_precedes = m->p_cs_precedes[0];
|
||||
lconv.int_p_sep_by_space = m->p_sep_by_space[0];
|
||||
lconv.int_n_cs_precedes = m->n_cs_precedes[0];
|
||||
lconv.int_n_sep_by_space = m->n_sep_by_space[0];
|
||||
lconv.int_n_sign_posn = m->n_sign_posn[0];
|
||||
lconv.int_p_sign_posn = m->p_sign_posn[0];
|
||||
#endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */
|
||||
#endif /* __HAVE_LOCALE_INFO__ */
|
||||
return (struct lconv *) &lconv;
|
||||
/* Note that we always fall back to the global locale, even in case
|
||||
of specifying a reent. Otherwise a call to _localeconv_r would just
|
||||
crash if the reent locale pointer is NULL. */
|
||||
return __localeconv_l (__get_current_locale ());
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
struct lconv *
|
||||
_DEFUN_VOID (localeconv)
|
||||
{
|
||||
return _localeconv_r (_REENT);
|
||||
return __localeconv_l (__get_current_locale ());
|
||||
}
|
||||
#endif
|
||||
|
@ -180,6 +180,7 @@ struct __locale_t
|
||||
const char *, size_t, mbstate_t *);
|
||||
int cjk_lang;
|
||||
char *ctype_ptr; /* Unused in __global_locale */
|
||||
struct lconv lconv;
|
||||
#ifndef __HAVE_LOCALE_INFO__
|
||||
char mb_cur_max[2];
|
||||
char ctype_codeset[ENCODING_LEN + 1];
|
||||
@ -195,6 +196,8 @@ extern struct __locale_t __global_locale;
|
||||
extern char *__loadlocale (struct __locale_t *, int, const char *);
|
||||
extern const char *__get_locale_env(struct _reent *, int);
|
||||
|
||||
extern struct lconv *__localeconv_l (struct __locale_t *locale);
|
||||
|
||||
/* In POSIX terms the global locale is the process-wide locale. Use this
|
||||
function to always refer to the global locale. */
|
||||
_ELIDABLE_INLINE struct __locale_t *
|
||||
|
Loading…
x
Reference in New Issue
Block a user