diff options
author | darylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-27 21:42:16 +0000 |
---|---|---|
committer | darylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-27 21:42:16 +0000 |
commit | 2aa62f2bc9a9654687b377d9ca8a8c2c860a3852 (patch) | |
tree | 62a0991a44327154fb88bf95bd6f7522053db7bb /StdLib/LibC/Locale/localeconv.c | |
parent | 98790d814871cc30bbd536673d3a0948047cd2f0 (diff) | |
download | edk2-platforms-2aa62f2bc9a9654687b377d9ca8a8c2c860a3852.tar.xz |
Standard Libraries for EDK II.
This set of three packages: AppPkg, StdLib, StdLibPrivateInternalFiles; contains the implementation of libraries based upon non-UEFI standards such as ISO/IEC-9899, the library portion of the C Language Standard, POSIX, etc.
AppPkg contains applications that make use of the standard libraries defined in the StdLib Package.
StdLib contains header (include) files and the implementations of the standard libraries.
StdLibPrivateInternalFiles contains files for the exclusive use of the library implementations in StdLib. These files should never be directly referenced from applications or other code.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11600 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/LibC/Locale/localeconv.c')
-rw-r--r-- | StdLib/LibC/Locale/localeconv.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/StdLib/LibC/Locale/localeconv.c b/StdLib/LibC/Locale/localeconv.c new file mode 100644 index 0000000000..46430f9c48 --- /dev/null +++ b/StdLib/LibC/Locale/localeconv.c @@ -0,0 +1,85 @@ +/* $NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $ */
+
+/*
+ * Written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+#include <LibConfig.h>
+#include <sys/EfiCdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/localedef.h>
+#include <locale.h>
+
+/*
+ * The localeconv() function constructs a struct lconv from the current
+ * monetary and numeric locales.
+ *
+ * Because localeconv() may be called many times (especially by library
+ * routines like printf() & strtod()), the approprate members of the
+ * lconv structure are computed only when the monetary or numeric
+ * locale has been changed.
+ */
+int __mlocale_changed = 1;
+int __nlocale_changed = 1;
+
+/*
+ * Return the current locale conversion.
+ */
+struct lconv *
+localeconv()
+{
+ static struct lconv ret;
+
+ if (__mlocale_changed) {
+ /* LC_MONETARY */
+ ret.int_curr_symbol =
+ __UNCONST(_CurrentMonetaryLocale->int_curr_symbol);
+ ret.currency_symbol =
+ __UNCONST(_CurrentMonetaryLocale->currency_symbol);
+ ret.mon_decimal_point =
+ __UNCONST(_CurrentMonetaryLocale->mon_decimal_point);
+ ret.mon_thousands_sep =
+ __UNCONST(_CurrentMonetaryLocale->mon_thousands_sep);
+ ret.mon_grouping =
+ __UNCONST(_CurrentMonetaryLocale->mon_grouping);
+ ret.positive_sign =
+ __UNCONST(_CurrentMonetaryLocale->positive_sign);
+ ret.negative_sign =
+ __UNCONST(_CurrentMonetaryLocale->negative_sign);
+ ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
+ ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
+ ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
+ ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
+ ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
+ ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
+ ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
+ ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
+ ret.int_p_cs_precedes =
+ _CurrentMonetaryLocale->int_p_cs_precedes;
+ ret.int_n_cs_precedes =
+ _CurrentMonetaryLocale->int_n_cs_precedes;
+ ret.int_p_sep_by_space =
+ _CurrentMonetaryLocale->int_p_sep_by_space;
+ ret.int_n_sep_by_space =
+ _CurrentMonetaryLocale->int_n_sep_by_space;
+ ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn;
+ ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn;
+ __mlocale_changed = 0;
+ }
+
+ if (__nlocale_changed) {
+ /* LC_NUMERIC */
+ ret.decimal_point =
+ __UNCONST(_CurrentNumericLocale->decimal_point);
+ ret.thousands_sep =
+ __UNCONST(_CurrentNumericLocale->thousands_sep);
+ ret.grouping =
+ __UNCONST(_CurrentNumericLocale->grouping);
+ __nlocale_changed = 0;
+ }
+
+ return (&ret);
+}
|