]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/mskanji.c.patch
Libc-320.tar.gz
[apple/libc.git] / locale / FreeBSD / mskanji.c.patch
1 --- mskanji.c.orig Tue May 20 15:21:44 2003
2 +++ mskanji.c Wed Jun 18 12:02:06 2003
3 @@ -43,6 +43,7 @@
4 #include <stddef.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 +#include <ctype.h>
8
9 rune_t _MSKanji_sgetrune(const char *, size_t, char const **);
10 int _MSKanji_sputrune(rune_t, char *, size_t, char **);
11 @@ -67,20 +68,23 @@
12 {
13 rune_t rune = 0;
14
15 - if (n < 1) {
16 - if (result != NULL)
17 - *result = string;
18 + if (result != NULL)
19 + *result = string;
20 + if (n < 1)
21 return (_INVALID_RUNE);
22 - }
23
24 rune = *string++ & 0xff;
25 if ((rune > 0x80 && rune < 0xa0) ||
26 (rune >= 0xe0 && rune < 0xfd)) {
27 - if (n < 2) {
28 - rune = _INVALID_RUNE;
29 - --string;
30 - } else
31 + if (n < 2)
32 + return (_INVALID_RUNE);
33 + else
34 rune = (rune << 8) | (*string++ & 0xff);
35 + }
36 + if (!isrune(rune)) {
37 + if (result != NULL)
38 + (*result)++;
39 + return (_INVALID_RUNE);
40 }
41 if (result != NULL)
42 *result = string;