Overview
Comment: | Make applying a table a private method. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
baeb7b379ac63c3060c3d285ff6681fe |
User & Date: | js on 2010-04-17 15:56:02 |
Other Links: | manifest | tags |
Context
2010-04-17
| ||
16:01 | Add class OFHash as a superclass for OFMD5Hash and OFSHA1Hash. check-in: d28c998082 user: js tags: trunk | |
15:56 | Make applying a table a private method. check-in: baeb7b379a user: js tags: trunk | |
15:46 | Don't return self where not necessary, return void or something useful. check-in: 062a052b50 user: js tags: trunk | |
Changes
Modified src/OFMutableString.m from [702fa32298] to [276880c8d3].
︙ | ︙ | |||
27 28 29 30 31 32 33 | #import "OFString.h" #import "OFExceptions.h" #import "macros.h" #import "asprintf.h" #import "unicode.h" | | < | > | | | | | 27 28 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 | #import "OFString.h" #import "OFExceptions.h" #import "macros.h" #import "asprintf.h" #import "unicode.h" @implementation OFMutableString - (void)_applyTable: (const of_unichar_t* const[])table withSize: (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; uint8_t t; while (--p >= (uint8_t*)string) if ((t = table[0][*p]) != 0) *p = t; 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) { |
︙ | ︙ | |||
112 113 114 115 116 117 118 | j += d; } assert(j == nlen); nstr[j] = 0; [self freeMemory: ustr]; | | | | < | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | j += d; } assert(j == nlen); nstr[j] = 0; [self freeMemory: ustr]; [self freeMemory: string]; string = nstr; length = nlen; } - (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; len = strlen(str); |
︙ | ︙ | |||
341 342 343 344 345 346 347 | } madvise(string, len, MADV_NORMAL); } - (void)upper { | | | | | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | } madvise(string, len, MADV_NORMAL); } - (void)upper { [self _applyTable: of_unicode_upper_table withSize: OF_UNICODE_UPPER_TABLE_SIZE]; } - (void)lower { [self _applyTable: of_unicode_lower_table withSize: OF_UNICODE_LOWER_TABLE_SIZE]; } - (void)removeCharactersFromIndex: (size_t)start toIndex: (size_t)end { if (is_utf8) { start = of_string_index_to_position(string, start, length); |
︙ | ︙ |