]>
Commit | Line | Data |
---|---|---|
9385eb3d A |
1 | --- utf8.c.orig Tue May 20 15:21:44 2003 |
2 | +++ utf8.c Wed Jun 18 12:07:28 2003 | |
3 | @@ -53,11 +53,10 @@ | |
4 | int ch, len, mask; | |
5 | rune_t lbound, wch; | |
6 | ||
7 | - if (n < 1) { | |
8 | - if (result != NULL) | |
9 | - *result = string; | |
10 | + if (result != NULL) | |
11 | + *result = string; | |
12 | + if (n < 1) | |
13 | return (_INVALID_RUNE); | |
14 | - } | |
15 | ||
16 | /* | |
17 | * Determine the number of octets that make up this character from | |
18 | @@ -100,18 +99,15 @@ | |
19 | * Malformed input; input is not UTF-8. | |
20 | */ | |
21 | if (result != NULL) | |
22 | - *result = string + 1; | |
23 | + (*result)++; | |
24 | return (_INVALID_RUNE); | |
25 | } | |
26 | ||
27 | - if (n < len) { | |
28 | + if (n < len) | |
29 | /* | |
30 | * Truncated or partial input. | |
31 | */ | |
32 | - if (result != NULL) | |
33 | - *result = string; | |
34 | return (_INVALID_RUNE); | |
35 | - } | |
36 | ||
37 | /* | |
38 | * Decode the octet sequence representing the character in chunks | |
39 | @@ -124,19 +120,21 @@ | |
40 | * Malformed input; bad characters in the middle | |
41 | * of a character. | |
42 | */ | |
43 | - wch = _INVALID_RUNE; | |
44 | if (result != NULL) | |
45 | - *result = string + 1; | |
46 | + (*result)++; | |
47 | return (_INVALID_RUNE); | |
48 | } | |
49 | wch <<= 6; | |
50 | wch |= *string++ & 0x3f; | |
51 | } | |
52 | - if (wch != _INVALID_RUNE && wch < lbound) | |
53 | + if (wch < lbound) { | |
54 | /* | |
55 | * Malformed input; redundant encoding. | |
56 | */ | |
57 | - wch = _INVALID_RUNE; | |
58 | + if (result != NULL) | |
59 | + (*result)++; | |
60 | + return (_INVALID_RUNE); | |
61 | + } | |
62 | if (result != NULL) | |
63 | *result = string; | |
64 | return (wch); |