summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/setrunelocale.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-11-01 05:13:13 +0000
committertjr <tjr@FreeBSD.org>2003-11-01 05:13:13 +0000
commit3c1f1a199da3314885eb9bfa43aeff376af61002 (patch)
tree7a458ea464e285a9ff9db7f270ed8f95c1f9e00a /lib/libc/locale/setrunelocale.c
parent8ded4dfb69d56c7c1d2b22688776da16d814d18b (diff)
downloadFreeBSD-src-3c1f1a199da3314885eb9bfa43aeff376af61002.zip
FreeBSD-src-3c1f1a199da3314885eb9bfa43aeff376af61002.tar.gz
Allow mbrtowc() and wcrtomb() to be implemented directly, instead of
as wrappers around the deprecated 4.4BSD rune functions. This paves the way for state-dependent encodings, which the rune API does not support. - Add __emulated_sgetrune() and __emulated_sputrune(), which are implementations of sgetrune() and sputrune() in terms of mbrtowc() and wcrtomb(). - Rename the old rune-wrapper mbrtowc() and wcrtomb() functions to __emulated_mbrtowc() and __emulated_wcrtomb(). - Add __mbrtowc and __wcrtomb function pointers, which point to the current locale's conversion functions, or the __emulated versions. - Implement mbrtowc() and wcrtomb() as calls to these function pointers. - Make the "NONE" encoding implement mbrtowc() and wcrtomb() directly. All of this emulation mess will be removed, together with rune support, in FreeBSD 6.
Diffstat (limited to 'lib/libc/locale/setrunelocale.c')
-rw-r--r--lib/libc/locale/setrunelocale.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 9cdd7e7..0037f9c 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <wchar.h>
#include "ldpart.h"
#include "setlocale.h"
@@ -60,6 +61,16 @@ extern int _BIG5_init(_RuneLocale *);
extern int _MSKanji_init(_RuneLocale *);
extern _RuneLocale *_Read_RuneMagi(FILE *);
+extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
+ size_t, mbstate_t * __restrict);
+extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
+extern size_t __emulated_mbrtowc(wchar_t * __restrict, const char * __restrict,
+ size_t, mbstate_t * __restrict ps);
+extern size_t __emulated_wcrtomb(char * __restrict, wchar_t,
+ mbstate_t * __restrict ps);
+extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
+extern int __emulated_sputrune(rune_t, char *, size_t, char **);
+
static int __setrunelocale(const char *);
__warn_references(setrunelocale, "warning: setrunelocale() is deprecated. See setrunelocale(3).");
@@ -132,6 +143,10 @@ __setrunelocale(const char *encoding)
}
(void)fclose(fp);
+ __mbrtowc = __emulated_mbrtowc;
+ __wcrtomb = __emulated_wcrtomb;
+ rl->sputrune = __emulated_sputrune;
+ rl->sgetrune = __emulated_sgetrune;
if (strcmp(rl->encoding, "NONE") == 0)
ret = _none_init(rl);
else if (strcmp(rl->encoding, "UTF2") == 0)
OpenPOWER on IntegriCloud