]> git.saurik.com Git - apple/libc.git/blobdiff - locale/FreeBSD/mskanji.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / locale / FreeBSD / mskanji.c.patch
index f740c3482c2bcd13c69d11806fe1dfa5976bae3d..1399fa96667b2a10ab64f1789cb9140788235de3 100644 (file)
@@ -1,42 +1,74 @@
---- mskanji.c.orig     Tue May 20 15:21:44 2003
-+++ mskanji.c  Wed Jun 18 12:02:06 2003
-@@ -43,6 +43,7 @@
- #include <stddef.h>
- #include <stdio.h>
- #include <stdlib.h>
-+#include <ctype.h>
- rune_t        _MSKanji_sgetrune(const char *, size_t, char const **);
- int   _MSKanji_sputrune(rune_t, char *, size_t, char **);
-@@ -67,20 +68,23 @@
+--- mskanji.c.orig     2009-11-09 15:05:25.000000000 -0800
++++ mskanji.c  2009-11-09 16:30:02.000000000 -0800
+@@ -39,6 +39,8 @@ static char sccsid[] = "@(#)mskanji.c        1.
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD: src/lib/libc/locale/mskanji.c,v 1.18 2007/10/13 16:28:22 ache Exp $");
++#include "xlocale_private.h"
++
+ #include <sys/types.h>
+ #include <errno.h>
+ #include <runetype.h>
+@@ -47,33 +49,30 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
+ #include <wchar.h>
+ #include "mblocal.h"
+-extern int __mb_sb_limit;
+-
+ static size_t _MSKanji_mbrtowc(wchar_t * __restrict, const char * __restrict,
+-                  size_t, mbstate_t * __restrict);
+-static int    _MSKanji_mbsinit(const mbstate_t *);
++                  size_t, mbstate_t * __restrict, locale_t);
++static int    _MSKanji_mbsinit(const mbstate_t *, locale_t);
+ static size_t _MSKanji_wcrtomb(char * __restrict, wchar_t,
+-                  mbstate_t * __restrict);
++                  mbstate_t * __restrict, locale_t);
+ typedef struct {
+       wchar_t ch;
+ } _MSKanjiState;
+-int
+-_MSKanji_init(_RuneLocale *rl)
++__private_extern__ int
++_MSKanji_init(struct __xlocale_st_runelocale *xrl)
+ {
+-      __mbrtowc = _MSKanji_mbrtowc;
+-      __wcrtomb = _MSKanji_wcrtomb;
+-      __mbsinit = _MSKanji_mbsinit;
+-      _CurrentRuneLocale = rl;
+-      __mb_cur_max = 2;
+-      __mb_sb_limit = 256;
++      xrl->__mbrtowc = _MSKanji_mbrtowc;
++      xrl->__wcrtomb = _MSKanji_wcrtomb;
++      xrl->__mbsinit = _MSKanji_mbsinit;
++      xrl->__mb_cur_max = 2;
++      xrl->__mb_sb_limit = 256;
+       return (0);
+ }
+ static int
+-_MSKanji_mbsinit(const mbstate_t *ps)
++_MSKanji_mbsinit(const mbstate_t *ps, locale_t loc __unused)
+ {
+       return (ps == NULL || ((const _MSKanjiState *)ps)->ch == 0);
+@@ -81,7 +80,7 @@ _MSKanji_mbsinit(const mbstate_t *ps)
+ static size_t
+ _MSKanji_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
+-    mbstate_t * __restrict ps)
++    mbstate_t * __restrict ps, locale_t loc __unused)
+ {
+       _MSKanjiState *ms;
+       wchar_t wc;
+@@ -138,7 +137,7 @@ _MSKanji_mbrtowc(wchar_t * __restrict pw
+ }
+ static size_t
+-_MSKanji_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
++_MSKanji_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc __unused)
  {
-       rune_t rune = 0;
--      if (n < 1) {
--              if (result != NULL)
--                      *result = string;
-+      if (result != NULL)
-+              *result = string;
-+      if (n < 1)
-               return (_INVALID_RUNE);
--      }
-       rune = *string++ & 0xff;
-       if ((rune > 0x80 && rune < 0xa0) ||
-           (rune >= 0xe0 && rune < 0xfd)) {
--              if (n < 2) {
--                      rune = _INVALID_RUNE;
--                      --string;
--              } else
-+              if (n < 2)
-+                      return (_INVALID_RUNE);
-+              else
-                       rune = (rune << 8) | (*string++ & 0xff);
-+      }
-+      if (!isrune(rune)) {
-+              if (result != NULL)
-+                      (*result)++;
-+              return (_INVALID_RUNE);
-       }
-       if (result != NULL)
-               *result = string;
+       _MSKanjiState *ms;
+       int len, i;