libc: Add a very bare-bones locale.h

This commit is contained in:
apio 2023-05-31 22:12:50 +02:00
parent d40654a00c
commit 5c68d50070
Signed by: apio
GPG Key ID: B8A7D06E42258954
4 changed files with 51 additions and 0 deletions

View File

@ -19,6 +19,7 @@ set(SOURCES
src/env.cpp
src/pwd.cpp
src/grp.cpp
src/locale.cpp
src/sys/stat.cpp
src/sys/mman.cpp
src/sys/wait.cpp

View File

@ -0,0 +1,18 @@
/* bits/locale-cat.h: Locale categories. */
#ifndef _BITS_LOCALE_CAT_H
#define _BITS_LOCALE_CAT_H
enum __libc_locale_category
{
LC_ALL, // Controls all locales.
LC_CTYPE, // Character classification and case conversion.
LC_COLLATE, // Collation order.
LC_MONETARY, // Monetary formatting.
LC_NUMERIC, // Numeric, non-monetary formatting.
LC_TIME, // Date and time formats.
LC_MESSAGES, // Formats of informative and diagnostic messages and interactive responses.
__num_locale_categories,
};
#endif

20
libc/include/locale.h Normal file
View File

@ -0,0 +1,20 @@
/* locale.h: Locale category macros. */
#ifndef _LOCALE_H
#define _LOCALE_H
#include <bits/locale-cat.h>
#ifdef __cplusplus
extern "C"
{
#endif
// Query or set the current locale.
char* setlocale(int category, const char* locale);
#ifdef __cplusplus
}
#endif
#endif

12
libc/src/locale.cpp Normal file
View File

@ -0,0 +1,12 @@
#include <locale.h>
static char s_default_locale[] = "C";
extern "C"
{
char* setlocale(int, const char*)
{
// FIXME: Set the current locale if <locale> is not NULL.
return s_default_locale;
}
}