1 --- wcsnrtombs.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2 +++ wcsnrtombs.c 2009-11-09 17:47:14.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsnrtombs.c,v 1.3 2005/02/12 08:45:12 stefanf Exp $");
7 +#include "xlocale_private.h"
12 @@ -34,32 +36,41 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
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. */
62 @@ -71,9 +82,9 @@ __wcsnrtombs_std(char * __restrict dst,
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 = __wcrtomb(dst, *s, ps)) == (size_t)-1) {
70 + if ((nb = __wcrtomb(dst, *s, ps, loc)) == (size_t)-1) {
74 @@ -86,7 +97,7 @@ __wcsnrtombs_std(char * __restrict dst,
75 * character is too long for the buffer.
78 - if ((nb = __wcrtomb(buf, *s, ps)) == (size_t)-1) {
79 + if ((nb = __wcrtomb(buf, *s, ps, loc)) == (size_t)-1) {