1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

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

View file

@ -45,11 +45,19 @@ static struct lconv default_locale = {
default_empty_value default_empty_value
}; };
char* setlocale(int, char const*) char* setlocale(int, char const* locale)
{ {
static char locale[2]; static char c_locale_string[2];
memcpy(locale, "C", 2); memcpy(c_locale_string, "C", 2);
return locale;
// 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() struct lconv* localeconv()