X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..a9aaacca3a68bb8d74fec09d8d8681a0efda2581:/locale/FreeBSD/mbsnrtowcs.c diff --git a/locale/FreeBSD/mbsnrtowcs.c b/locale/FreeBSD/mbsnrtowcs.c index 3e65b15..41cdd86 100644 --- a/locale/FreeBSD/mbsnrtowcs.c +++ b/locale/FreeBSD/mbsnrtowcs.c @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD: src/lib/libc/locale/mbsnrtowcs.c,v 1.1 2004/07/21 10:54:57 tjr Exp $"); +#include "xlocale_private.h" + #include #include #include @@ -34,31 +36,40 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/mbsnrtowcs.c,v 1.1 2004/07/21 10:54:57 t #include "mblocal.h" size_t -mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, - size_t nms, size_t len, mbstate_t * __restrict ps) +mbsnrtowcs_l(wchar_t * __restrict dst, const char ** __restrict src, + size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc) { - static mbstate_t mbs; - + NORMALIZE_LOCALE(loc); if (ps == NULL) - ps = &mbs; - return (__mbsnrtowcs(dst, src, nms, len, ps)); + ps = &loc->__mbs_mbsnrtowcs; + return (loc->__lc_ctype->__mbsnrtowcs(dst, src, nms, len, ps, loc)); } size_t -__mbsnrtowcs_std(wchar_t * __restrict dst, const char ** __restrict src, +mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, mbstate_t * __restrict ps) +{ + return mbsnrtowcs_l(dst, src, nms, len, ps, __current_locale()); +} + +__private_extern__ size_t +__mbsnrtowcs_std(wchar_t * __restrict dst, const char ** __restrict src, + size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc) { const char *s; size_t nchr; wchar_t wc; size_t nb; + size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, + size_t, mbstate_t * __restrict, locale_t) + = loc->__lc_ctype->__mbrtowc; s = *src; nchr = 0; if (dst == NULL) { for (;;) { - if ((nb = __mbrtowc(&wc, s, nms, ps)) == (size_t)-1) + if ((nb = __mbrtowc(&wc, s, nms, ps, loc)) == (size_t)-1) /* Invalid sequence - mbrtowc() sets errno. */ return ((size_t)-1); else if (nb == 0 || nb == (size_t)-2) @@ -71,7 +82,7 @@ __mbsnrtowcs_std(wchar_t * __restrict dst, const char ** __restrict src, } while (len-- > 0) { - if ((nb = __mbrtowc(dst, s, nms, ps)) == (size_t)-1) { + if ((nb = __mbrtowc(dst, s, nms, ps, loc)) == (size_t)-1) { *src = s; return ((size_t)-1); } else if (nb == (size_t)-2) {