commit c8f36b726296544661faacef1fe8532c152d0c01
parent 94ae04adada37fa3aa3901a4d5a025f7d247aa5d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 5 Nov 2022 12:19:40 +0100
libc: Improve wchar.h and wctype.h
These headers are not yet finished and they still have some
placeholders but this commit reduced some of them.
Diffstat:
8 files changed, 102 insertions(+), 8 deletions(-)
diff --git a/include/bits/amd64/arch/cdefs.h b/include/bits/amd64/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/bits/arm/arch/cdefs.h b/include/bits/arm/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/bits/arm64/arch/cdefs.h b/include/bits/arm64/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/bits/i386/arch/cdefs.h b/include/bits/i386/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/bits/ppc/arch/cdefs.h b/include/bits/ppc/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/bits/z80/arch/cdefs.h b/include/bits/z80/arch/cdefs.h
@@ -28,3 +28,18 @@ typedef int wchar_t;
#endif
#undef _NEED_WCHART
#endif
+
+#ifdef _NEED_WEOF
+#ifndef WEOF
+#define WEOF 0xFFFFFFFFU
+#endif
+#undef _NEED_WEOF
+#endif
+
+#ifdef _NEED_WINT
+#ifndef _WINT
+typedef unsigned win_t;
+#define _WINT
+#endif
+#undef _NEED_WINT
+#endif
diff --git a/include/wchar.h b/include/wchar.h
@@ -4,18 +4,20 @@
#define _NEED_NULL
#define _NEED_SIZET
#define _NEED_WCHART
+#define _NEED_WEOF
#include <sys/cdefs.h>
#include <arch/cdefs.h>
-/* TODO: This is only a placeholder */
-typedef long mbstate_t;
-typedef long wint_t;
+/*
+ * We only support utf8 as multibyte encoding and
+ * it does not have state.
+ */
+typedef int mbstate_t;
+
struct tm;
/* #define WCHAR_MAX 1 */
/* #define WCHAR_MIN 1 */
-/* #define WEOF -1 */
-/* #define NULL 0 */
#ifdef _STDARG_H
extern int vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg);
diff --git a/include/wctype.h b/include/wctype.h
@@ -1,13 +1,15 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
+#define _NEED_WEOF
+#define _NEED_WINT
+#include <sys/cdefs.h>
+#include <arch/cdefs.h>
+
/* TODO: This is only a placeholder */
-typedef int wint_t;
typedef int wctrans_t;
typedef int wctype_t;
-#define WEOF -1
-
extern int iswalnum(wint_t wc);
extern int iswalpha(wint_t wc);
extern int iswblank(wint_t wc);