From 175c6c79dd834b571de174a2afb9768d5f16c229 Mon Sep 17 00:00:00 2001 From: espie <> Date: Wed, 11 May 2005 18:44:13 +0000 Subject: [PATCH] major abi changes: * introduce the mbstate_t typedef. impacts gnu libiconv, which has already been taken care of. * Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with an external variable __mb_cur_max (impacts libX11 and various ports). * use mbstate in all the mb <-> wchar functions with state. * add a stub iswctype function allowing some ports to compile. bash and gdiff are missing wcscoll, and need to be told there's no i18n until this is fixed. Discussed and matthieu, otto, millert, kettenis, deraadt. Major libc bump --- src/include/stddef.h | 7 ++++++- src/include/stdlib.h | 5 +++-- src/include/wchar.h | 18 +++++++++++++++++- src/include/wctype.h | 4 +++- src/lib/libc/stdlib/Makefile.inc | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/include/stddef.h b/src/include/stddef.h index 5a818e71..467a51ed 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stddef.h,v 1.7 2005/04/14 20:59:10 espie Exp $ */ +/* $OpenBSD: stddef.h,v 1.8 2005/05/11 18:44:12 espie Exp $ */ /* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ /*- @@ -57,6 +57,11 @@ typedef _BSD_WINT_T_ wint_t; #undef _BSD_WINT_T_ #endif +#ifdef _BSD_MBSTATE_T_ +typedef _BSD_MBSTATE_T_ mbstate_t; +#undef _BSD_MBSTATE_T_ +#endif + #ifndef NULL #ifdef __GNUG__ #define NULL __null diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 76a2a1f3..8fdec7e2 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.32 2004/08/03 19:59:42 millert Exp $ */ +/* $OpenBSD: stdlib.h,v 1.33 2005/05/11 18:44:12 espie Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -84,7 +84,8 @@ typedef struct { #define RAND_MAX 0x7fffffff -#define MB_CUR_MAX 1 /* XXX */ +extern size_t __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max #include diff --git a/src/include/wchar.h b/src/include/wchar.h index a6703cd8..c7bd964d 100644 --- a/src/include/wchar.h +++ b/src/include/wchar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wchar.h,v 1.1 2005/04/14 20:59:10 espie Exp $ */ +/* $OpenBSD: wchar.h,v 1.2 2005/05/11 18:44:12 espie Exp $ */ /* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */ /*- @@ -84,6 +84,11 @@ typedef _BSD_WCHAR_T_ wchar_t; #undef _BSD_WCHAR_T_ #endif +#ifdef _BSD_MBSTATE_T_ +typedef _BSD_MBSTATE_T_ mbstate_t; +#undef _BSD_MBSTATE_T_ +#endif + #ifdef _BSD_WINT_T_ typedef _BSD_WINT_T_ wint_t; #undef _BSD_WINT_T_ @@ -99,6 +104,14 @@ typedef _BSD_SIZE_T_ size_t; #endif __BEGIN_DECLS +wint_t btowc(int); +size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); +size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, + mbstate_t * __restrict); +int mbsinit(const mbstate_t *); +size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, + mbstate_t * __restrict); +size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); wchar_t *wcschr(const wchar_t *, wchar_t); int wcscmp(const wchar_t *, const wchar_t *); @@ -113,6 +126,8 @@ wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t); wchar_t *wcspbrk(const wchar_t *, const wchar_t *); wchar_t *wcsrchr(const wchar_t *, wchar_t); +size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, + mbstate_t * __restrict); size_t wcsspn(const wchar_t *, const wchar_t *); wchar_t *wcsstr(const wchar_t *, const wchar_t *); wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, @@ -128,6 +143,7 @@ wchar_t *wmemset(wchar_t *, wchar_t, size_t); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); +int wctob(wint_t); __END_DECLS #endif /* !_WCHAR_H_ */ diff --git a/src/include/wctype.h b/src/include/wctype.h index 50ff0f45..e8058e62 100644 --- a/src/include/wctype.h +++ b/src/include/wctype.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wctype.h,v 1.2 2005/04/30 09:14:23 espie Exp $ */ +/* $OpenBSD: wctype.h,v 1.3 2005/05/11 18:44:12 espie Exp $ */ /* $NetBSD: wctype.h,v 1.5 2003/03/02 22:18:11 tshiozak Exp $ */ /*- @@ -69,6 +69,8 @@ int iswupper(wint_t); int iswxdigit(wint_t); wint_t towlower(wint_t); wint_t towupper(wint_t); +int iswctype(wint_t, wctype_t); +wctype_t wctype(const char *); __END_DECLS #endif /* _WCTYPE_H_ */ diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc index 1d5ba5c9..ba81d5ee 100644 --- a/src/lib/libc/stdlib/Makefile.inc +++ b/src/lib/libc/stdlib/Makefile.inc @@ -6,7 +6,7 @@ SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ calloc.c cfree.c exit.c ecvt.c gcvt.c getenv.c getopt_long.c \ getsubopt.c hcreate.c heapsort.c l64a.c llabs.c lsearch.c malloc.c \ - merge.c multibyte.c putenv.c qsort.c radixsort.c rand.c random.c \ + merge.c putenv.c qsort.c radixsort.c rand.c random.c \ realpath.c setenv.c strtod.c strtol.c strtoll.c strtonum.c strtoul.c \ strtoull.c system.c \ tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c \