diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-06-01 23:37:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-16 16:42:40 +0200 |
commit | 8f9af4a58282ff8c66ac71137be4025e26dc8623 (patch) | |
tree | 0797b8d4eef2871f49958e4b30d0988e4fd46716 /Userland/Libraries | |
parent | 5ea1810ada65dc8c734ab12f1f9735055bb69b93 (diff) | |
download | serenity-8f9af4a58282ff8c66ac71137be4025e26dc8623.zip |
LibC: Implement CODESET for langinfo
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibC/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibC/langinfo.cpp | 27 | ||||
-rw-r--r-- | Userland/Libraries/LibC/langinfo.h | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibC/nl_types.h | 15 |
4 files changed, 63 insertions, 0 deletions
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 <langinfo.h> + +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<char*>(__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 <nl_types.h> +#include <sys/cdefs.h> + +__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 <sys/cdefs.h> + +__BEGIN_DECLS + +typedef int nl_item; + +__END_DECLS |