X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/9385eb3d10ebe5eb398c52040ec3dbfba9b0cdcf..7b00c0c43f52e9d27168e67a26aac19065cdb40c:/locale/FreeBSD/euc.c.patch diff --git a/locale/FreeBSD/euc.c.patch b/locale/FreeBSD/euc.c.patch index 9d60826..816b75b 100644 --- a/locale/FreeBSD/euc.c.patch +++ b/locale/FreeBSD/euc.c.patch @@ -1,37 +1,118 @@ ---- euc.c.orig Tue May 20 15:21:44 2003 -+++ euc.c Wed Jun 18 12:01:30 2003 -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - - rune_t _EUC_sgetrune(const char *, size_t, char const **); - int _EUC_sputrune(rune_t, char *, size_t, char **); -@@ -135,11 +136,10 @@ - rune_t rune = 0; - int len, set; - -- if (n < 1 || (len = CEI->count[set = _euc_set(*string)]) > n) { -- if (result) -- *result = string; -+ if (result) -+ *result = string; -+ if (n < 1 || (len = CEI->count[set = _euc_set(*string)]) > n) - return (_INVALID_RUNE); -- } - switch (set) { - case 3: - case 2: -@@ -151,6 +151,11 @@ - while (len-- > 0) - rune = (rune << 8) | ((u_int)(*string++) & 0xff); - break; -+ } -+ if (!isrune(rune)) { -+ if (result) -+ (*result)++; -+ return (_INVALID_RUNE); +--- euc.c.bsdnew 2009-11-09 15:05:25.000000000 -0800 ++++ euc.c 2009-11-09 15:44:21.000000000 -0800 +@@ -41,6 +41,8 @@ static char sccsid[] = "@(#)euc.c 8.1 (B + #include + __FBSDID("$FreeBSD: src/lib/libc/locale/euc.c,v 1.22 2007/10/13 16:28:21 ache Exp $"); + ++#include "xlocale_private.h" ++ + #include + #include + #include +@@ -49,13 +51,11 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/ + #include + #include "mblocal.h" + +-extern int __mb_sb_limit; +- + static size_t _EUC_mbrtowc(wchar_t * __restrict, const char * __restrict, +- size_t, mbstate_t * __restrict); +-static int _EUC_mbsinit(const mbstate_t *); ++ size_t, mbstate_t * __restrict, locale_t); ++static int _EUC_mbsinit(const mbstate_t *, locale_t); + static size_t _EUC_wcrtomb(char * __restrict, wchar_t, +- mbstate_t * __restrict); ++ mbstate_t * __restrict, locale_t); + + typedef struct { + int count[4]; +@@ -69,12 +69,20 @@ typedef struct { + int want; + } _EucState; + +-int +-_EUC_init(_RuneLocale *rl) ++/* This will be called by the XL_RELEASE() macro to free the extra storage */ ++static void ++_EUC_free_extra(struct __xlocale_st_runelocale *xrl) ++{ ++ free(xrl->_CurrentRuneLocale.__variable); ++} ++ ++__private_extern__ int ++_EUC_init(struct __xlocale_st_runelocale *xrl) + { + _EucInfo *ei; + int x, new__mb_cur_max; + char *v, *e; ++ _RuneLocale *rl = &xrl->_CurrentRuneLocale; + + if (rl->__variable == NULL) + return (EFTYPE); +@@ -113,24 +121,22 @@ _EUC_init(_RuneLocale *rl) } - if (result) - *result = string; + rl->__variable = ei; + rl->__variable_len = sizeof(_EucInfo); +- _CurrentRuneLocale = rl; +- __mb_cur_max = new__mb_cur_max; +- __mbrtowc = _EUC_mbrtowc; +- __wcrtomb = _EUC_wcrtomb; +- __mbsinit = _EUC_mbsinit; +- __mb_sb_limit = 256; ++ xrl->__mb_cur_max = new__mb_cur_max; ++ xrl->__mbrtowc = _EUC_mbrtowc; ++ xrl->__wcrtomb = _EUC_wcrtomb; ++ xrl->__mbsinit = _EUC_mbsinit; ++ xrl->__mb_sb_limit = 256; ++ xrl->__free_extra = (__free_extra_t)_EUC_free_extra; + return (0); + } + + static int +-_EUC_mbsinit(const mbstate_t *ps) ++_EUC_mbsinit(const mbstate_t *ps, locale_t loc __unused) + { + + return (ps == NULL || ((const _EucState *)ps)->want == 0); + } + +-#define CEI ((_EucInfo *)(_CurrentRuneLocale->__variable)) +- + #define _SS2 0x008e + #define _SS3 0x008f + +@@ -146,16 +152,18 @@ _euc_set(u_int c) + + static size_t + _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, +- mbstate_t * __restrict ps) ++ mbstate_t * __restrict ps, locale_t loc) + { + _EucState *es; + int i, set, want; + wchar_t wc; + const char *os; ++ struct __xlocale_st_runelocale *rl = loc->__lc_ctype; ++ _EucInfo *CEI = (_EucInfo *)rl->_CurrentRuneLocale.__variable; + + es = (_EucState *)ps; + +- if (es->want < 0 || es->want > MB_CUR_MAX || es->set < 0 || ++ if (es->want < 0 || es->want > rl->__mb_cur_max || es->set < 0 || + es->set > 3) { + errno = EINVAL; + return ((size_t)-1); +@@ -218,11 +226,12 @@ _EUC_mbrtowc(wchar_t * __restrict pwc, c + } + + static size_t +-_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) ++_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc) + { + _EucState *es; + wchar_t m, nm; + int i, len; ++ _EucInfo *CEI = (_EucInfo *)loc->__lc_ctype->_CurrentRuneLocale.__variable; + + es = (_EucState *)ps; +