From a3d053dbb3fb953d877cf07baaf229796a83ac04 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Thu, 30 Aug 2012 00:29:27 +0100 Subject: [PATCH] PDCLIB-2: Complete wchar.h + manual page. This header is a monster, implies numerous backend changes, and therefore is going to be a bit of a slog :-( --- includes/stdint.h | 3 + includes/wchar.h | 103 +++++++++++++++++-- man3/wchar.h.3 | 254 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 354 insertions(+), 6 deletions(-) create mode 100644 man3/wchar.h.3 diff --git a/includes/stdint.h b/includes/stdint.h index 2a76836..8699a2e 100644 --- a/includes/stdint.h +++ b/includes/stdint.h @@ -153,8 +153,11 @@ typedef _PDCLIB_uintmax_t uintmax_t; #define SIZE_MAX _PDCLIB_SIZE_MAX +#ifndef _PDCLIB_WCHAR_MIN_MAX_DEFINED +#define _PDCLIB_WCHAR_MIN_MAX_DEFINED #define WCHAR_MIN _PDCLIB_WCHAR_MIN #define WCHAR_MAX _PDCLIB_WCHAR_MAX +#endif #define WINT_MIN _PDCLIB_WINT_MIN #define WINT_MAX _PDCLIB_WINT_MAX diff --git a/includes/wchar.h b/includes/wchar.h index 59955b3..a98abdb 100644 --- a/includes/wchar.h +++ b/includes/wchar.h @@ -21,15 +21,106 @@ typedef _PDCLIB_size_t size_t; #ifndef __cplusplus #ifndef _PDCLIB_WCHAR_T_DEFINED #define _PDCLIB_WCHAR_T_DEFINED _PDCLIB_WCHAR_T_DEFINED -typedef _PDCLIB_wchar_t wchar_t; +typedef _PDCLIB_wchar_t wchar_t; #endif #endif -wchar_t *wcschr( const wchar_t * haystack, wchar_t needle ) _PDCLIB_nothrow; -wchar_t *wcsrchr( const wchar_t * haystack, wchar_t needle ) _PDCLIB_nothrow; -size_t wcslen( const wchar_t * string) _PDCLIB_nothrow; -wchar_t *wcscpy( wchar_t * _PDCLIB_restrict dest, - const wchar_t * _PDCLIB_restrict src) _PDCLIB_nothrow; +#ifndef _PDCLIB_WINT_T_DEFINED +#define _PDCLIB_WINT_T_DEFINED _PDCLIB_WINT_T_DEFINED +typedef _PDCLIB_wint_t wint_t; +#endif + +#ifndef _PDCLIB_MBSTATE_T_DEFINED +#define _PDCLIB_MBSTATE_T_DEFINED _PDCLIB_MBSTATE_T_DEFINED +typedef _PDCLIB_mbstate_t mbstate_t; +#endif + +struct tm; + +#ifndef _PDCLIB_NULL_DEFINED +#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED +#define NULL _PDCLIB_NULL +#endif + +#ifndef _PDCLIB_WCHAR_MIN_MAX_DEFINED +#define _PDCLIB_WCHAR_MIN_MAX_DEFINED +#define WCHAR_MIN _PDCLIB_WCHAR_MIN +#define WCHAR_MAX _PDCLIB_WCHAR_MAX +#endif + +#define WEOF ((wint_t) -1) + +/* Wide character string handling */ +wchar_t *wcscpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2); +wchar_t *wcsncpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n); +wchar_t *wmemcpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n); +wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n); +wchar_t *wcscat(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2); +wchar_t *wcsncat(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n); +int wcscmp(const wchar_t *s1, const wchar_t *s2); +int wcscoll(const wchar_t *s1, const wchar_t *s2); +int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n); +size_t wcsxfrm(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n); +int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n); +wchar_t *wcschr(const wchar_t *s, wchar_t c); +size_t wcscspn(const wchar_t *s1, const wchar_t *s2); +wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2); +wchar_t *wcsrchr(const wchar_t *s, wchar_t c); +size_t wcsspn(const wchar_t *s1, const wchar_t *s2); +wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2); +wchar_t *wcstok(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, wchar_t **_PDCLIB_restrict ptr); +wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n); +size_t wcslen(const wchar_t *s); +wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n); + +#if 0 +size_t wcsftime(wchar_t *_PDCLIB_restrict s, size_t maxsize, const wchar_t *_PDCLIB_restrict format, const struct tm *_PDCLIB_restrict timeptr); +#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 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 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 getwchar(void); +wint_t putwc(wchar_t c, FILE *stream); +wint_t putwchar(wchar_t c); +wint_t ungetwc(wint_t c, FILE *stream); + +/* Wide character <-> Numeric conversions */ +#if 0 +double wcstod(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr); +float wcstof(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr); +long double wcstold(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr); +#endif +long int wcstol(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base); +long long int wcstoll(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base); +unsigned long int wcstoul(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base); +unsigned long long int wcstoull(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base); + +/* Character set conversion */ +wint_t btowc(int c); +int wctob(wint_t c); +int mbsinit(const mbstate_t *ps); +size_t mbrlen(const char *_PDCLIB_restrict s, size_t n, mbstate_t *_PDCLIB_restrict ps); +size_t mbrtowc(wchar_t *_PDCLIB_restrict pwc, const char *_PDCLIB_restrict s, size_t n, mbstate_t *_PDCLIB_restrict ps); +size_t wcrtomb(char *_PDCLIB_restrict s, wchar_t wc, mbstate_t *_PDCLIB_restrict ps); +size_t mbsrtowcs(wchar_t *_PDCLIB_restrict dst, const char **_PDCLIB_restrict src, size_t len, mbstate_t *_PDCLIB_restrict ps); +size_t wcsrtombs(char *_PDCLIB_restrict dst, const wchar_t **_PDCLIB_restrict src, size_t len, mbstate_t *_PDCLIB_restrict ps); _PDCLIB_END_EXTERN_C #endif diff --git a/man3/wchar.h.3 b/man3/wchar.h.3 new file mode 100644 index 0000000..0df246a --- /dev/null +++ b/man3/wchar.h.3 @@ -0,0 +1,254 @@ +.\" This file is part of the Public Domain C Library " "PDCLib). +.\" Permission is granted to use" "modify" "and / or redistribute at will. +.\" +.Dd +.Dt WCHAR.H 3 +.Os +.\" +.Sh NAME +.Nm wchar.h +.Nd wide character & wide character string manipulation +.\" +.Sh SYNOPSIS +.In wchar.h +.\" +.Sh DESCRIPTION +The +.In wchar.h +header provides functions for manipulating wide character strings" "for +converting between wide characters and multibyte character sets" "for +manipulating wide character strings" "and for wide character oriented input and +output. +.\" +.Ss Types & Definitions +The type +.Vt size_t +and macro +.Dv NULL +shall be defined as in +.In stddef.h . +.Pp +The type +.Vt wchar_t +shall be defined as an integral type capable of representing any wide character +in the implementation defined encoding. The type +.Vt wint_t +shall be defined as an integral type capable of representing any wide character +in the implementation defined encoding" "plus the distinct value given by +.Dv WEOF , +which evaluates to a constant expression of type +.Vt wint_t +which does not correspond to any character in the implementation defined +character set. The macros +.Dv WCHAR_MIN +and +.Dv WCHAR_MAX +shall be defined as in +.In stdint.h . +.Pp +The type +.Vt mbstate_t +shall be a complete non-array object type used for the storage of the state of +a multibyte to wide character conversion. +.Pp +The type +.Vt struct tm +shall be defined as an incomplete type" "a full definition of wich can be found +in +.In time.h . +.\" +.Ss Wide Character String Handling Functions +.Fn "wchar_t *wcscpy" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" +.br +.Fn "wchar_t *wcsncpy" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" "size_t n" +.br +.Fn "wchar_t *wmemcpy" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" "size_t n" +.br +.Fn "wchar_t *wmemmove" "wchar_t *s1" "const wchar_t *s2" "size_t n" +.br +.Fn "wchar_t *wcscat" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" +.br +.Fn "wchar_t *wcsncat" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" "size_t n" +.br +.Fn "int wcscmp" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "int wcscoll" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "int wcsncmp" "const wchar_t *s1" "const wchar_t *s2" "size_t n" +.br +.Fn "size_t wcsxfrm" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" "size_t n" +.br +.Fn "int wmemcmp" "const wchar_t *s1" "const wchar_t *s2" "size_t n" +.br +.Fn "wchar_t *wcschr" "const wchar_t *s" "wchar_t c" +.br +.Fn "size_t wcscspn" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "wchar_t *wcspbrk" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "wchar_t *wcsrchr" "const wchar_t *s" "wchar_t c" +.br +.Fn "size_t wcsspn" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "wchar_t *wcsstr" "const wchar_t *s1" "const wchar_t *s2" +.br +.Fn "wchar_t *wcstok" "wchar_t *_PDCLIB_restrict s1" "const wchar_t *_PDCLIB_restrict s2" "wchar_t **_PDCLIB_restrict ptr" +.br +.Fn "wchar_t *wmemchr" "const wchar_t *s" "wchar_t c" "size_t n" +.br +.Fn "size_t wcslen" "const wchar_t *s" +.br +.Fn "wchar_t *wmemset" "wchar_t *s" "wchar_t c" "size_t n" +.\" +.Ss Wide Character String Formatting +.Fn "int swprintf" "wchar_t *_PDCLIB_restrict s" "size_t n" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "int swscanf" "const wchar_t *_PDCLIB_restrict s" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "int vswprintf" "wchar_t *_PDCLIB_restrict s" "size_t n" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "int vswscanf" "const wchar_t *_PDCLIB_restrict s" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "size_t wcsftime" "wchar_t *_PDCLIB_restrict s" "size_t maxsize" "const wchar_t *_PDCLIB_restrict format" "const struct tm *_PDCLIB_restrict timeptr" +.\" +.Ss Wide Character Input and Output +.Fn "int fwprintf" "FILE *_PDCLIB_restrict stream" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "int fwscanf" "FILE *_PDCLIB_restrict stream" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "int vfwprintf" "FILE *_PDCLIB_restrict stream" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "int vfwscanf" "FILE *_PDCLIB_restrict stream" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "int vwprintf" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "int vwscanf" "const wchar_t *_PDCLIB_restrict format" "va_list arg" +.br +.Fn "int wprintf" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "int wscanf" "const wchar_t *_PDCLIB_restrict format" "..." +.br +.Fn "wint_t fgetwc" "FILE *stream" +.br +.Fn "wchar_t *fgetws" "wchar_t *_PDCLIB_restrict s" "int n" "FILE *_PDCLIB_restrict stream" +.br +.Fn "wint_t fputwc" "wchar_t c" "FILE *stream" +.br +.Fn "int fputws" "const wchar_t *_PDCLIB_restrict s" "FILE *_PDCLIB_restrict stream" +.br +.Fn "int fwide" "FILE *stream" "int mode" +.br +.Fn "wint_t getwc" "FILE *stream" +.br +.Fn "wint_t getwchar" "void" +.br +.Fn "wint_t putwc" "wchar_t c" "FILE *stream" +.br +.Fn "wint_t putwchar" "wchar_t c" +.br +.Fn "wint_t ungetwc" "wint_t c" "FILE *stream" +.\" +.Ss Wide Character String Parsing +.Fn "double wcstod" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" +.br +.Fn "float wcstof" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" +.br +.Fn "long double wcstold" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" +.br +.Fn "long int wcstol" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" "int base" +.br +.Fn "long long int wcstoll" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" "int base" +.br +.Fn "unsigned long int wcstoul" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" "int base" +.br +.Fn "unsigned long long int wcstoull" "const wchar_t *_PDCLIB_restrict nptr" "wchar_t **_PDCLIB_restrict endptr" "int base" +.\" +.Ss Character Set Conversion +.Fn "wint_t btowc" "int c" +.br +.Fn "int wctob" "wint_t c" +.br +.Fn "int mbsinit" "const mbstate_t *ps" +.br +.Fn "size_t mbrlen" "const char *_PDCLIB_restrict s" "size_t n" "mbstate_t *_PDCLIB_restrict ps" +.br +.Fn "size_t mbrtowc" "wchar_t *_PDCLIB_restrict pwc" "const char *_PDCLIB_restrict s" "size_t n" "mbstate_t *_PDCLIB_restrict ps" +.br +.Fn "size_t wcrtomb" "char *_PDCLIB_restrict s" "wchar_t wc" "mbstate_t *_PDCLIB_restrict ps" +.br +.Fn "size_t mbsrtowcs" "wchar_t *_PDCLIB_restrict dst" "const char **_PDCLIB_restrict src" "size_t len" "mbstate_t *_PDCLIB_restrict ps" +.br +.Fn "size_t wcsrtombs" "char *_PDCLIB_restrict dst" "const wchar_t **_PDCLIB_restrict src" "size_t len" "mbstate_t *_PDCLIB_restrict ps" +.\" +.Sh SEE ALSO +.Xr string.h 3 +.Xr uchar.h 3 +.Xr wcscpy 3 +.Xr wcsncpy 3 +.Xr wmemcpy 3 +.Xr wmemmove 3 +.Xr wcscat 3 +.Xr wcsncat 3 +.Xr wcscmp 3 +.Xr wcscoll 3 +.Xr wcsncmp 3 +.Xr wcsxfrm 3 +.Xr wmemcmp 3 +.Xr wcschr 3 +.Xr wcscspn 3 +.Xr wcspbrk 3 +.Xr wcsrchr 3 +.Xr wcsspn 3 +.Xr wcsstr 3 +.Xr wcstok 3 +.Xr wmemchr 3 +.Xr wcslen 3 +.Xr wmemset 3 +.\" +.Xr swprintf 3 +.Xr swscanf 3 +.Xr vswprintf 3 +.Xr vswscanf 3 +.Xr wcsftime 3 +.\" +.Xr fwprintf 3 +.Xr fwscanf 3 +.Xr vfwprintf 3 +.Xr vfwscanf 3 +.Xr vwprintf 3 +.Xr vwscanf 3 +.Xr wprintf 3 +.Xr wscanf 3 +.Xr fgetwc 3 +.Xr fgetws 3 +.Xr fputwc 3 +.Xr fputws 3 +.Xr fwide 3 +.Xr getwc 3 +.Xr getwchar 3 +.Xr putwc 3 +.Xr putwchar 3 +.Xr ungetwc 3 +.\" +.Xr wcstod 3 +.Xr wcstof 3 +.Xr wcstold 3 +.Xr wcstol 3 +.Xr wcstoll 3 +.Xr wcstoul 3 +.Xr wcstoull 3 +.\" +.Xr btowc 3 +.Xr wctomb 3 +.Xr mbsinit 3 +.Xr mbrlen 3 +.Xr mbrtowc 3 +.Xr wcrtomb 3 +.Xr mbsrtowcs 3 +.Xr wcsrtombs 3 +.\" +.Sh STANDARDS +Conforming to +.St -isoC-amd1 , +.St -isoC-99 and +.St -isoC-2011 . \ No newline at end of file -- 2.40.0