options/ansi: Add localeconv() for C locale

This commit is contained in:
Alexander van der Grinten 2019-01-11 21:56:07 +01:00
parent 45b100debc
commit c671d114fd

View file

@ -1,4 +1,5 @@
#include <limits.h>
#include <locale.h>
#include <string.h>
@ -7,6 +8,36 @@
#include <mlibc/debug.hpp>
#include <frg/optional.hpp>
namespace {
// Values of the C locale are defined by the C standard.
lconv c_locale_lconv = {
const_cast<char *>("."), // decimal_point
const_cast<char *>(""), // thousands_sep
const_cast<char *>(""), // grouping
const_cast<char *>(""), // mon_decimal_point
const_cast<char *>(""), // mon_thousands_sep
const_cast<char *>(""), // mon_grouping
const_cast<char *>(""), // positive_sign
const_cast<char *>(""), // negative_sign
const_cast<char *>(""), // currency_symbol
CHAR_MAX, // frac_digits
CHAR_MAX, // p_cs_precedes
CHAR_MAX, // n_cs_precedes
CHAR_MAX, // p_sep_by_space
CHAR_MAX, // n_sep_by_space
CHAR_MAX, // p_sign_posn
CHAR_MAX, // n_sign_posn
const_cast<char *>(""), // int_curr_symbol
CHAR_MAX, // int_frac_digits
CHAR_MAX, // int_p_cs_precedes
CHAR_MAX, // int_n_cs_precedes
CHAR_MAX, // int_p_sep_by_space
CHAR_MAX, // int_n_sep_by_space
CHAR_MAX, // int_p_sign_posn
CHAR_MAX // int_n_sign_posn
};
}
struct __Mlibc_LocaleDesc {
// identifier of this locale. used in setlocale()
const char *locale;
@ -93,8 +124,7 @@ char *setlocale(int category, const char *locale) {
}
struct lconv *localeconv(void) {
__ensure(!"Not implemented");
__builtin_unreachable();
return &c_locale_lconv;
}
locale_t newlocale(int category_mask, const char *locale, locale_t base) {