lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1991-2015 Free Software Foundation, Inc. |
| 2 | This file is part of the GNU C Library. |
| 3 | |
| 4 | The GNU C Library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | The GNU C Library 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 GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with the GNU C Library; if not, see |
| 16 | <http://www.gnu.org/licenses/>. */ |
| 17 | |
| 18 | #include <locale.h> |
| 19 | #include "localeinfo.h" |
| 20 | #include <shlib-compat.h> |
| 21 | |
| 22 | /* Return monetary and numeric information about the current locale. */ |
| 23 | struct lconv * |
| 24 | __localeconv (void) |
| 25 | { |
| 26 | static struct lconv result; |
| 27 | |
| 28 | result.decimal_point = (char *) _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT); |
| 29 | result.thousands_sep = (char *) _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP); |
| 30 | result.grouping = (char *) _NL_CURRENT (LC_NUMERIC, GROUPING); |
| 31 | if (*result.grouping == '\177' || *result.grouping == '\377') |
| 32 | result.grouping = (char *) ""; |
| 33 | |
| 34 | result.int_curr_symbol = (char *) _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL); |
| 35 | result.currency_symbol = (char *) _NL_CURRENT (LC_MONETARY, CURRENCY_SYMBOL); |
| 36 | result.mon_decimal_point = (char *) _NL_CURRENT (LC_MONETARY, |
| 37 | MON_DECIMAL_POINT); |
| 38 | result.mon_thousands_sep = (char *) _NL_CURRENT (LC_MONETARY, |
| 39 | MON_THOUSANDS_SEP); |
| 40 | result.mon_grouping = (char *) _NL_CURRENT (LC_MONETARY, MON_GROUPING); |
| 41 | if (*result.mon_grouping == '\177' || *result.mon_grouping == '\377') |
| 42 | result.mon_grouping = (char *) ""; |
| 43 | result.positive_sign = (char *) _NL_CURRENT (LC_MONETARY, POSITIVE_SIGN); |
| 44 | result.negative_sign = (char *) _NL_CURRENT (LC_MONETARY, NEGATIVE_SIGN); |
| 45 | |
| 46 | #define INT_ELEM(member, element) \ |
| 47 | result.member = *(char *) _NL_CURRENT (LC_MONETARY, element); \ |
| 48 | if (result.member == '\377') result.member = CHAR_MAX |
| 49 | |
| 50 | INT_ELEM (int_frac_digits, INT_FRAC_DIGITS); |
| 51 | INT_ELEM (frac_digits, FRAC_DIGITS); |
| 52 | INT_ELEM (p_cs_precedes, P_CS_PRECEDES); |
| 53 | INT_ELEM (p_sep_by_space, P_SEP_BY_SPACE); |
| 54 | INT_ELEM (n_cs_precedes, N_CS_PRECEDES); |
| 55 | INT_ELEM (n_sep_by_space, N_SEP_BY_SPACE); |
| 56 | INT_ELEM (p_sign_posn, P_SIGN_POSN); |
| 57 | INT_ELEM (n_sign_posn, N_SIGN_POSN); |
| 58 | INT_ELEM (int_p_cs_precedes, INT_P_CS_PRECEDES); |
| 59 | INT_ELEM (int_p_sep_by_space, INT_P_SEP_BY_SPACE); |
| 60 | INT_ELEM (int_n_cs_precedes, INT_N_CS_PRECEDES); |
| 61 | INT_ELEM (int_n_sep_by_space, INT_N_SEP_BY_SPACE); |
| 62 | INT_ELEM (int_p_sign_posn, INT_P_SIGN_POSN); |
| 63 | INT_ELEM (int_n_sign_posn, INT_N_SIGN_POSN); |
| 64 | |
| 65 | return &result; |
| 66 | } |
| 67 | |
| 68 | versioned_symbol (libc, __localeconv, localeconv, GLIBC_2_2); |
| 69 | #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) |
| 70 | strong_alias (__localeconv, __localeconv20) |
| 71 | compat_symbol (libc, __localeconv20, localeconv, GLIBC_2_0); |
| 72 | #endif |