Add a manual page explaining the format of /etc/manpath.config.
[dragonfly/vkernel-mp.git] / lib / libc / locale / localeconv.c
blobcc19f27cc59aee738295b2614d38288e695beb87
1 /* $NetBSD: src/lib/libc/locale/localeconv.c,v 1.12 2004/01/02 21:53:49 itojun Exp $ */
2 /* $DragonFly: src/lib/libc/locale/localeconv.c,v 1.3 2005/04/21 18:36:34 joerg Exp $ */
4 /*
5 * Written by J.T. Conklin <jtc@NetBSD.org>.
6 * Public domain.
7 */
9 #include <sys/localedef.h>
10 #include <locale.h>
12 /*
13 * The localeconv() function constructs a struct lconv from the current
14 * monetary and numeric locales.
16 * Because localeconv() may be called many times (especially by library
17 * routines like printf() & strtod()), the appropriate members of the
18 * lconv structure are computed only when the monetary or numeric
19 * locale has been changed.
21 int __mlocale_changed = 1;
22 int __nlocale_changed = 1;
25 * Return the current locale conversion.
27 struct lconv *
28 localeconv(void)
30 static struct lconv ret;
32 if (__mlocale_changed) {
33 /* LC_MONETARY */
34 ret.int_curr_symbol = _CurrentMonetaryLocale->int_curr_symbol;
35 ret.currency_symbol = _CurrentMonetaryLocale->currency_symbol;
36 ret.mon_decimal_point =
37 _CurrentMonetaryLocale->mon_decimal_point;
38 ret.mon_thousands_sep =
39 _CurrentMonetaryLocale->mon_thousands_sep;
40 ret.mon_grouping = _CurrentMonetaryLocale->mon_grouping;
41 ret.positive_sign = _CurrentMonetaryLocale->positive_sign;
42 ret.negative_sign = _CurrentMonetaryLocale->negative_sign;
43 ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
44 ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
45 ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
46 ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
47 ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
48 ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
49 ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
50 ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
51 ret.int_p_cs_precedes =
52 _CurrentMonetaryLocale->int_p_cs_precedes;
53 ret.int_n_cs_precedes =
54 _CurrentMonetaryLocale->int_n_cs_precedes;
55 ret.int_p_sep_by_space =
56 _CurrentMonetaryLocale->int_p_sep_by_space;
57 ret.int_n_sep_by_space =
58 _CurrentMonetaryLocale->int_n_sep_by_space;
59 ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn;
60 ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn;
61 __mlocale_changed = 0;
64 if (__nlocale_changed) {
65 /* LC_NUMERIC */
66 /* LINTED const castaway */
67 ret.decimal_point =
68 (char *)_CurrentNumericLocale->decimal_point;
69 /* LINTED const castaway */
70 ret.thousands_sep =
71 (char *)_CurrentNumericLocale->thousands_sep;
72 /* LINTED const castaway */
73 ret.grouping = (char *) _CurrentNumericLocale->grouping;
74 __nlocale_changed = 0;
77 return(&ret);