1 --- wcsnrtombs.c.orig 2004-11-25 11:38:20.000000000 -0800
2 +++ wcsnrtombs.c 2005-02-18 18:38:25.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsnrtombs.c,v 1.2 2004/07/22 02:57:29 tjr Exp $");
7 +#include "xlocale_private.h"
16 -wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
17 - size_t len, mbstate_t * __restrict ps)
18 +wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
19 + size_t len, mbstate_t * __restrict ps, locale_t loc)
21 - static mbstate_t mbs;
23 + NORMALIZE_LOCALE(loc);
26 - return (__wcsnrtombs(dst, src, nwc, len, ps));
27 + ps = &loc->__mbs_wcsnrtombs;
28 + return (loc->__lc_ctype->__wcsnrtombs(dst, src, nwc, len, ps, loc));
32 +wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
33 + size_t len, mbstate_t * __restrict ps)
35 + return wcsnrtombs_l(dst, src, nwc, len, ps, __current_locale());
38 +__private_extern__ size_t
39 __wcsnrtombs_std(char * __restrict dst, const wchar_t ** __restrict src,
40 - size_t nwc, size_t len, mbstate_t * __restrict ps)
41 + size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc)
48 + struct __xlocale_st_runelocale *runeLocale = loc->__lc_ctype;
49 + size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t) = runeLocale->__wcrtomb;
50 + int mb_cur_max = runeLocale->__mb_cur_max;
57 - if ((nb = __wcrtomb(buf, *s, ps)) == (size_t)-1)
58 + if ((nb = __wcrtomb(buf, *s, ps, loc)) == (size_t)-1)
59 /* Invalid character - wcrtomb() sets errno. */
65 while (len > 0 && nwc-- > 0) {
66 - if (len > (size_t)MB_CUR_MAX) {
67 + if (len > (size_t)mb_cur_max) {
68 /* Enough space to translate in-place. */
69 - if ((nb = (int)__wcrtomb(dst, *s, ps)) < 0) {
70 + if ((nb = (int)__wcrtomb(dst, *s, ps, loc)) < 0) {
75 * character is too long for the buffer.
78 - if ((nb = (int)__wcrtomb(buf, *s, ps)) < 0) {
79 + if ((nb = (int)__wcrtomb(buf, *s, ps, loc)) < 0) {