LibC: Implement localeconv()

This commit is contained in:
Bananymous 2024-08-09 16:56:48 +03:00
parent a87ce41030
commit 2e642327ea
1 changed files with 33 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#include <BAN/Assert.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
@ -35,6 +36,38 @@ static const char* locale_to_str(locale_t locale)
ASSERT_NOT_REACHED();
}
struct lconv* localeconv(void)
{
constexpr char CHAR_MAX = __SCHAR_MAX__;
static lconv lconv;
lconv.currency_symbol = const_cast<char*>("");
lconv.decimal_point = const_cast<char*>(".");
lconv.frac_digits = CHAR_MAX;
lconv.grouping = const_cast<char*>("");
lconv.int_curr_symbol = const_cast<char*>("");
lconv.int_frac_digits = CHAR_MAX;
lconv.int_n_cs_precedes = CHAR_MAX;
lconv.int_n_sep_by_space = CHAR_MAX;
lconv.int_n_sign_posn = CHAR_MAX;
lconv.int_p_cs_precedes = CHAR_MAX;
lconv.int_p_sep_by_space = CHAR_MAX;
lconv.int_p_sign_posn = CHAR_MAX;
lconv.mon_decimal_point = const_cast<char*>("");
lconv.mon_grouping = const_cast<char*>("");
lconv.mon_thousands_sep = const_cast<char*>("");
lconv.negative_sign = const_cast<char*>("");
lconv.n_cs_precedes = CHAR_MAX;
lconv.n_sep_by_space = CHAR_MAX;
lconv.n_sign_posn = CHAR_MAX;
lconv.positive_sign = const_cast<char*>("");
lconv.p_cs_precedes = CHAR_MAX;
lconv.p_sep_by_space = CHAR_MAX;
lconv.p_sign_posn = CHAR_MAX;
lconv.thousands_sep = const_cast<char*>("");
return &lconv;
}
char* setlocale(int category, const char* locale_str)
{
static char s_locale_buffer[128];
@ -94,7 +127,6 @@ char* setlocale(int category, const char* locale_str)
return s_locale_buffer;
}
locale_t __getlocale(int category)
{
switch (category)