diff --git a/libc/include/__/wchar.h b/libc/include/__/wchar.h new file mode 100644 index 00000000..3b7a2f78 --- /dev/null +++ b/libc/include/__/wchar.h @@ -0,0 +1,44 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2014. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + __/wchar.h + Wide character support. + +*******************************************************************************/ + +#ifndef INCLUDE____WCHAR_H +#define INCLUDE____WCHAR_H + +#include + +__BEGIN_DECLS + +typedef __WCHAR_TYPE__ __wchar_t; +#define __WCHAR_MIN __WCHAR_MIN__ +#define __WCHAR_MAX __WCHAR_MAX__ + +typedef __WINT_TYPE__ __wint_t; +#define __WINT_MIN __WINT_MIN__ +#define __WINT_MAX __WINT_MAX__ + +#define __WEOF __WINT_MAX + +__END_DECLS + +#endif diff --git a/libc/include/stdint.h b/libc/include/stdint.h index bc1baf7b..81b24a87 100644 --- a/libc/include/stdint.h +++ b/libc/include/stdint.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2013, 2014. This file is part of the Sortix C Library. @@ -28,6 +28,7 @@ #include #include <__/stdint.h> +#include <__/wchar.h> __BEGIN_DECLS @@ -116,7 +117,21 @@ __BEGIN_DECLS #define SSIZE_MIN __SSIZE_MIN #define SSIZE_MAX __SSIZE_MAX -/* TODO: wchar_t related stuff is missing here. */ +#ifndef WCHAR_MIN +#define WCHAR_MIN __WCHAR_MIN +#endif + +#ifndef WCHAR_MAX +#define WCHAR_MAX __WCHAR_MAX +#endif + +#ifndef WINT_MIN +#define WINT_MIN __WINT_MIN +#endif + +#ifndef WINT_MAX +#define WINT_MAX __WINT_MAX +#endif #endif diff --git a/libc/include/wchar.h b/libc/include/wchar.h index e38a1039..e2914bfa 100644 --- a/libc/include/wchar.h +++ b/libc/include/wchar.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. This file is part of the Sortix C Library. @@ -29,6 +29,8 @@ #include +#include <__/wchar.h> + #include #if defined(__is_sortix_libc) @@ -37,12 +39,23 @@ __BEGIN_DECLS +#ifndef NULL +#define __need_NULL +#include +#endif + #ifndef __size_t_defined #define __size_t_defined #define __need_size_t #include #endif +#ifndef __wchar_t_defined +#define __wchar_t_defined +#define __need_wchar_t +#include +#endif + #ifndef __off_t_defined #define __off_t_defined typedef __off_t off_t; @@ -62,47 +75,35 @@ typedef int __locale_t; typedef __locale_t locale_t; #endif -#ifndef __wchar_t_defined -#define __wchar_t_defined -#define __need_wchar_t -#include -#endif - #ifndef __wint_t_defined #define __wint_t_defined -typedef int __wint_t; typedef __wint_t wint_t; #endif -#ifndef WCHAR_MAX -#define WCHAR_MAX __WCHAR_MAX -#endif - #ifndef WCHAR_MIN #define WCHAR_MIN __WCHAR_MIN #endif -#ifndef WEOF -#define WEOF (-1) +#ifndef WCHAR_MAX +#define WCHAR_MAX __WCHAR_MAX #endif -#ifndef NULL -#define __need_NULL -#include +#ifndef WEOF +#define WEOF __WEOF #endif #ifndef __mbstate_t_defined - /* Conversion state information. */ - typedef struct +/* Conversion state information. */ +typedef struct +{ + int __count; + union { - int __count; - union - { - wint_t __wch; - char __wchb[4]; - } __value; /* Value so far. */ - } mbstate_t; - #define __mbstate_t_defined 1 + wint_t __wch; + char __wchb[4]; + } __value; /* Value so far. */ +} mbstate_t; +#define __mbstate_t_defined 1 #endif struct tm; diff --git a/libc/include/wctype.h b/libc/include/wctype.h index b6bdf5b8..9b79fbb6 100644 --- a/libc/include/wctype.h +++ b/libc/include/wctype.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2014. This file is part of the Sortix C Library. @@ -29,27 +29,15 @@ #include +#include <__/wchar.h> + __BEGIN_DECLS #ifndef __wint_t_defined #define __wint_t_defined -typedef int __wint_t; typedef __wint_t wint_t; #endif -#ifndef __wctrans_t_defined -#define __wctrans_t_defined -/* TODO: figure out what this does and typedef it properly. This is just a - temporary assignment. */ -typedef unsigned int __wctrans_t; -typedef __wctrans_t wctrans_t; -#endif - -#ifndef __wctype_t_defined -#define __wctype_t_defined -typedef int (*wctype_t)(wint_t); -#endif - #ifndef __locale_t_defined #define __locale_t_defined /* TODO: figure out what this does and typedef it properly. This is just a @@ -59,9 +47,15 @@ typedef __locale_t locale_t; #endif #ifndef WEOF -#define WEOF (-1) +#define WEOF __WEOF #endif +/* TODO: Figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef unsigned int wctrans_t; + +typedef int (*wctype_t)(wint_t); + int iswalnum(wint_t); int iswalpha(wint_t); int iswblank(wint_t); diff --git a/libc/wctype/iswcntrl.cpp b/libc/wctype/iswcntrl.cpp index 91b7e61f..358d1ff9 100644 --- a/libc/wctype/iswcntrl.cpp +++ b/libc/wctype/iswcntrl.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2014. This file is part of the Sortix C Library. @@ -26,5 +26,5 @@ extern "C" int iswcntrl(wint_t c) { - return 0 <= c && c < 32; + return c < 32; }