rm_/lib/localeconv.c

104 lines
3.4 KiB
C
Raw Permalink Normal View History

2020-09-02 16:47:03 +08:00
/* Query locale dependent information for formatting numbers.
2022-07-28 14:16:50 +08:00
Copyright (C) 2012-2022 Free Software Foundation, Inc.
2020-09-02 16:47:03 +08:00
2022-07-28 14:16:50 +08:00
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
2020-09-02 16:47:03 +08:00
2022-07-28 14:16:50 +08:00
This file is distributed in the hope that it will be useful,
2020-09-02 16:47:03 +08:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2022-07-28 14:16:50 +08:00
GNU Lesser General Public License for more details.
2020-09-02 16:47:03 +08:00
2022-07-28 14:16:50 +08:00
You should have received a copy of the GNU Lesser General Public License
2020-09-02 16:47:03 +08:00
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <locale.h>
#if HAVE_STRUCT_LCONV_DECIMAL_POINT
/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
members. */
struct lconv *
localeconv (void)
{
static struct lconv result;
# undef lconv
# undef localeconv
struct lconv *sys_result = localeconv ();
result.decimal_point = sys_result->decimal_point;
result.thousands_sep = sys_result->thousands_sep;
result.grouping = sys_result->grouping;
result.mon_decimal_point = sys_result->mon_decimal_point;
result.mon_thousands_sep = sys_result->mon_thousands_sep;
result.mon_grouping = sys_result->mon_grouping;
result.positive_sign = sys_result->positive_sign;
result.negative_sign = sys_result->negative_sign;
result.currency_symbol = sys_result->currency_symbol;
result.frac_digits = sys_result->frac_digits;
result.p_cs_precedes = sys_result->p_cs_precedes;
result.p_sign_posn = sys_result->p_sign_posn;
result.p_sep_by_space = sys_result->p_sep_by_space;
result.n_cs_precedes = sys_result->n_cs_precedes;
result.n_sign_posn = sys_result->n_sign_posn;
result.n_sep_by_space = sys_result->n_sep_by_space;
result.int_curr_symbol = sys_result->int_curr_symbol;
result.int_frac_digits = sys_result->int_frac_digits;
result.int_p_cs_precedes = sys_result->p_cs_precedes;
result.int_p_sign_posn = sys_result->p_sign_posn;
result.int_p_sep_by_space = sys_result->p_sep_by_space;
result.int_n_cs_precedes = sys_result->n_cs_precedes;
result.int_n_sign_posn = sys_result->n_sign_posn;
result.int_n_sep_by_space = sys_result->n_sep_by_space;
return &result;
}
#else
/* Override for platforms where 'struct lconv' is a dummy. */
# include <limits.h>
struct lconv *
localeconv (void)
{
static /*const*/ struct lconv result =
{
/* decimal_point */ ".",
/* thousands_sep */ "",
/* grouping */ "",
/* mon_decimal_point */ "",
/* mon_thousands_sep */ "",
/* mon_grouping */ "",
/* positive_sign */ "",
/* negative_sign */ "",
/* currency_symbol */ "",
/* frac_digits */ CHAR_MAX,
/* p_cs_precedes */ CHAR_MAX,
/* p_sign_posn */ CHAR_MAX,
/* p_sep_by_space */ CHAR_MAX,
/* n_cs_precedes */ CHAR_MAX,
/* n_sign_posn */ CHAR_MAX,
/* n_sep_by_space */ CHAR_MAX,
/* int_curr_symbol */ "",
/* int_frac_digits */ CHAR_MAX,
/* int_p_cs_precedes */ CHAR_MAX,
/* int_p_sign_posn */ CHAR_MAX,
/* int_p_sep_by_space */ CHAR_MAX,
/* int_n_cs_precedes */ CHAR_MAX,
/* int_n_sign_posn */ CHAR_MAX,
/* int_n_sep_by_space */ CHAR_MAX
};
return &result;
}
#endif