1 /* Query locale dependent information for formatting numbers.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
24 #if HAVE_STRUCT_LCONV_DECIMAL_POINT
26 # define FIX_CHAR_VALUE(x) ((x) >= 0 ? (x) : CHAR_MAX)
28 /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
29 members or where fields of type 'char' are set to -1 instead of CHAR_MAX. */
34 static struct lconv result
;
37 struct lconv
*sys_result
= localeconv ();
39 result
.decimal_point
= sys_result
->decimal_point
;
40 result
.thousands_sep
= sys_result
->thousands_sep
;
41 result
.grouping
= sys_result
->grouping
;
42 result
.mon_decimal_point
= sys_result
->mon_decimal_point
;
43 result
.mon_thousands_sep
= sys_result
->mon_thousands_sep
;
44 result
.mon_grouping
= sys_result
->mon_grouping
;
45 result
.positive_sign
= sys_result
->positive_sign
;
46 result
.negative_sign
= sys_result
->negative_sign
;
47 result
.currency_symbol
= sys_result
->currency_symbol
;
48 result
.frac_digits
= FIX_CHAR_VALUE (sys_result
->frac_digits
);
49 result
.p_cs_precedes
= FIX_CHAR_VALUE (sys_result
->p_cs_precedes
);
50 result
.p_sign_posn
= FIX_CHAR_VALUE (sys_result
->p_sign_posn
);
51 result
.p_sep_by_space
= FIX_CHAR_VALUE (sys_result
->p_sep_by_space
);
52 result
.n_cs_precedes
= FIX_CHAR_VALUE (sys_result
->n_cs_precedes
);
53 result
.n_sign_posn
= FIX_CHAR_VALUE (sys_result
->n_sign_posn
);
54 result
.n_sep_by_space
= FIX_CHAR_VALUE (sys_result
->n_sep_by_space
);
55 result
.int_curr_symbol
= sys_result
->int_curr_symbol
;
56 result
.int_frac_digits
= FIX_CHAR_VALUE (sys_result
->int_frac_digits
);
57 # if HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES
58 result
.int_p_cs_precedes
= FIX_CHAR_VALUE (sys_result
->int_p_cs_precedes
);
59 result
.int_p_sign_posn
= FIX_CHAR_VALUE (sys_result
->int_p_sign_posn
);
60 result
.int_p_sep_by_space
= FIX_CHAR_VALUE (sys_result
->int_p_sep_by_space
);
61 result
.int_n_cs_precedes
= FIX_CHAR_VALUE (sys_result
->int_n_cs_precedes
);
62 result
.int_n_sign_posn
= FIX_CHAR_VALUE (sys_result
->int_n_sign_posn
);
63 result
.int_n_sep_by_space
= FIX_CHAR_VALUE (sys_result
->int_n_sep_by_space
);
65 result
.int_p_cs_precedes
= FIX_CHAR_VALUE (sys_result
->p_cs_precedes
);
66 result
.int_p_sign_posn
= FIX_CHAR_VALUE (sys_result
->p_sign_posn
);
67 result
.int_p_sep_by_space
= FIX_CHAR_VALUE (sys_result
->p_sep_by_space
);
68 result
.int_n_cs_precedes
= FIX_CHAR_VALUE (sys_result
->n_cs_precedes
);
69 result
.int_n_sign_posn
= FIX_CHAR_VALUE (sys_result
->n_sign_posn
);
70 result
.int_n_sep_by_space
= FIX_CHAR_VALUE (sys_result
->n_sep_by_space
);
78 /* Override for platforms where 'struct lconv' is a dummy. */
83 static /*const*/ struct lconv result
=
85 /* decimal_point */ ".",
86 /* thousands_sep */ "",
88 /* mon_decimal_point */ "",
89 /* mon_thousands_sep */ "",
90 /* mon_grouping */ "",
91 /* positive_sign */ "",
92 /* negative_sign */ "",
93 /* currency_symbol */ "",
94 /* frac_digits */ CHAR_MAX
,
95 /* p_cs_precedes */ CHAR_MAX
,
96 /* p_sign_posn */ CHAR_MAX
,
97 /* p_sep_by_space */ CHAR_MAX
,
98 /* n_cs_precedes */ CHAR_MAX
,
99 /* n_sign_posn */ CHAR_MAX
,
100 /* n_sep_by_space */ CHAR_MAX
,
101 /* int_curr_symbol */ "",
102 /* int_frac_digits */ CHAR_MAX
,
103 /* int_p_cs_precedes */ CHAR_MAX
,
104 /* int_p_sign_posn */ CHAR_MAX
,
105 /* int_p_sep_by_space */ CHAR_MAX
,
106 /* int_n_cs_precedes */ CHAR_MAX
,
107 /* int_n_sign_posn */ CHAR_MAX
,
108 /* int_n_sep_by_space */ CHAR_MAX