diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2004-04-07 09:47:56 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2004-04-07 09:47:56 +0000 |
| commit | dc763237dac6f1391d35533691691b118e21272b (patch) | |
| tree | 11fa0f1538982249c0bab94e73e6639ddeab7213 /lib/libc/string | |
| parent | ed870c6a8e17a94f7e99d16246bde847e0f8887f (diff) | |
Notes
Diffstat (limited to 'lib/libc/string')
| -rw-r--r-- | lib/libc/string/wcscoll.c | 8 | ||||
| -rw-r--r-- | lib/libc/string/wcsxfrm.c | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/string/wcscoll.c b/lib/libc/string/wcscoll.c index b042a2576fa6..dbfbcfa919a7 100644 --- a/lib/libc/string/wcscoll.c +++ b/lib/libc/string/wcscoll.c @@ -79,16 +79,20 @@ wcscoll(const wchar_t *ws1, const wchar_t *ws2) static char * __mbsdup(const wchar_t *ws) { + static const mbstate_t initial; + mbstate_t st; const wchar_t *wcp; size_t len; char *mbs; wcp = ws; - if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1) + st = initial; + if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1) return (NULL); if ((mbs = malloc(len + 1)) == NULL) return (NULL); - wcsrtombs(mbs, &ws, len + 1, NULL); + st = initial; + wcsrtombs(mbs, &ws, len + 1, &st); return (mbs); } diff --git a/lib/libc/string/wcsxfrm.c b/lib/libc/string/wcsxfrm.c index 4e988af47b01..5e47ad946ee6 100644 --- a/lib/libc/string/wcsxfrm.c +++ b/lib/libc/string/wcsxfrm.c @@ -97,16 +97,20 @@ wcsxfrm(wchar_t * __restrict dest, const wchar_t * __restrict src, size_t len) static char * __mbsdup(const wchar_t *ws) { + static const mbstate_t initial; + mbstate_t st; const wchar_t *wcp; size_t len; char *mbs; wcp = ws; - if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1) + st = initial; + if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1) return (NULL); if ((mbs = malloc(len + 1)) == NULL) return (NULL); - wcsrtombs(mbs, &ws, len + 1, NULL); + st = initial; + wcsrtombs(mbs, &ws, len + 1, &st); return (mbs); } |
