X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..7b00c0c43f52e9d27168e67a26aac19065cdb40c:/locale/FreeBSD/utf8.c.patch?ds=sidebyside diff --git a/locale/FreeBSD/utf8.c.patch b/locale/FreeBSD/utf8.c.patch index 2aa8c40..9427108 100644 --- a/locale/FreeBSD/utf8.c.patch +++ b/locale/FreeBSD/utf8.c.patch @@ -1,40 +1,40 @@ ---- utf8.c.orig Thu Nov 25 11:38:20 2004 -+++ utf8.c Fri Feb 18 15:40:44 2005 +--- utf8.c.bsdnew 2009-11-09 15:05:25.000000000 -0800 ++++ utf8.c 2009-11-09 17:35:23.000000000 -0800 @@ -27,6 +27,8 @@ #include - __FBSDID("$FreeBSD: src/lib/libc/locale/utf8.c,v 1.11 2004/07/27 06:29:48 tjr Exp $"); + __FBSDID("$FreeBSD: src/lib/libc/locale/utf8.c,v 1.16 2007/10/15 09:51:30 ache Exp $"); +#include "xlocale_private.h" + #include #include #include -@@ -35,14 +37,16 @@ +@@ -35,18 +37,18 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/ #include #include "mblocal.h" --size_t _UTF8_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, -- mbstate_t * __restrict); --int _UTF8_mbsinit(const mbstate_t *); --size_t _UTF8_mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, -- size_t, size_t, mbstate_t * __restrict); --size_t _UTF8_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); --size_t _UTF8_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, -- size_t, size_t, mbstate_t * __restrict); +-extern int __mb_sb_limit; +#define UTF8_MB_CUR_MAX 6 -+ -+static size_t _UTF8_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, -+ mbstate_t * __restrict, locale_t); + + static size_t _UTF8_mbrtowc(wchar_t * __restrict, const char * __restrict, +- size_t, mbstate_t * __restrict); +-static int _UTF8_mbsinit(const mbstate_t *); ++ size_t, mbstate_t * __restrict, locale_t); +static int _UTF8_mbsinit(const mbstate_t *, locale_t); -+static size_t _UTF8_mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, -+ size_t, size_t, mbstate_t * __restrict, locale_t); -+static size_t _UTF8_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t); -+static size_t _UTF8_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, -+ size_t, size_t, mbstate_t * __restrict, locale_t); + static size_t _UTF8_mbsnrtowcs(wchar_t * __restrict, + const char ** __restrict, size_t, size_t, +- mbstate_t * __restrict); ++ mbstate_t * __restrict, locale_t); + static size_t _UTF8_wcrtomb(char * __restrict, wchar_t, +- mbstate_t * __restrict); ++ mbstate_t * __restrict, locale_t); + static size_t _UTF8_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, +- size_t, size_t, mbstate_t * __restrict); ++ size_t, size_t, mbstate_t * __restrict, locale_t); typedef struct { wchar_t ch; -@@ -50,31 +54,30 @@ +@@ -54,29 +56,28 @@ typedef struct { wchar_t lbound; } _UTF8State; @@ -57,40 +57,42 @@ + xrl->__mbsnrtowcs = _UTF8_mbsnrtowcs; + xrl->__wcsnrtombs = _UTF8_wcsnrtombs; + xrl->__mb_cur_max = UTF8_MB_CUR_MAX; + /* + * UCS-4 encoding used as the internal representation, so + * slots 0x0080-0x00FF are occuped and must be excluded + * from the single byte ctype by setting the limit. + */ +- __mb_sb_limit = 128; ++ xrl->__mb_sb_limit = 128; return (0); } --int + static int -_UTF8_mbsinit(const mbstate_t *ps) -+static int +_UTF8_mbsinit(const mbstate_t *ps, locale_t loc) { return (ps == NULL || ((const _UTF8State *)ps)->want == 0); - } +@@ -84,7 +85,7 @@ _UTF8_mbsinit(const mbstate_t *ps) --size_t -+static size_t + static size_t _UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, - mbstate_t * __restrict ps) + mbstate_t * __restrict ps, locale_t loc) { _UTF8State *us; int ch, i, mask, want; -@@ -194,9 +197,9 @@ - return (wch == L'\0' ? 0 : want); - } +@@ -206,7 +207,7 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, --size_t -+static size_t + static size_t _UTF8_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, - size_t nms, size_t len, mbstate_t * __restrict ps) + size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc) { _UTF8State *us; const char *s; -@@ -226,7 +229,7 @@ +@@ -236,7 +237,7 @@ _UTF8_mbsnrtowcs(wchar_t * __restrict ds * excluding NUL. */ nb = 1; @@ -99,7 +101,7 @@ (size_t)-1) /* Invalid sequence - mbrtowc() sets errno. */ return ((size_t)-1); -@@ -256,7 +259,7 @@ +@@ -266,7 +267,7 @@ _UTF8_mbsnrtowcs(wchar_t * __restrict ds */ *dst = (wchar_t)*s; nb = 1; @@ -108,30 +110,25 @@ (size_t)-1) { *src = s; return ((size_t)-1); -@@ -276,8 +279,8 @@ - return (nchr); +@@ -287,7 +288,7 @@ _UTF8_mbsnrtowcs(wchar_t * __restrict ds } --size_t + static size_t -_UTF8_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) -+static size_t +_UTF8_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc) { _UTF8State *us; unsigned char lead; -@@ -344,9 +347,9 @@ - return (len); - } +@@ -356,7 +357,7 @@ _UTF8_wcrtomb(char * __restrict s, wchar --size_t -+static size_t + static size_t _UTF8_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, - size_t nwc, size_t len, mbstate_t * __restrict ps) + size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc) { _UTF8State *us; char buf[MB_LEN_MAX]; -@@ -369,7 +372,7 @@ +@@ -379,7 +380,7 @@ _UTF8_wcsnrtombs(char * __restrict dst, if (0 <= *s && *s < 0x80) /* Fast path for plain ASCII characters. */ nb = 1; @@ -140,24 +137,24 @@ (size_t)-1) /* Invalid character - wcrtomb() sets errno. */ return ((size_t)-1); -@@ -386,9 +389,9 @@ +@@ -396,9 +397,9 @@ _UTF8_wcsnrtombs(char * __restrict dst, /* Fast path for plain ASCII characters. */ nb = 1; *dst = *s; - } else if (len > (size_t)MB_CUR_MAX) { + } else if (len > (size_t)UTF8_MB_CUR_MAX) { /* Enough space to translate in-place. */ -- if ((nb = (int)_UTF8_wcrtomb(dst, *s, ps)) < 0) { -+ if ((nb = (int)_UTF8_wcrtomb(dst, *s, ps, loc)) < 0) { +- if ((nb = _UTF8_wcrtomb(dst, *s, ps)) == (size_t)-1) { ++ if ((nb = _UTF8_wcrtomb(dst, *s, ps, loc)) == (size_t)-1) { *src = s; return ((size_t)-1); } -@@ -396,7 +399,7 @@ +@@ -406,7 +407,7 @@ _UTF8_wcsnrtombs(char * __restrict dst, /* * May not be enough space; use temp. buffer. */ -- if ((nb = (int)_UTF8_wcrtomb(buf, *s, ps)) < 0) { -+ if ((nb = (int)_UTF8_wcrtomb(buf, *s, ps, loc)) < 0) { +- if ((nb = _UTF8_wcrtomb(buf, *s, ps)) == (size_t)-1) { ++ if ((nb = _UTF8_wcrtomb(buf, *s, ps, loc)) == (size_t)-1) { *src = s; return ((size_t)-1); }