diff --git a/Userland/Libraries/LibC/CMakeLists.txt b/Userland/Libraries/LibC/CMakeLists.txt index 48a627d85e..98b31ba227 100644 --- a/Userland/Libraries/LibC/CMakeLists.txt +++ b/Userland/Libraries/LibC/CMakeLists.txt @@ -12,6 +12,7 @@ set(LIBC_SOURCES grp.cpp inttypes.cpp ioctl.cpp + langinfo.cpp libcinit.cpp libgen.cpp link.cpp diff --git a/Userland/Libraries/LibC/langinfo.cpp b/Userland/Libraries/LibC/langinfo.cpp new file mode 100644 index 0000000000..9d5d9d2eee --- /dev/null +++ b/Userland/Libraries/LibC/langinfo.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021, the SerenityOS developers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +static const char* __nl_langinfo(nl_item item) +{ + switch (item) { + case CODESET: + return "UTF-8"; + default: + return ""; + } +} + +extern "C" { + +char* nl_langinfo(nl_item item) +{ + // POSIX states that returned strings should not be modified, + // so this cast is probably fine. + return const_cast(__nl_langinfo(item)); +} +} diff --git a/Userland/Libraries/LibC/langinfo.h b/Userland/Libraries/LibC/langinfo.h new file mode 100644 index 0000000000..3470f18f93 --- /dev/null +++ b/Userland/Libraries/LibC/langinfo.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021, the SerenityOS developers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +__BEGIN_DECLS + +enum { + CODESET, +}; + +char* nl_langinfo(nl_item); + +__END_DECLS diff --git a/Userland/Libraries/LibC/nl_types.h b/Userland/Libraries/LibC/nl_types.h new file mode 100644 index 0000000000..31fcbc0e75 --- /dev/null +++ b/Userland/Libraries/LibC/nl_types.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021, the SerenityOS developers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +__BEGIN_DECLS + +typedef int nl_item; + +__END_DECLS