GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libc/locale/localeconv.c Lines: 0 29 0.0 %
Date: 2017-11-07 Branches: 0 4 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: localeconv.c,v 1.8 2016/05/23 00:05:15 guenther Exp $ */
2
/*
3
 * Written by J.T. Conklin <jtc@netbsd.org>.
4
 * Public domain.
5
 */
6
7
#include <locale.h>
8
#include "localedef.h"
9
10
/*
11
 * The localeconv() function constructs a struct lconv from the current
12
 * monetary and numeric locales.
13
 *
14
 * Because localeconv() may be called many times (especially by library
15
 * routines like printf() & strtod()), the approprate members of the
16
 * lconv structure are computed only when the monetary or numeric
17
 * locale has been changed.
18
 */
19
static int __mlocale_changed = 1;
20
static int __nlocale_changed = 1;
21
22
/*
23
 * Return the current locale conversion.
24
 */
25
struct lconv *
26
localeconv(void)
27
{
28
    static struct lconv ret;
29
30
    if (__mlocale_changed) {
31
	/* LC_MONETARY */
32
	ret.int_curr_symbol	= _CurrentMonetaryLocale->int_curr_symbol;
33
	ret.currency_symbol	= _CurrentMonetaryLocale->currency_symbol;
34
	ret.mon_decimal_point	= _CurrentMonetaryLocale->mon_decimal_point;
35
	ret.mon_thousands_sep	= _CurrentMonetaryLocale->mon_thousands_sep;
36
	ret.mon_grouping	= _CurrentMonetaryLocale->mon_grouping;
37
	ret.positive_sign	= _CurrentMonetaryLocale->positive_sign;
38
	ret.negative_sign	= _CurrentMonetaryLocale->negative_sign;
39
	ret.int_frac_digits	= _CurrentMonetaryLocale->int_frac_digits;
40
	ret.frac_digits		= _CurrentMonetaryLocale->frac_digits;
41
	ret.p_cs_precedes	= _CurrentMonetaryLocale->p_cs_precedes;
42
	ret.p_sep_by_space	= _CurrentMonetaryLocale->p_sep_by_space;
43
	ret.n_cs_precedes	= _CurrentMonetaryLocale->n_cs_precedes;
44
	ret.n_sep_by_space	= _CurrentMonetaryLocale->n_sep_by_space;
45
	ret.p_sign_posn		= _CurrentMonetaryLocale->p_sign_posn;
46
	ret.n_sign_posn		= _CurrentMonetaryLocale->n_sign_posn;
47
	ret.int_p_cs_precedes	= _CurrentMonetaryLocale->int_p_cs_precedes;
48
	ret.int_p_sep_by_space	= _CurrentMonetaryLocale->int_p_sep_by_space;
49
	ret.int_n_cs_precedes	= _CurrentMonetaryLocale->int_n_cs_precedes;
50
	ret.int_n_sep_by_space	= _CurrentMonetaryLocale->int_n_sep_by_space;
51
	ret.int_p_sign_posn	= _CurrentMonetaryLocale->int_p_sign_posn;
52
	ret.int_n_sign_posn	= _CurrentMonetaryLocale->int_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
    }
63
64
    return (&ret);
65
}
66
DEF_STRONG(localeconv);