Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -533,11 +533,11 @@ pool = objc_autoreleasePoolPush(); ret = [[self componentsJoinedByString: @",\n"] mutableCopy]; @try { - [ret prependString: @"(\n"]; + [ret insertString: @"(\n" atIndex: 0]; [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)"]; } @catch (id e) { [ret release]; @throw e; Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -56,11 +56,11 @@ [mutableString replaceOccurrencesOfString: @"\f" withString: @"\\f"]; [mutableString replaceOccurrencesOfString: @"\r" withString: @"\\r"]; [mutableString replaceOccurrencesOfString: @"\n" withString: @"\\n"]; [mutableString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; - [mutableString prependString: @"\""]; + [mutableString insertString: @"\"" atIndex: 0]; [mutableString appendString: @"\""]; [mutableString makeImmutable]; return mutableString; Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -109,22 +109,10 @@ * @param format A format string which generates the string to append * @param arguments The arguments used in the format string */ - (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments; -/** - * @brief Prepends another OFString to the OFMutableString. - * - * @param string An OFString to prepend - */ -- (void)prependString: (OFString *)string; - -/** - * @brief Reverses the string. - */ -- (void)reverse; - /** * @brief Converts the string to uppercase. */ - (void)uppercase; Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -370,26 +370,10 @@ } @finally { free(UTF8String); } } -- (void)prependString: (OFString *)string -{ - [self insertString: string atIndex: 0]; -} - -- (void)reverse -{ - size_t i, j, length = self.length; - - for (i = 0, j = length - 1; i < length / 2; i++, j--) { - OFUnichar tmp = [self characterAtIndex: j]; - [self setCharacter: [self characterAtIndex: i] atIndex: j]; - [self setCharacter: tmp atIndex: i]; - } -} - #ifdef OF_HAVE_UNICODE_TABLES - (void)uppercase { [self of_convertWithWordStartTable: OFUnicodeUppercaseTable wordMiddleTable: OFUnicodeUppercaseTable Index: src/OFMutableUTF8String.m ================================================================== --- src/OFMutableUTF8String.m +++ src/OFMutableUTF8String.m @@ -423,90 +423,10 @@ } @finally { free(UTF8String); } } -- (void)reverse -{ - size_t i, j; - - _s->hasHash = false; - - /* We reverse all bytes and restore UTF-8 later, if necessary */ - for (i = 0, j = _s->cStringLength - 1; i < _s->cStringLength / 2; - i++, j--) { - _s->cString[i] ^= _s->cString[j]; - _s->cString[j] ^= _s->cString[i]; - _s->cString[i] ^= _s->cString[j]; - } - - if (!_s->isUTF8) - return; - - for (i = 0; i < _s->cStringLength; i++) { - /* ASCII */ - if OF_LIKELY (!(_s->cString[i] & 0x80)) - continue; - - /* A start byte can't happen first as we reversed everything */ - if OF_UNLIKELY (_s->cString[i] & 0x40) - @throw [OFInvalidEncodingException exception]; - - /* Next byte must not be ASCII */ - if OF_UNLIKELY (_s->cStringLength < i + 1 || - !(_s->cString[i + 1] & 0x80)) - @throw [OFInvalidEncodingException exception]; - - /* Next byte is the start byte */ - if OF_LIKELY (_s->cString[i + 1] & 0x40) { - _s->cString[i] ^= _s->cString[i + 1]; - _s->cString[i + 1] ^= _s->cString[i]; - _s->cString[i] ^= _s->cString[i + 1]; - - i++; - continue; - } - - /* Second next byte must not be ASCII */ - if OF_UNLIKELY (_s->cStringLength < i + 2 || - !(_s->cString[i + 2] & 0x80)) - @throw [OFInvalidEncodingException exception]; - - /* Second next byte is the start byte */ - if OF_LIKELY (_s->cString[i + 2] & 0x40) { - _s->cString[i] ^= _s->cString[i + 2]; - _s->cString[i + 2] ^= _s->cString[i]; - _s->cString[i] ^= _s->cString[i + 2]; - - i += 2; - continue; - } - - /* Third next byte must not be ASCII */ - if OF_UNLIKELY (_s->cStringLength < i + 3 || - !(_s->cString[i + 3] & 0x80)) - @throw [OFInvalidEncodingException exception]; - - /* Third next byte is the start byte */ - if OF_LIKELY (_s->cString[i + 3] & 0x40) { - _s->cString[i] ^= _s->cString[i + 3]; - _s->cString[i + 3] ^= _s->cString[i]; - _s->cString[i] ^= _s->cString[i + 3]; - - _s->cString[i + 1] ^= _s->cString[i + 2]; - _s->cString[i + 2] ^= _s->cString[i + 1]; - _s->cString[i + 1] ^= _s->cString[i + 2]; - - i += 3; - continue; - } - - /* UTF-8 does not allow more than 4 bytes per character */ - @throw [OFInvalidEncodingException exception]; - } -} - - (void)insertString: (OFString *)string atIndex: (size_t)idx { size_t newCStringLength; if (idx > _s->length) Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1754,21 +1754,21 @@ const char *cString = self.UTF8String; if ((!OFASCIIIsAlpha(cString[0]) && cString[0] != '_' && cString[0] != '$') || strpbrk(cString, " \n\r\t\b\f\\\"'") != NULL) { - [JSON prependString: @"\""]; + [JSON insertString: @"\"" atIndex: 0]; [JSON appendString: @"\""]; } } else { - [JSON prependString: @"\""]; + [JSON insertString: @"\"" atIndex: 0]; [JSON appendString: @"\""]; } } else { [JSON replaceOccurrencesOfString: @"\n" withString: @"\\n"]; - [JSON prependString: @"\""]; + [JSON insertString: @"\"" atIndex: 0]; [JSON appendString: @"\""]; } [JSON makeImmutable]; Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -399,11 +399,11 @@ if ((home = [env objectForKey: @"HOME"]) == nil) return nil; [path deleteCharactersInRange: OFMakeRange(0, 1)]; - [path prependString: home]; + [path insertString: home atIndex: 0]; } [path makeImmutable]; return [OFURL fileURLWithPath: path isDirectory: true]; @@ -488,11 +488,11 @@ if ((home = [env objectForKey: @"HOME"]) == nil) return nil; [path deleteCharactersInRange: OFMakeRange(0, 1)]; - [path prependString: home]; + [path insertString: home atIndex: 0]; } [path appendString: @"/Preferences"]; [path makeImmutable]; Index: src/platform/Windows/OFSubprocess.m ================================================================== --- src/platform/Windows/OFSubprocess.m +++ src/platform/Windows/OFSubprocess.m @@ -153,11 +153,11 @@ withString: @"\\\\\""]; [argumentsString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; if ([argumentsString containsString: @" "]) { - [argumentsString prependString: @"\""]; + [argumentsString insertString: @"\"" atIndex: 0]; [argumentsString appendString: @"\""]; } for (OFString *argument in arguments) { OFMutableString *tmp = Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -292,29 +292,26 @@ [mutableString1 characterAtIndex: 5] == 0x1D11E) EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]", OFOutOfRangeException, [mutableString1 characterAtIndex: 7]) - TEST(@"-[reverse]", - R([mutableString1 reverse]) && [mutableString1 isEqual: @"3𝄞1€sät"]) - mutableString2 = [mutableStringClass stringWithString: @"abc"]; #ifdef OF_HAVE_UNICODE_TABLES TEST(@"-[uppercase]", R([mutableString1 uppercase]) && - [mutableString1 isEqual: @"3𝄞1€SÄT"] && + [mutableString1 isEqual: @"TÄS€1𝄞3"] && R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"]) TEST(@"-[lowercase]", R([mutableString1 lowercase]) && - [mutableString1 isEqual: @"3𝄞1€sät"] && + [mutableString1 isEqual: @"täs€1𝄞3"] && R([mutableString2 lowercase]) && [mutableString2 isEqual: @"abc"]) TEST(@"-[uppercaseString]", - [[mutableString1 uppercaseString] isEqual: @"3𝄞1€SÄT"]) + [[mutableString1 uppercaseString] isEqual: @"TÄS€1𝄞3"]) TEST(@"-[lowercaseString]", R([mutableString1 uppercase]) && - [[mutableString1 lowercaseString] isEqual: @"3𝄞1€sät"]) + [[mutableString1 lowercaseString] isEqual: @"täs€1𝄞3"]) TEST(@"-[capitalizedString]", [C(@"džbla tdžst TDŽST").capitalizedString isEqual: @"Džbla Tdžst Tdžst"]) #else TEST(@"-[uppercase]", R([mutableString1 uppercase]) && @@ -545,13 +542,10 @@ [C(@"𝄞öö") substringWithRange: OFMakeRange(4, 0)]) TEST(@"-[stringByAppendingString:]", [[C(@"foo") stringByAppendingString: @"bar"] isEqual: @"foobar"]) - TEST(@"-[stringByPrependingString:]", - [[C(@"foo") stringByPrependingString: @"bar"] isEqual: @"barfoo"]) - #ifdef OF_HAVE_FILES # if defined(OF_WINDOWS) TEST(@"-[isAbsolutePath]", C(@"C:\\foo").absolutePath && C(@"a:/foo").absolutePath && !C(@"foo").absolutePath && !C(@"b:foo").absolutePath &&