[tyndur-devel] [PATCH v2] libc: btowc
max at tyndur.org ·
From: Max Reitz <max at tyndur.org> * btowc() nimmt ein int, kein wint_t + btowc() zu wchar.h hinzugefügt Signed-off-by: Max Reitz <max at tyndur.org> --- src/modules/include/wchar.h | 9 +++++++++ src/modules/lib/stdlibc/wctype.c | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/include/wchar.h b/src/modules/include/wchar.h index c458870..eca6348 100644 --- a/src/modules/include/wchar.h +++ b/src/modules/include/wchar.h @@ -600,6 +600,15 @@ wint_t putwchar(wchar_t wc); * @return Bei Erfolg > 0, im Fehlerfall -1 */ int fputws(const wchar_t* wcs, FILE* stream); + +/** + * Konvertiert ein Ein-Byte-Character in ein Wide-Character + * + * @param c Der Character + * + * @return Das konvertierte Zeichen, ansonsten WEOF + */ +wint_t btowc(int c); #endif //ifndef _WCHAR_H_ diff --git a/src/modules/lib/stdlibc/wctype.c b/src/modules/lib/stdlibc/wctype.c index 8353776..6b6d491 100644 --- a/src/modules/lib/stdlibc/wctype.c +++ b/src/modules/lib/stdlibc/wctype.c @@ -85,13 +85,13 @@ int iswctype(wint_t wc, wctype_t type) /** * Konvertiert ein Ein-Byte-Character in ein Wide-Character * - * @param wc Der Character + * @param c Der Character * * @return Das konvertierte Zeichen, ansonsten WEOF **/ -wint_t btowc(wint_t wc) +wint_t btowc(int c) { - return (wc < 0 || wc > 127) ? WEOF : wc; + return (c < 0 || c > 127) ? WEOF : (wint_t)c; } -- 1.6.3.3