25#ifdef MON_THOUSANDS_SEP
30#define TRANSLATE_FROM_LANGINFO
38#ifdef TRANSLATE_FROM_LANGINFO
44#ifdef TRANSLATE_FROM_LANGINFO
45#define LCONV_M(is_string, category, name, item) \
46 { is_string, category, offsetof(struct lconv, name), item }
48#define LCONV_M(is_string, category, name, item) \
49 { is_string, category, offsetof(struct lconv, name) }
51#define LCONV_S(c, n, i) LCONV_M(true, c, n, i)
52#define LCONV_C(c, n, i) LCONV_M(false, c, n, i)
67 LCONV_S(LC_NUMERIC, grouping, GROUPING),
68 LCONV_S(LC_MONETARY, int_curr_symbol, INT_CURR_SYMBOL),
69 LCONV_S(LC_MONETARY, currency_symbol, CURRENCY_SYMBOL),
70 LCONV_S(LC_MONETARY, mon_decimal_point, MON_DECIMAL_POINT),
71 LCONV_S(LC_MONETARY, mon_thousands_sep, MON_THOUSANDS_SEP),
72 LCONV_S(LC_MONETARY, mon_grouping, MON_GROUPING),
73 LCONV_S(LC_MONETARY, positive_sign, POSITIVE_SIGN),
74 LCONV_S(LC_MONETARY, negative_sign, NEGATIVE_SIGN),
77 LCONV_C(LC_MONETARY, int_frac_digits, INT_FRAC_DIGITS),
78 LCONV_C(LC_MONETARY, frac_digits, FRAC_DIGITS),
79 LCONV_C(LC_MONETARY, p_cs_precedes, P_CS_PRECEDES),
80 LCONV_C(LC_MONETARY, p_sep_by_space, P_SEP_BY_SPACE),
81 LCONV_C(LC_MONETARY, n_cs_precedes, N_CS_PRECEDES),
82 LCONV_C(LC_MONETARY, n_sep_by_space, N_SEP_BY_SPACE),
83 LCONV_C(LC_MONETARY, p_sign_posn, P_SIGN_POSN),
84 LCONV_C(LC_MONETARY, n_sign_posn, N_SIGN_POSN),
111#ifdef TRANSLATE_FROM_LANGINFO
116pg_localeconv_from_langinfo(
struct lconv *dst,
125 numeric_locale : monetary_locale;
132 if (!(
string = strdup(
string)))
169 if (!(
string = strdup(
string)))
236 wchar_t *save_lc_ctype = NULL;
237 wchar_t *save_lc_monetary = NULL;
238 wchar_t *save_lc_numeric = NULL;
239 int save_config_thread_locale;
243 save_config_thread_locale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
252 save_lc_ctype = _wsetlocale(LC_CTYPE, NULL);
253 if (!save_lc_ctype || !(save_lc_ctype = wcsdup(save_lc_ctype)))
255 save_lc_monetary = _wsetlocale(LC_MONETARY, NULL);
256 if (!save_lc_monetary || !(save_lc_monetary = wcsdup(save_lc_monetary)))
258 save_lc_numeric = _wsetlocale(LC_NUMERIC, NULL);
259 if (!save_lc_numeric || !(save_lc_numeric = wcsdup(save_lc_numeric)))
280 _wsetlocale(LC_CTYPE, save_lc_ctype);
283 if (save_lc_monetary)
285 _wsetlocale(LC_MONETARY, save_lc_monetary);
286 free(save_lc_monetary);
290 _wsetlocale(LC_NUMERIC, save_lc_numeric);
291 free(save_lc_numeric);
293 _configthreadlocale(save_config_thread_locale);
309 monetary_locale = newlocale(LC_ALL_MASK,
lc_monetary, 0);
310 if (monetary_locale == 0)
312 numeric_locale = newlocale(LC_ALL_MASK,
lc_numeric, 0);
313 if (numeric_locale == 0)
315 freelocale(monetary_locale);
320#if defined(TRANSLATE_FROM_LANGINFO)
322 result = pg_localeconv_from_langinfo(
output,
325#elif defined(HAVE_LOCALECONV_L)
328 localeconv_l(monetary_locale),
334 localeconv_l(numeric_locale),
345 save_locale = uselocale(monetary_locale);
352 uselocale(numeric_locale);
359 uselocale(save_locale);
363 freelocale(monetary_locale);
364 freelocale(numeric_locale);
static char * thousands_sep
static char * decimal_point
static char * lc_monetary
static char * lconv_char_member(struct lconv *lconv, int i)
int pg_localeconv_r(const char *lc_monetary, const char *lc_numeric, struct lconv *output)
static int pg_localeconv_copy_members(struct lconv *dst, struct lconv *src, int category)
static char ** lconv_string_member(struct lconv *lconv, int i)
static const struct lconv_member_info table[]
void pg_localeconv_free(struct lconv *lconv)
int pthread_mutex_unlock(pthread_mutex_t *mp)
int pthread_mutex_lock(pthread_mutex_t *mp)
#define PTHREAD_MUTEX_INITIALIZER