From 41777e3d5dc655f59a8c3bcd071639e6878e853a Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Tue, 11 Sep 2012 22:46:07 +0100 Subject: [PATCH] PDCLIB-2: : don't expect or expose definition of FILE. Declare mbstate_t, wint_t, wchar_t --- includes/wchar.h | 34 ++++++++++----------- internals/_PDCLIB_int.h | 9 ++++++ platform/example/internals/_PDCLIB_config.h | 5 +-- platform/win32/internals/_PDCLIB_config.h | 1 + 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/includes/wchar.h b/includes/wchar.h index a98abdb..bac7f40 100644 --- a/includes/wchar.h +++ b/includes/wchar.h @@ -32,7 +32,7 @@ typedef _PDCLIB_wint_t wint_t; #ifndef _PDCLIB_MBSTATE_T_DEFINED #define _PDCLIB_MBSTATE_T_DEFINED _PDCLIB_MBSTATE_T_DEFINED -typedef _PDCLIB_mbstate_t mbstate_t; +typedef struct _PDCLIB_mbstate_t mbstate_t; #endif struct tm; @@ -78,28 +78,28 @@ size_t wcsftime(wchar_t *_PDCLIB_restrict s, size_t maxsize, const wchar_t *_PDC #endif /* Wide character I/O */ -int fwprintf(FILE *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...); -int fwscanf(FILE *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...); +int fwprintf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...); +int fwscanf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...); int swprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, ...); int swscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, ...); -int vfwprintf(FILE *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, va_list arg); -int vfwscanf(FILE *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, va_list arg); -int vswprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, va_list arg); -int vswscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, va_list arg); -int vwprintf(const wchar_t *_PDCLIB_restrict format, va_list arg); -int vwscanf(const wchar_t *_PDCLIB_restrict format, va_list arg); +int vfwprintf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); +int vfwscanf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); +int vswprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); +int vswscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); +int vwprintf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); +int vwscanf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg); int wprintf(const wchar_t *_PDCLIB_restrict format, ...); int wscanf(const wchar_t *_PDCLIB_restrict format, ...); -wint_t fgetwc(FILE *stream); -wchar_t *fgetws(wchar_t *_PDCLIB_restrict s, int n, FILE *_PDCLIB_restrict stream); -wint_t fputwc(wchar_t c, FILE *stream); -int fputws(const wchar_t *_PDCLIB_restrict s, FILE *_PDCLIB_restrict stream); -int fwide(FILE *stream, int mode); -wint_t getwc(FILE *stream); +wint_t fgetwc(struct _PDCLIB_file_t *stream); +wchar_t *fgetws(wchar_t *_PDCLIB_restrict s, int n, struct _PDCLIB_file_t *_PDCLIB_restrict stream); +wint_t fputwc(wchar_t c, struct _PDCLIB_file_t *stream); +int fputws(const wchar_t *_PDCLIB_restrict s, struct _PDCLIB_file_t *_PDCLIB_restrict stream); +int fwide(struct _PDCLIB_file_t *stream, int mode); +wint_t getwc(struct _PDCLIB_file_t *stream); wint_t getwchar(void); -wint_t putwc(wchar_t c, FILE *stream); +wint_t putwc(wchar_t c, struct _PDCLIB_file_t *stream); wint_t putwchar(wchar_t c); -wint_t ungetwc(wint_t c, FILE *stream); +wint_t ungetwc(wint_t c, struct _PDCLIB_file_t *stream); /* Wide character <-> Numeric conversions */ #if 0 diff --git a/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h index fee45ce..2900ff3 100644 --- a/internals/_PDCLIB_int.h +++ b/internals/_PDCLIB_int.h @@ -230,6 +230,7 @@ typedef _PDCLIB_ptrdiff _PDCLIB_ptrdiff_t; typedef _PDCLIB_size _PDCLIB_size_t; #define _PDCLIB_SIZE_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIZE ), _MAX ) +typedef _PDCLIB_wint _PDCLIB_wint_t; typedef _PDCLIB_wchar _PDCLIB_wchar_t; #define _PDCLIB_WCHAR_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_WCHAR ), _MIN ) #define _PDCLIB_WCHAR_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_WCHAR ), _MAX ) @@ -466,4 +467,12 @@ struct _PDCLIB_ctype_t unsigned char collation; }; +/* -------------------------------------------------------------------------- */ +/* mbstate_t */ +/* -------------------------------------------------------------------------- */ + +struct _PDCLIB_mbstate_t { + _PDCLIB_uint32_t st[4]; +}; + #endif diff --git a/platform/example/internals/_PDCLIB_config.h b/platform/example/internals/_PDCLIB_config.h index 0163753..00dbc24 100644 --- a/platform/example/internals/_PDCLIB_config.h +++ b/platform/example/internals/_PDCLIB_config.h @@ -143,8 +143,9 @@ struct _PDCLIB_lldiv_t /* Large enough an integer to hold all character codes of the largest supported locale. */ -#define _PDCLIB_wchar unsigned short -#define _PDCLIB_WCHAR USHRT +#define _PDCLIB_wint signed int +#define _PDCLIB_wchar unsigned int +#define _PDCLIB_WCHAR UINT #define _PDCLIB_intptr int #define _PDCLIB_INTPTR INT diff --git a/platform/win32/internals/_PDCLIB_config.h b/platform/win32/internals/_PDCLIB_config.h index 1d233eb..abefef9 100644 --- a/platform/win32/internals/_PDCLIB_config.h +++ b/platform/win32/internals/_PDCLIB_config.h @@ -162,6 +162,7 @@ struct _PDCLIB_lldiv_t XX: Windows requires wchar_t be an unsigned short, but this is not compliant. */ +#define _PDCLIB_wint signed short #define _PDCLIB_wchar unsigned short #define _PDCLIB_WCHAR USHRT -- 2.40.0