Differences From Artifact [b2dec79243]:
- File src/OFMutableString.m — part of check-in [1433aef0d0] at 2010-01-16 15:05:14 on branch trunk — Reduce dependencies between headers. (user: js, size: 10904) [annotate] [blame] [check-ins using]
To Artifact [5bfa0023ae]:
- File
src/OFMutableString.m
— part of check-in
[13f2a20288]
at
2010-01-30 18:29:28
on branch trunk
— Change how the Unicode table is stored.
The recent optimization had a bug in the range check and thus did not
notice that an int16_t is not enough to store the difference, thus
leading to broken results. This reverts it to the old way the Unicode
table was stored. (user: js, size: 10973) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
29 30 31 32 33 34 35 | #import "OFMacros.h" #import "asprintf.h" #import "unicode.h" static void apply_table(id self, Class isa, char **string, unsigned int *length, | | > | | | > > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #import "OFMacros.h" #import "asprintf.h" #import "unicode.h" static void apply_table(id self, Class isa, char **string, unsigned int *length, BOOL is_utf8, const of_unichar_t* const table[], const size_t table_size) { of_unichar_t c; of_unichar_t *ustr; size_t ulen, nlen, clen; size_t i, j, d; char *nstr; if (!is_utf8) { assert(table_size >= 1); uint8_t *p = (uint8_t*)*string + *length; while (--p >= (uint8_t*)*string) if (table[0][*p]) *p = table[0][*p]; return; } ulen = [self length]; ustr = [self allocMemoryForNItems: [self length] withSize: ulen]; i = 0; j = 0; nlen = 0; while (i < *length) { clen = of_string_utf8_to_unicode(*string + i, *length - i, &c); if (clen == 0 || c > 0x10FFFF) { [self freeMemory: ustr]; @throw [OFInvalidEncodingException newWithClass: isa]; } if (c >> 8 < table_size) { of_unichar_t tc = table[c >> 8][c & 0xFF]; if (tc) c = tc; } ustr[j++] = c; if (c < 0x80) nlen++; else if (c < 0x800) nlen += 2; else if (c < 0x10000) |
︙ | ︙ |