mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Improve wchar declarations in <wchar.h>, <wctype.h> and <stdint.h>.
This commit is contained in:
parent
28f49e53bf
commit
512c9d3f08
5 changed files with 101 additions and 47 deletions
44
libc/include/__/wchar.h
Normal file
44
libc/include/__/wchar.h
Normal 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
|
|
@ -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.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#include <__/stdint.h>
|
#include <__/stdint.h>
|
||||||
|
#include <__/wchar.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -116,7 +117,21 @@ __BEGIN_DECLS
|
||||||
#define SSIZE_MIN __SSIZE_MIN
|
#define SSIZE_MIN __SSIZE_MIN
|
||||||
#define SSIZE_MAX __SSIZE_MAX
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include <sys/__/types.h>
|
#include <sys/__/types.h>
|
||||||
|
|
||||||
|
#include <__/wchar.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if defined(__is_sortix_libc)
|
#if defined(__is_sortix_libc)
|
||||||
|
@ -37,12 +39,23 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __size_t_defined
|
#ifndef __size_t_defined
|
||||||
#define __size_t_defined
|
#define __size_t_defined
|
||||||
#define __need_size_t
|
#define __need_size_t
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wchar_t_defined
|
||||||
|
#define __wchar_t_defined
|
||||||
|
#define __need_wchar_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __off_t_defined
|
#ifndef __off_t_defined
|
||||||
#define __off_t_defined
|
#define __off_t_defined
|
||||||
typedef __off_t off_t;
|
typedef __off_t off_t;
|
||||||
|
@ -62,47 +75,35 @@ typedef int __locale_t;
|
||||||
typedef __locale_t locale_t;
|
typedef __locale_t locale_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __wchar_t_defined
|
|
||||||
#define __wchar_t_defined
|
|
||||||
#define __need_wchar_t
|
|
||||||
#include <stddef.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __wint_t_defined
|
#ifndef __wint_t_defined
|
||||||
#define __wint_t_defined
|
#define __wint_t_defined
|
||||||
typedef int __wint_t;
|
|
||||||
typedef __wint_t wint_t;
|
typedef __wint_t wint_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WCHAR_MAX
|
|
||||||
#define WCHAR_MAX __WCHAR_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WCHAR_MIN
|
#ifndef WCHAR_MIN
|
||||||
#define WCHAR_MIN __WCHAR_MIN
|
#define WCHAR_MIN __WCHAR_MIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WEOF
|
#ifndef WCHAR_MAX
|
||||||
#define WEOF (-1)
|
#define WCHAR_MAX __WCHAR_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef WEOF
|
||||||
#define __need_NULL
|
#define WEOF __WEOF
|
||||||
#include <stddef.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __mbstate_t_defined
|
#ifndef __mbstate_t_defined
|
||||||
/* Conversion state information. */
|
/* Conversion state information. */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
{
|
||||||
|
int __count;
|
||||||
|
union
|
||||||
{
|
{
|
||||||
int __count;
|
wint_t __wch;
|
||||||
union
|
char __wchb[4];
|
||||||
{
|
} __value; /* Value so far. */
|
||||||
wint_t __wch;
|
} mbstate_t;
|
||||||
char __wchb[4];
|
#define __mbstate_t_defined 1
|
||||||
} __value; /* Value so far. */
|
|
||||||
} mbstate_t;
|
|
||||||
#define __mbstate_t_defined 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct tm;
|
struct tm;
|
||||||
|
|
|
@ -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.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -29,27 +29,15 @@
|
||||||
|
|
||||||
#include <sys/__/types.h>
|
#include <sys/__/types.h>
|
||||||
|
|
||||||
|
#include <__/wchar.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
#ifndef __wint_t_defined
|
#ifndef __wint_t_defined
|
||||||
#define __wint_t_defined
|
#define __wint_t_defined
|
||||||
typedef int __wint_t;
|
|
||||||
typedef __wint_t wint_t;
|
typedef __wint_t wint_t;
|
||||||
#endif
|
#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
|
#ifndef __locale_t_defined
|
||||||
#define __locale_t_defined
|
#define __locale_t_defined
|
||||||
/* TODO: figure out what this does and typedef it properly. This is just a
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
@ -59,9 +47,15 @@ typedef __locale_t locale_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WEOF
|
#ifndef WEOF
|
||||||
#define WEOF (-1)
|
#define WEOF __WEOF
|
||||||
#endif
|
#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 iswalnum(wint_t);
|
||||||
int iswalpha(wint_t);
|
int iswalpha(wint_t);
|
||||||
int iswblank(wint_t);
|
int iswblank(wint_t);
|
||||||
|
|
|
@ -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.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -26,5 +26,5 @@
|
||||||
|
|
||||||
extern "C" int iswcntrl(wint_t c)
|
extern "C" int iswcntrl(wint_t c)
|
||||||
{
|
{
|
||||||
return 0 <= c && c < 32;
|
return c < 32;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue