LibC: Allow detection of supported locales through setlocale

Closes #14690
This commit is contained in:
implicitfield 2022-09-28 22:01:54 +03:00 committed by Tim Flynn
parent 3353f89e22
commit 767b23c4aa
Notes: sideshowbarker 2024-07-18 00:41:35 +09:00

View File

@ -45,11 +45,19 @@ static struct lconv default_locale = {
default_empty_value
};
char* setlocale(int, char const*)
char* setlocale(int, char const* locale)
{
static char locale[2];
memcpy(locale, "C", 2);
return locale;
static char c_locale_string[2];
memcpy(c_locale_string, "C", 2);
// If we get a null pointer, return the current locale as per POSIX spec.
if (locale == nullptr)
return c_locale_string;
if (strcmp(locale, "POSIX") == 0 || strcmp(locale, "C") == 0 || strcmp(locale, "") == 0)
return c_locale_string;
return nullptr;
}
struct lconv* localeconv()