@@ -120,11 +120,11 @@ *string = nstr; *length = nlen; } @implementation OFMutableString -- setToCString: (const char*)str +- (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; @@ -146,15 +146,13 @@ } length = len; string = [self allocMemoryWithSize: length + 1]; memcpy(string, str, length + 1); - - return self; } -- appendCString: (const char*)str +- (void)appendCString: (const char*)str { size_t strlength; strlength = strlen(str); @@ -168,16 +166,14 @@ string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; - - return self; } -- appendCString: (const char*)str - withLength: (size_t)len +- (void)appendCString: (const char*)str + withLength: (size_t)len { if (len > strlen(str)) @throw [OFOutOfRangeException newWithClass: isa]; switch (of_string_check_utf8(str, len)) { @@ -191,64 +187,53 @@ string = [self resizeMemory: string toSize: length + len + 1]; memcpy(string + length, str, len); length += len; string[length] = 0; - - return self; } -- appendCStringWithoutUTF8Checking: (const char*)str +- (void)appendCStringWithoutUTF8Checking: (const char*)str { size_t strlength; strlength = strlen(str); string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; - - return self; } -- appendCStringWithoutUTF8Checking: (const char*)str - length: (size_t)len +- (void)appendCStringWithoutUTF8Checking: (const char*)str + length: (size_t)len { if (len > strlen(str)) @throw [OFOutOfRangeException newWithClass: isa]; string = [self resizeMemory: string toSize: length + len + 1]; memcpy(string + length, str, len); length += len; string[length] = 0; - - return self; } -- appendString: (OFString*)str +- (void)appendString: (OFString*)str { [self appendCString: [str cString]]; - - return self; } -- appendFormat: (OFString*)fmt, ... +- (void)appendFormat: (OFString*)fmt, ... { - id ret; va_list args; va_start(args, fmt); - ret = [self appendFormat: fmt - withArguments: args]; + [self appendFormat: fmt + withArguments: args]; va_end(args); - - return ret; } -- appendFormat: (OFString*)fmt - withArguments: (va_list)args +- (void)appendFormat: (OFString*)fmt + withArguments: (va_list)args { char *t; if (fmt == nil) @throw [OFInvalidArgumentException newWithClass: isa @@ -265,15 +250,13 @@ @try { [self appendCString: t]; } @finally { free(t); } - - return self; } -- reverse +- (void)reverse { size_t i, j, len = length / 2; madvise(string, len, MADV_SEQUENTIAL); @@ -284,11 +267,11 @@ string[i] ^= string[j]; } if (!is_utf8) { madvise(string, len, MADV_NORMAL); - return self; + return; } for (i = 0; i < length; i++) { /* ASCII */ if (OF_LIKELY(!(string[i] & 0x80))) @@ -356,32 +339,26 @@ madvise(string, len, MADV_NORMAL); @throw [OFInvalidEncodingException newWithClass: isa]; } madvise(string, len, MADV_NORMAL); - - return self; } -- upper +- (void)upper { apply_table(self, isa, &string, &length, is_utf8, of_unicode_upper_table, OF_UNICODE_UPPER_TABLE_SIZE); - - return self; } -- lower +- (void)lower { apply_table(self, isa, &string, &length, is_utf8, of_unicode_lower_table, OF_UNICODE_LOWER_TABLE_SIZE); - - return self; } -- removeCharactersFromIndex: (size_t)start - toIndex: (size_t)end +- (void)removeCharactersFromIndex: (size_t)start + toIndex: (size_t)end { if (is_utf8) { start = of_string_index_to_position(string, start, length); end = of_string_index_to_position(string, end, length); } @@ -402,32 +379,30 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; -} - -- removeCharactersInRange: (of_range_t)range -{ - return [self removeCharactersFromIndex: range.start - toIndex: range.start + range.length]; +} + +- (void)removeCharactersInRange: (of_range_t)range +{ + [self removeCharactersFromIndex: range.start + toIndex: range.start + range.length]; } -- replaceOccurrencesOfString: (OFString*)str - withString: (OFString*)repl +- (void)replaceOccurrencesOfString: (OFString*)str + withString: (OFString*)repl { const char *str_c = [str cString]; const char *repl_c = [repl cString]; size_t str_len = [str cStringLength]; size_t repl_len = [repl cStringLength]; size_t i, last, tmp_len; char *tmp; if (str_len > length) - return self; + return; tmp = NULL; tmp_len = 0; for (i = 0, last = 0; i <= length - str_len; i++) { @@ -461,15 +436,13 @@ tmp[tmp_len] = 0; [self freeMemory: string]; string = tmp; length = tmp_len; - - return self; } -- removeLeadingWhitespaces +- (void)removeLeadingWhitespaces { size_t i; for (i = 0; i < length; i++) if (string[i] != ' ' && string[i] != '\t' && @@ -485,15 +458,13 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } -- removeTrailingWhitespaces +- (void)removeTrailingWhitespaces { size_t d; char *p; d = 0; @@ -512,15 +483,13 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } -- removeLeadingAndTrailingWhitespaces +- (void)removeLeadingAndTrailingWhitespaces { size_t d, i; char *p; d = 0; @@ -548,14 +517,12 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } - (id)copy { return [[OFString alloc] initWithString: self]; } @end