aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/locale/mbrtowc.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2003-11-01 05:13:13 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2003-11-01 05:13:13 +0000
commitd4f6cd06dd4e99170b0039b7b4c72585992322aa (patch)
tree7a458ea464e285a9ff9db7f270ed8f95c1f9e00a /lib/libc/locale/mbrtowc.c
parentde33beddd52678da658b7e56a8dd24ca635ef449 (diff)
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.
Notes
Notes: svn path=/head/; revision=121845
Diffstat (limited to 'lib/libc/locale/mbrtowc.c')
-rw-r--r--lib/libc/locale/mbrtowc.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/libc/locale/mbrtowc.c b/lib/libc/locale/mbrtowc.c
index 7e4d90ef12ab..e99308242a8c 100644
--- a/lib/libc/locale/mbrtowc.c
+++ b/lib/libc/locale/mbrtowc.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 Tim J. Robbins.
+ * Copyright (c) 2002, 2003 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,9 +32,24 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <wchar.h>
+extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
+ size_t, mbstate_t * __restrict);
+
+size_t
+mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
+ size_t n, mbstate_t * __restrict ps)
+{
+
+ return (__mbrtowc(pwc, s, n, ps));
+}
+
+/*
+ * Emulate the ISO C mbrtowc() function in terms of the deprecated
+ * 4.4BSD sgetrune() function.
+ */
size_t
-mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
- mbstate_t * __restrict ps __unused)
+__emulated_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
+ size_t n, mbstate_t * __restrict ps __unused)
{
const char *e;
rune_t r;