| 1 | /* Query locale dependent information for formatting numbers. | 
|---|
| 2 | Copyright (C) 2012-2022 Free Software Foundation, Inc. | 
|---|
| 3 |  | 
|---|
| 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. | 
|---|
| 8 |  | 
|---|
| 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. | 
|---|
| 13 |  | 
|---|
| 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/>.  */ | 
|---|
| 16 |  | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 |  | 
|---|
| 19 | /* Specification.  */ | 
|---|
| 20 | #include <locale.h> | 
|---|
| 21 |  | 
|---|
| 22 | #if HAVE_STRUCT_LCONV_DECIMAL_POINT | 
|---|
| 23 |  | 
|---|
| 24 | /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* | 
|---|
| 25 | members.  */ | 
|---|
| 26 |  | 
|---|
| 27 | struct lconv * | 
|---|
| 28 | localeconv (void) | 
|---|
| 29 | { | 
|---|
| 30 | static struct lconv result; | 
|---|
| 31 | # undef lconv | 
|---|
| 32 | # undef localeconv | 
|---|
| 33 | struct lconv *sys_result = localeconv (); | 
|---|
| 34 |  | 
|---|
| 35 | result.decimal_point = sys_result->decimal_point; | 
|---|
| 36 | result.thousands_sep = sys_result->thousands_sep; | 
|---|
| 37 | result.grouping = sys_result->grouping; | 
|---|
| 38 | result.mon_decimal_point = sys_result->mon_decimal_point; | 
|---|
| 39 | result.mon_thousands_sep = sys_result->mon_thousands_sep; | 
|---|
| 40 | result.mon_grouping = sys_result->mon_grouping; | 
|---|
| 41 | result.positive_sign = sys_result->positive_sign; | 
|---|
| 42 | result.negative_sign = sys_result->negative_sign; | 
|---|
| 43 | result.currency_symbol = sys_result->currency_symbol; | 
|---|
| 44 | result.frac_digits = sys_result->frac_digits; | 
|---|
| 45 | result.p_cs_precedes = sys_result->p_cs_precedes; | 
|---|
| 46 | result.p_sign_posn = sys_result->p_sign_posn; | 
|---|
| 47 | result.p_sep_by_space = sys_result->p_sep_by_space; | 
|---|
| 48 | result.n_cs_precedes = sys_result->n_cs_precedes; | 
|---|
| 49 | result.n_sign_posn = sys_result->n_sign_posn; | 
|---|
| 50 | result.n_sep_by_space = sys_result->n_sep_by_space; | 
|---|
| 51 | result.int_curr_symbol = sys_result->int_curr_symbol; | 
|---|
| 52 | result.int_frac_digits = sys_result->int_frac_digits; | 
|---|
| 53 | result.int_p_cs_precedes = sys_result->p_cs_precedes; | 
|---|
| 54 | result.int_p_sign_posn = sys_result->p_sign_posn; | 
|---|
| 55 | result.int_p_sep_by_space = sys_result->p_sep_by_space; | 
|---|
| 56 | result.int_n_cs_precedes = sys_result->n_cs_precedes; | 
|---|
| 57 | result.int_n_sign_posn = sys_result->n_sign_posn; | 
|---|
| 58 | result.int_n_sep_by_space = sys_result->n_sep_by_space; | 
|---|
| 59 |  | 
|---|
| 60 | return &result; | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | #else | 
|---|
| 64 |  | 
|---|
| 65 | /* Override for platforms where 'struct lconv' is a dummy.  */ | 
|---|
| 66 |  | 
|---|
| 67 | # include <limits.h> | 
|---|
| 68 |  | 
|---|
| 69 | struct lconv * | 
|---|
| 70 | localeconv (void) | 
|---|
| 71 | { | 
|---|
| 72 | static /*const*/ struct lconv result = | 
|---|
| 73 | { | 
|---|
| 74 | /* decimal_point */ ".", | 
|---|
| 75 | /* thousands_sep */ "", | 
|---|
| 76 | /* grouping */ "", | 
|---|
| 77 | /* mon_decimal_point */ "", | 
|---|
| 78 | /* mon_thousands_sep */ "", | 
|---|
| 79 | /* mon_grouping */ "", | 
|---|
| 80 | /* positive_sign */ "", | 
|---|
| 81 | /* negative_sign */ "", | 
|---|
| 82 | /* currency_symbol */ "", | 
|---|
| 83 | /* frac_digits */ CHAR_MAX, | 
|---|
| 84 | /* p_cs_precedes */ CHAR_MAX, | 
|---|
| 85 | /* p_sign_posn */ CHAR_MAX, | 
|---|
| 86 | /* p_sep_by_space */ CHAR_MAX, | 
|---|
| 87 | /* n_cs_precedes */ CHAR_MAX, | 
|---|
| 88 | /* n_sign_posn */ CHAR_MAX, | 
|---|
| 89 | /* n_sep_by_space */ CHAR_MAX, | 
|---|
| 90 | /* int_curr_symbol */ "", | 
|---|
| 91 | /* int_frac_digits */ CHAR_MAX, | 
|---|
| 92 | /* int_p_cs_precedes */ CHAR_MAX, | 
|---|
| 93 | /* int_p_sign_posn */ CHAR_MAX, | 
|---|
| 94 | /* int_p_sep_by_space */ CHAR_MAX, | 
|---|
| 95 | /* int_n_cs_precedes */ CHAR_MAX, | 
|---|
| 96 | /* int_n_sign_posn */ CHAR_MAX, | 
|---|
| 97 | /* int_n_sep_by_space */ CHAR_MAX | 
|---|
| 98 | }; | 
|---|
| 99 |  | 
|---|
| 100 | return &result; | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | #endif | 
|---|