Annotation of src/lib/libc/locale/localeconv.c, Revision 1.14
1.14 ! tnozaki 1: /* $NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $ */
1.7 kleink 2:
1.1 cgd 3: /*
1.11 salo 4: * Written by J.T. Conklin <jtc@NetBSD.org>.
1.6 jtc 5: * Public domain.
1.1 cgd 6: */
7:
1.8 christos 8: #include <sys/cdefs.h>
1.1 cgd 9: #if defined(LIBC_SCCS) && !defined(lint)
1.14 ! tnozaki 10: __RCSID("$NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $");
1.1 cgd 11: #endif /* LIBC_SCCS and not lint */
12:
1.5 jtc 13: #include <sys/localedef.h>
1.1 cgd 14: #include <locale.h>
15:
1.4 jtc 16: /*
17: * The localeconv() function constructs a struct lconv from the current
18: * monetary and numeric locales.
19: *
20: * Because localeconv() may be called many times (especially by library
1.14 ! tnozaki 21: * routines like printf() & strtod()), the appropriate members of the
1.4 jtc 22: * lconv structure are computed only when the monetary or numeric
23: * locale has been changed.
24: */
25: int __mlocale_changed = 1;
26: int __nlocale_changed = 1;
27:
1.1 cgd 28: /*
29: * Return the current locale conversion.
30: */
31: struct lconv *
32: localeconv()
33: {
1.12 itojun 34: static struct lconv ret;
1.4 jtc 35:
1.12 itojun 36: if (__mlocale_changed) {
37: /* LC_MONETARY */
1.13 christos 38: ret.int_curr_symbol =
39: __UNCONST(_CurrentMonetaryLocale->int_curr_symbol);
40: ret.currency_symbol =
41: __UNCONST(_CurrentMonetaryLocale->currency_symbol);
1.12 itojun 42: ret.mon_decimal_point =
1.13 christos 43: __UNCONST(_CurrentMonetaryLocale->mon_decimal_point);
1.12 itojun 44: ret.mon_thousands_sep =
1.13 christos 45: __UNCONST(_CurrentMonetaryLocale->mon_thousands_sep);
46: ret.mon_grouping =
47: __UNCONST(_CurrentMonetaryLocale->mon_grouping);
48: ret.positive_sign =
49: __UNCONST(_CurrentMonetaryLocale->positive_sign);
50: ret.negative_sign =
51: __UNCONST(_CurrentMonetaryLocale->negative_sign);
1.12 itojun 52: ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
53: ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
54: ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
55: ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
56: ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
57: ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
58: ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
59: ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
60: ret.int_p_cs_precedes =
61: _CurrentMonetaryLocale->int_p_cs_precedes;
62: ret.int_n_cs_precedes =
63: _CurrentMonetaryLocale->int_n_cs_precedes;
64: ret.int_p_sep_by_space =
65: _CurrentMonetaryLocale->int_p_sep_by_space;
66: ret.int_n_sep_by_space =
67: _CurrentMonetaryLocale->int_n_sep_by_space;
68: ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn;
69: ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn;
70: __mlocale_changed = 0;
71: }
72:
73: if (__nlocale_changed) {
74: /* LC_NUMERIC */
75: ret.decimal_point =
1.13 christos 76: __UNCONST(_CurrentNumericLocale->decimal_point);
1.12 itojun 77: ret.thousands_sep =
1.13 christos 78: __UNCONST(_CurrentNumericLocale->thousands_sep);
79: ret.grouping =
80: __UNCONST(_CurrentNumericLocale->grouping);
1.12 itojun 81: __nlocale_changed = 0;
82: }
1.1 cgd 83:
1.12 itojun 84: return (&ret);
1.1 cgd 85: }
CVSweb <webmaster@jp.NetBSD.org>