Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -29,13 +29,13 @@ #import "macros.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) +@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; @@ -42,14 +42,14 @@ char *nstr; if (!is_utf8) { assert(table_size >= 1); - uint8_t *p = (uint8_t*)*string + *length; + uint8_t *p = (uint8_t*)string + length; uint8_t t; - while (--p >= (uint8_t*)*string) + while (--p >= (uint8_t*)string) if ((t = table[0][*p]) != 0) *p = t; return; } @@ -60,12 +60,12 @@ i = 0; j = 0; nlen = 0; - while (i < *length) { - clen = of_string_utf8_to_unicode(*string + i, *length - i, &c); + 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]; } @@ -114,16 +114,15 @@ assert(j == nlen); nstr[j] = 0; [self freeMemory: ustr]; - [self freeMemory: *string]; - *string = nstr; - *length = nlen; + [self freeMemory: string]; + string = nstr; + length = nlen; } -@implementation OFMutableString - (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; @@ -343,18 +342,18 @@ madvise(string, len, MADV_NORMAL); } - (void)upper { - apply_table(self, isa, &string, &length, is_utf8, - of_unicode_upper_table, OF_UNICODE_UPPER_TABLE_SIZE); + [self _applyTable: of_unicode_upper_table + withSize: OF_UNICODE_UPPER_TABLE_SIZE]; } - (void)lower { - apply_table(self, isa, &string, &length, is_utf8, - of_unicode_lower_table, OF_UNICODE_LOWER_TABLE_SIZE); + [self _applyTable: of_unicode_lower_table + withSize: OF_UNICODE_LOWER_TABLE_SIZE]; } - (void)removeCharactersFromIndex: (size_t)start toIndex: (size_t)end {