diff options
Diffstat (limited to 'gl/localeconv.c')
-rw-r--r-- | gl/localeconv.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/gl/localeconv.c b/gl/localeconv.c index 60c050f..10fc7b7 100644 --- a/gl/localeconv.c +++ b/gl/localeconv.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Query locale dependent information for formatting numbers. | 1 | /* Query locale dependent information for formatting numbers. |
2 | Copyright (C) 2012-2023 Free Software Foundation, Inc. | 2 | Copyright (C) 2012-2024 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This file is free software: you can redistribute it and/or modify | 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 | 5 | it under the terms of the GNU Lesser General Public License as |
@@ -19,10 +19,14 @@ | |||
19 | /* Specification. */ | 19 | /* Specification. */ |
20 | #include <locale.h> | 20 | #include <locale.h> |
21 | 21 | ||
22 | #include <limits.h> | ||
23 | |||
22 | #if HAVE_STRUCT_LCONV_DECIMAL_POINT | 24 | #if HAVE_STRUCT_LCONV_DECIMAL_POINT |
23 | 25 | ||
26 | # define FIX_CHAR_VALUE(x) ((x) >= 0 ? (x) : CHAR_MAX) | ||
27 | |||
24 | /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* | 28 | /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* |
25 | members. */ | 29 | members or where fields of type 'char' are set to -1 instead of CHAR_MAX. */ |
26 | 30 | ||
27 | struct lconv * | 31 | struct lconv * |
28 | localeconv (void) | 32 | localeconv (void) |
@@ -41,21 +45,30 @@ localeconv (void) | |||
41 | result.positive_sign = sys_result->positive_sign; | 45 | result.positive_sign = sys_result->positive_sign; |
42 | result.negative_sign = sys_result->negative_sign; | 46 | result.negative_sign = sys_result->negative_sign; |
43 | result.currency_symbol = sys_result->currency_symbol; | 47 | result.currency_symbol = sys_result->currency_symbol; |
44 | result.frac_digits = sys_result->frac_digits; | 48 | result.frac_digits = FIX_CHAR_VALUE (sys_result->frac_digits); |
45 | result.p_cs_precedes = sys_result->p_cs_precedes; | 49 | result.p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes); |
46 | result.p_sign_posn = sys_result->p_sign_posn; | 50 | result.p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn); |
47 | result.p_sep_by_space = sys_result->p_sep_by_space; | 51 | result.p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space); |
48 | result.n_cs_precedes = sys_result->n_cs_precedes; | 52 | result.n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes); |
49 | result.n_sign_posn = sys_result->n_sign_posn; | 53 | result.n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn); |
50 | result.n_sep_by_space = sys_result->n_sep_by_space; | 54 | result.n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space); |
51 | result.int_curr_symbol = sys_result->int_curr_symbol; | 55 | result.int_curr_symbol = sys_result->int_curr_symbol; |
52 | result.int_frac_digits = sys_result->int_frac_digits; | 56 | result.int_frac_digits = FIX_CHAR_VALUE (sys_result->int_frac_digits); |
53 | result.int_p_cs_precedes = sys_result->p_cs_precedes; | 57 | # if HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES |
54 | result.int_p_sign_posn = sys_result->p_sign_posn; | 58 | result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->int_p_cs_precedes); |
55 | result.int_p_sep_by_space = sys_result->p_sep_by_space; | 59 | result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->int_p_sign_posn); |
56 | result.int_n_cs_precedes = sys_result->n_cs_precedes; | 60 | result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->int_p_sep_by_space); |
57 | result.int_n_sign_posn = sys_result->n_sign_posn; | 61 | result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->int_n_cs_precedes); |
58 | result.int_n_sep_by_space = sys_result->n_sep_by_space; | 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); | ||
64 | # else | ||
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); | ||
71 | # endif | ||
59 | 72 | ||
60 | return &result; | 73 | return &result; |
61 | } | 74 | } |
@@ -64,8 +77,6 @@ localeconv (void) | |||
64 | 77 | ||
65 | /* Override for platforms where 'struct lconv' is a dummy. */ | 78 | /* Override for platforms where 'struct lconv' is a dummy. */ |
66 | 79 | ||
67 | # include <limits.h> | ||
68 | |||
69 | struct lconv * | 80 | struct lconv * |
70 | localeconv (void) | 81 | localeconv (void) |
71 | { | 82 | { |