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