[BACK]Return to localeconv.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / locale

Annotation of src/lib/libc/locale/localeconv.c, Revision 1.8

1.8     ! christos    1: /*     $NetBSD: localeconv.c,v 1.7 1997/04/29 16:40:17 kleink Exp $    */
1.7       kleink      2:
1.1       cgd         3: /*
1.6       jtc         4:  * Written by J.T. Conklin <jtc@netbsd.org>.
                      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.8     ! christos   10: __RCSID("$NetBSD$");
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
                     21:  * routines like printf() & strtod()), the approprate members of the
                     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.4       jtc        34:     static struct lconv ret;
                     35:
                     36:     if (__mlocale_changed) {
                     37:        /* LC_MONETARY */
                     38:        ret.int_curr_symbol     = _CurrentMonetaryLocale->int_curr_symbol;
                     39:        ret.currency_symbol     = _CurrentMonetaryLocale->currency_symbol;
                     40:        ret.mon_decimal_point   = _CurrentMonetaryLocale->mon_decimal_point;
                     41:        ret.mon_thousands_sep   = _CurrentMonetaryLocale->mon_thousands_sep;
                     42:        ret.mon_grouping        = _CurrentMonetaryLocale->mon_grouping;
                     43:        ret.positive_sign       = _CurrentMonetaryLocale->positive_sign;
                     44:        ret.negative_sign       = _CurrentMonetaryLocale->negative_sign;
                     45:        ret.int_frac_digits     = _CurrentMonetaryLocale->int_frac_digits;
                     46:        ret.frac_digits         = _CurrentMonetaryLocale->frac_digits;
                     47:        ret.p_cs_precedes       = _CurrentMonetaryLocale->p_cs_precedes;
                     48:        ret.p_sep_by_space      = _CurrentMonetaryLocale->p_sep_by_space;
                     49:        ret.n_cs_precedes       = _CurrentMonetaryLocale->n_cs_precedes;
                     50:        ret.n_sep_by_space      = _CurrentMonetaryLocale->n_sep_by_space;
                     51:        ret.p_sign_posn         = _CurrentMonetaryLocale->p_sign_posn;
                     52:        ret.n_sign_posn         = _CurrentMonetaryLocale->n_sign_posn;
                     53:        __mlocale_changed = 0;
                     54:     }
                     55:
                     56:     if (__nlocale_changed) {
                     57:        /* LC_NUMERIC */
                     58:        ret.decimal_point       = (char *) _CurrentNumericLocale->decimal_point;
                     59:        ret.thousands_sep       = (char *) _CurrentNumericLocale->thousands_sep;
                     60:        ret.grouping            = (char *) _CurrentNumericLocale->grouping;
                     61:        __nlocale_changed = 0;
                     62:     }
1.1       cgd        63:
1.4       jtc        64:     return (&ret);
1.1       cgd        65: }

CVSweb <webmaster@jp.NetBSD.org>