Improve wchar declarations in <wchar.h>, <wctype.h> and <stdint.h>.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-02-13 15:46:08 +01:00
parent 28f49e53bf
commit 512c9d3f08
5 changed files with 101 additions and 47 deletions

44
libc/include/__/wchar.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
__/wchar.h
Wide character support.
*******************************************************************************/
#ifndef INCLUDE____WCHAR_H
#define INCLUDE____WCHAR_H
#include <sys/cdefs.h>
__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

View File

@ -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 <sys/cdefs.h>
#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

View File

@ -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 <sys/__/types.h>
#include <__/wchar.h>
#include <stdarg.h>
#if defined(__is_sortix_libc)
@ -37,12 +39,23 @@
__BEGIN_DECLS
#ifndef NULL
#define __need_NULL
#include <stddef.h>
#endif
#ifndef __size_t_defined
#define __size_t_defined
#define __need_size_t
#include <stddef.h>
#endif
#ifndef __wchar_t_defined
#define __wchar_t_defined
#define __need_wchar_t
#include <stddef.h>
#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 <stddef.h>
#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 <stddef.h>
#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;

View File

@ -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 <sys/__/types.h>
#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);

View File

@ -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;
}