1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-29 03:19:22 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
1995-04-29 03:19:22 +04:00
|
|
|
static char *rcsid = "$Id: localeconv.c,v 1.6 1995/04/28 23:19:32 jtc Exp $";
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* LIBC_SCCS and not lint */
|
|
|
|
|
1994-09-29 07:57:04 +03:00
|
|
|
#include <sys/localedef.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <locale.h>
|
|
|
|
|
1994-05-25 05:49:32 +04:00
|
|
|
/*
|
|
|
|
* The localeconv() function constructs a struct lconv from the current
|
|
|
|
* monetary and numeric locales.
|
|
|
|
*
|
|
|
|
* Because localeconv() may be called many times (especially by library
|
|
|
|
* routines like printf() & strtod()), the approprate members of the
|
|
|
|
* lconv structure are computed only when the monetary or numeric
|
|
|
|
* locale has been changed.
|
|
|
|
*/
|
|
|
|
int __mlocale_changed = 1;
|
|
|
|
int __nlocale_changed = 1;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Return the current locale conversion.
|
|
|
|
*/
|
|
|
|
struct lconv *
|
|
|
|
localeconv()
|
|
|
|
{
|
1994-05-25 05:49:32 +04:00
|
|
|
static struct lconv ret;
|
|
|
|
|
|
|
|
if (__mlocale_changed) {
|
|
|
|
/* LC_MONETARY */
|
|
|
|
ret.int_curr_symbol = _CurrentMonetaryLocale->int_curr_symbol;
|
|
|
|
ret.currency_symbol = _CurrentMonetaryLocale->currency_symbol;
|
|
|
|
ret.mon_decimal_point = _CurrentMonetaryLocale->mon_decimal_point;
|
|
|
|
ret.mon_thousands_sep = _CurrentMonetaryLocale->mon_thousands_sep;
|
|
|
|
ret.mon_grouping = _CurrentMonetaryLocale->mon_grouping;
|
|
|
|
ret.positive_sign = _CurrentMonetaryLocale->positive_sign;
|
|
|
|
ret.negative_sign = _CurrentMonetaryLocale->negative_sign;
|
|
|
|
ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
|
|
|
|
ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
|
|
|
|
ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
|
|
|
|
ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
|
|
|
|
ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
|
|
|
|
ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
|
|
|
|
ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
|
|
|
|
ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
|
|
|
|
__mlocale_changed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (__nlocale_changed) {
|
|
|
|
/* LC_NUMERIC */
|
|
|
|
ret.decimal_point = (char *) _CurrentNumericLocale->decimal_point;
|
|
|
|
ret.thousands_sep = (char *) _CurrentNumericLocale->thousands_sep;
|
|
|
|
ret.grouping = (char *) _CurrentNumericLocale->grouping;
|
|
|
|
__nlocale_changed = 0;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-05-25 05:49:32 +04:00
|
|
|
return (&ret);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|