xref: /reactos/sdk/lib/ucrt/locale/localeconv.cpp (revision ffd69754)
104e0dc4aSTimo Kreuzer /***
204e0dc4aSTimo Kreuzer *lconv.c - Contains the localeconv function
304e0dc4aSTimo Kreuzer *
404e0dc4aSTimo Kreuzer *       Copyright (c) Microsoft Corporation. All rights reserved.
504e0dc4aSTimo Kreuzer *
604e0dc4aSTimo Kreuzer *Purpose:
704e0dc4aSTimo Kreuzer *       Contains the localeconv() function.
804e0dc4aSTimo Kreuzer *
904e0dc4aSTimo Kreuzer *******************************************************************************/
1004e0dc4aSTimo Kreuzer #include <corecrt_internal.h>
1104e0dc4aSTimo Kreuzer #include <limits.h>
1204e0dc4aSTimo Kreuzer #include <locale.h>
1304e0dc4aSTimo Kreuzer 
1404e0dc4aSTimo Kreuzer 
1504e0dc4aSTimo Kreuzer 
1604e0dc4aSTimo Kreuzer /* pointer to original static to avoid freeing */
17*ffd69754STimo Kreuzer extern "C" { char    __acrt_lconv_static_decimal  []{"."}; }
18*ffd69754STimo Kreuzer extern "C" { char    __acrt_lconv_static_null     []{""}; }
19*ffd69754STimo Kreuzer extern "C" { wchar_t __acrt_lconv_static_W_decimal[]{L"."}; }
20*ffd69754STimo Kreuzer extern "C" { wchar_t __acrt_lconv_static_W_null   []{L""}; }
2104e0dc4aSTimo Kreuzer 
2204e0dc4aSTimo Kreuzer /* lconv settings for "C" locale */
23*ffd69754STimo Kreuzer extern "C" { struct lconv __acrt_lconv_c
2404e0dc4aSTimo Kreuzer {
2504e0dc4aSTimo Kreuzer     __acrt_lconv_static_decimal,   // decimal_point
2604e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // thousands_sep
2704e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // grouping
2804e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // int_curr_symbol
2904e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // currency_symbol
3004e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // mon_decimal_point
3104e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // mon_thousands_sep
3204e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // mon_grouping
3304e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // positive_sign
3404e0dc4aSTimo Kreuzer     __acrt_lconv_static_null,      // negative_sign
3504e0dc4aSTimo Kreuzer     CHAR_MAX,                      // int_frac_digits
3604e0dc4aSTimo Kreuzer     CHAR_MAX,                      // frac_digits
3704e0dc4aSTimo Kreuzer     CHAR_MAX,                      // p_cs_precedes
3804e0dc4aSTimo Kreuzer     CHAR_MAX,                      // p_sep_by_space
3904e0dc4aSTimo Kreuzer     CHAR_MAX,                      // n_cs_precedes
4004e0dc4aSTimo Kreuzer     CHAR_MAX,                      // n_sep_by_space
4104e0dc4aSTimo Kreuzer     CHAR_MAX,                      // p_sign_posn
4204e0dc4aSTimo Kreuzer     CHAR_MAX,                      // n_sign_posn
4304e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_decimal, // _W_decimal_point
4404e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_thousands_sep
4504e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_int_curr_symbol
4604e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_currency_symbol
4704e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_mon_decimal_point
4804e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_mon_thousands_sep
4904e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_positive_sign
5004e0dc4aSTimo Kreuzer     __acrt_lconv_static_W_null,    // _W_negative_sign
51*ffd69754STimo Kreuzer }; }
5204e0dc4aSTimo Kreuzer 
5304e0dc4aSTimo Kreuzer 
5404e0dc4aSTimo Kreuzer /* pointer to current lconv structure */
5504e0dc4aSTimo Kreuzer 
56*ffd69754STimo Kreuzer extern "C" { struct lconv* __acrt_lconv{&__acrt_lconv_c}; }
5704e0dc4aSTimo Kreuzer 
5804e0dc4aSTimo Kreuzer /***
5904e0dc4aSTimo Kreuzer *struct lconv *localeconv(void) - Return the numeric formatting convention
6004e0dc4aSTimo Kreuzer *
6104e0dc4aSTimo Kreuzer *Purpose:
6204e0dc4aSTimo Kreuzer *       The localeconv() routine returns the numeric formatting conventions
6304e0dc4aSTimo Kreuzer *       for the current locale setting.  [ANSI]
6404e0dc4aSTimo Kreuzer *
6504e0dc4aSTimo Kreuzer *Entry:
6604e0dc4aSTimo Kreuzer *       void
6704e0dc4aSTimo Kreuzer *
6804e0dc4aSTimo Kreuzer *Exit:
6904e0dc4aSTimo Kreuzer *       struct lconv * = pointer to struct indicating current numeric
7004e0dc4aSTimo Kreuzer *                        formatting conventions.
7104e0dc4aSTimo Kreuzer *
7204e0dc4aSTimo Kreuzer *Exceptions:
7304e0dc4aSTimo Kreuzer *
7404e0dc4aSTimo Kreuzer *******************************************************************************/
7504e0dc4aSTimo Kreuzer 
localeconv()7604e0dc4aSTimo Kreuzer extern "C" lconv* __cdecl localeconv()
7704e0dc4aSTimo Kreuzer {
7804e0dc4aSTimo Kreuzer     // Note that we don't need _LocaleUpdate in this function.  The main reason
7904e0dc4aSTimo Kreuzer     // being, that this is a leaf function in locale usage terms.
8004e0dc4aSTimo Kreuzer     __acrt_ptd* const ptd = __acrt_getptd();
8104e0dc4aSTimo Kreuzer     __crt_locale_data* locale_info = ptd->_locale_info;
8204e0dc4aSTimo Kreuzer 
8304e0dc4aSTimo Kreuzer     __acrt_update_locale_info(ptd, &locale_info);
8404e0dc4aSTimo Kreuzer 
8504e0dc4aSTimo Kreuzer     return locale_info->lconv;
8604e0dc4aSTimo Kreuzer }
87