From: Owen Shepherd Date: Sun, 30 Dec 2012 21:43:19 +0000 (+0000) Subject: PDCLIB-2 PDCLIB-12: Move _PDCLIB_mbstate_t to _PDCLIB_encoding.h, the new home for... X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=commitdiff_plain;h=effb3189773dc441285c056abf1ea78276698cb8 PDCLIB-2 PDCLIB-12: Move _PDCLIB_mbstate_t to _PDCLIB_encoding.h, the new home for character-related functions. Update wchar.h to reference this. Define mbstate_t to be 128 bytes; a very conservative size --- diff --git a/includes/wchar.h b/includes/wchar.h index 2740d00..e3d8e49 100644 --- a/includes/wchar.h +++ b/includes/wchar.h @@ -8,6 +8,7 @@ #ifndef _PDCLIB_WCHAR_H #define _PDCLIB_WCHAR_H #include <_PDCLIB_io.h> +#include <_PDCLIB_encoding.h> _PDCLIB_BEGIN_EXTERN_C /* This is VASTLY incomplete. Functions being implemented as required by other portions of the library diff --git a/internals/_PDCLIB_encoding.h b/internals/_PDCLIB_encoding.h index 11e2ac5..01e60a1 100644 --- a/internals/_PDCLIB_encoding.h +++ b/internals/_PDCLIB_encoding.h @@ -16,6 +16,33 @@ typedef char16_t _PDCLIB_char16_t; typedef char32_t _PDCLIB_char32_t; #endif +/* -------------------------------------------------------------------------- */ +/* mbstate_t */ +/* -------------------------------------------------------------------------- */ + +typedef struct _PDCLIB_mbstate_t { + union { + /* Is this the best way to represent this? Is this big enough? */ + _PDCLIB_uint64_t _St64[15]; + _PDCLIB_uint32_t _St32[31]; + _PDCLIB_uint16_t _St16[62]; + unsigned char _StUC[124]; + signed char _StSC[124]; + char _StC [124]; + }; + + union { + /* c16/related functions: Surrogate storage + * + * If zero, no surrogate pending. If nonzero, surrogate. + */ + _PDCLIB_uint16_t _Surrogate; + + /* Reserved for potential mbtoutf8/etc functions */ + unsigned char _U8[4]; + }; +} _PDCLIB_mbstate_t; + #ifdef _PDCLIB_WCHAR_IS_UCS2 /* Must be cauued with bufsize >= 1, in != NULL, out != NULL, ps != NULL * diff --git a/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h index e9de2e4..c0bbe00 100644 --- a/internals/_PDCLIB_int.h +++ b/internals/_PDCLIB_int.h @@ -418,12 +418,4 @@ struct _PDCLIB_ctype_t unsigned char collation; }; -/* -------------------------------------------------------------------------- */ -/* mbstate_t */ -/* -------------------------------------------------------------------------- */ - -typedef struct _PDCLIB_mbstate_t { - _PDCLIB_uint32_t st[4]; -} _PDCLIB_mbstate_t; - #endif