summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-04-07 09:49:10 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-04-07 09:49:10 +0000
commite97e8562744f5b6a68d5ee5da07c791c42785e80 (patch)
tree81a872676a753fbd726f6e983ce1e9211b7369fa
parentdc763237dac6f1391d35533691691b118e21272b (diff)
Notes
-rw-r--r--lib/libc/locale/srune.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libc/locale/srune.c b/lib/libc/locale/srune.c
index 073fd912e074e..67d3a399d9df8 100644
--- a/lib/libc/locale/srune.c
+++ b/lib/libc/locale/srune.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2003 Tim J. Robbins
+ * Copyright (c) 2003-2004 Tim J. Robbins
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
+/* Not required when sgetrune() and sputrune() are removed. */
+#define OBSOLETE_IN_6
+
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -39,6 +42,8 @@ __FBSDID("$FreeBSD$");
rune_t
__emulated_sgetrune(const char *string, size_t n, const char **result)
{
+ static const mbstate_t initial;
+ mbstate_t mbs;
wchar_t wc;
size_t nconv;
@@ -46,7 +51,8 @@ __emulated_sgetrune(const char *string, size_t n, const char **result)
* Pass a NULL conversion state to mbrtowc() since multibyte
* conversion states are not supported.
*/
- nconv = mbrtowc(&wc, string, n, NULL);
+ mbs = initial;
+ nconv = mbrtowc(&wc, string, n, &mbs);
if (nconv == (size_t)-2) {
if (result != NULL)
*result = string;
@@ -71,10 +77,13 @@ __emulated_sgetrune(const char *string, size_t n, const char **result)
int
__emulated_sputrune(rune_t rune, char *string, size_t n, char **result)
{
+ static const mbstate_t initial;
+ mbstate_t mbs;
char buf[MB_LEN_MAX];
size_t nconv;
- nconv = wcrtomb(buf, (wchar_t)rune, NULL);
+ mbs = initial;
+ nconv = wcrtomb(buf, (wchar_t)rune, &mbs);
if (nconv == (size_t)-1) {
if (result != NULL)
*result = NULL;