Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -354,16 +354,10 @@ { [self finishInitialization]; return [self stringByAppendingPathExtension: extension]; } -- (OFString *)stringByPrependingString: (OFString *)string -{ - [self finishInitialization]; - return [self stringByPrependingString: string]; -} - - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement { [self finishInitialization]; return [self stringByReplacingOccurrencesOfString: string Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -97,11 +97,11 @@ /** KOI8-R */ OFStringEncodingKOI8R, /** KOI8-U */ OFStringEncodingKOI8U, /** Try to automatically detect the encoding */ - OFStringEncodingAutodetect = 0xFF + OFStringEncodingAutodetect = -1 } OFStringEncoding; /** * @brief Options for searching in strings. * @@ -229,10 +229,12 @@ * @brief The string as an array of Unicode characters. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. + * + * The returned string is *not* null-terminated. */ @property (readonly, nonatomic) const OFUnichar *characters OF_RETURNS_INNER_POINTER; /** @@ -239,10 +241,12 @@ * @brief The string in UTF-16 encoding with native byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. + * + * The returned string is null-terminated. */ @property (readonly, nonatomic) const OFChar16 *UTF16String OF_RETURNS_INNER_POINTER; /** @@ -254,10 +258,12 @@ * @brief The string in UTF-32 encoding with native byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. + * + * The returned string is null-terminated. */ @property (readonly, nonatomic) const OFChar32 *UTF32String OF_RETURNS_INNER_POINTER; /** @@ -411,20 +417,20 @@ length: (size_t)length; /** * @brief Creates a new OFString from a UTF-16 encoded string. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const OFChar16 *)string; /** * @brief Creates a new OFString from a UTF-16 encoded string with the * specified length. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param length The length of the UTF-16 string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const OFChar16 *)string length: (size_t)length; @@ -431,11 +437,11 @@ /** * @brief Creates a new OFString from a UTF-16 encoded string, assuming the * specified byte order if no byte order mark is found. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const OFChar16 *)string byteOrder: (OFByteOrder)byteOrder; @@ -443,11 +449,11 @@ /** * @brief Creates a new OFString from a UTF-16 encoded string with the * specified length, assuming the specified byte order if no byte order * mark is found. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param length The length of the UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const OFChar16 *)string @@ -455,20 +461,20 @@ byteOrder: (OFByteOrder)byteOrder; /** * @brief Creates a new OFString from a UTF-32 encoded string. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF32String: (const OFChar32 *)string; /** * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param length The length of the UTF-32 string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF32String: (const OFChar32 *)string length: (size_t)length; @@ -475,11 +481,11 @@ /** * @brief Creates a new OFString from a UTF-32 encoded string, assuming the * specified byte order if no byte order mark is found. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ + (instancetype)stringWithUTF32String: (const OFChar32 *)string byteOrder: (OFByteOrder)byteOrder; @@ -487,11 +493,11 @@ /** * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length, assuming the specified byte order if no byte order * mark is found. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ + (instancetype)stringWithUTF32String: (const OFChar32 *)string @@ -669,20 +675,20 @@ length: (size_t)length; /** * @brief Initializes an already allocated OFString with a UTF-16 string. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @return An initialized OFString */ - (instancetype)initWithUTF16String: (const OFChar16 *)string; /** * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param length The length of the UTF-16 string * @return An initialized OFString */ - (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length; @@ -689,11 +695,11 @@ /** * @brief Initializes an already allocated OFString with a UTF-16 string, * assuming the specified byte order if no byte order mark is found. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ - (instancetype)initWithUTF16String: (const OFChar16 *)string byteOrder: (OFByteOrder)byteOrder; @@ -701,11 +707,11 @@ /** * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length, assuming the specified byte order if no byte * order mark is found. * - * @param string The UTF-16 string + * @param string A zero-terminated UTF-16 string * @param length The length of the UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ - (instancetype)initWithUTF16String: (const OFChar16 *)string @@ -713,20 +719,20 @@ byteOrder: (OFByteOrder)byteOrder; /** * @brief Initializes an already allocated OFString with a UTF-32 string. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @return An initialized OFString */ - (instancetype)initWithUTF32String: (const OFChar32 *)string; /** * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param length The length of the UTF-32 string * @return An initialized OFString */ - (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length; @@ -733,11 +739,11 @@ /** * @brief Initializes an already allocated OFString with a UTF-32 string, * assuming the specified byte order if no byte order mark is found. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ - (instancetype)initWithUTF32String: (const OFChar32 *)string byteOrder: (OFByteOrder)byteOrder; @@ -745,11 +751,11 @@ /** * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length, assuming the specified byte order if no byte * order mark is found. * - * @param string The UTF-32 string + * @param string A zero-terminated UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ - (instancetype)initWithUTF32String: (const OFChar32 *)string @@ -1092,18 +1098,10 @@ * @return A new, autoreleased OFString with the specified format appended */ - (OFString *)stringByAppendingFormat: (OFConstantString *)format arguments: (va_list)arguments; -/** - * @brief Creates a new string by prepending another string. - * - * @param string The string to prepend - * @return A new autoreleased OFString with the specified string prepended - */ -- (OFString *)stringByPrependingString: (OFString *)string; - /** * @brief Creates a new string by replacing the occurrences of the specified * string with the specified replacement. * * @param string The string to replace @@ -1119,11 +1117,11 @@ * * @param string The string to replace * @param replacement The string with which it should be replaced * @param options Options modifying search behaviour. * Possible values are: - * * None yet + * * None yet, pass 0 * @param range The range in which to replace the string * @return A new string with the occurrences of the specified string replaced */ - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement @@ -1194,10 +1192,12 @@ * @brief Returns the string in UTF-16 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. + * + * The returned string is null-terminated. * * @param byteOrder The byte order for the UTF-16 encoding * @return The string in UTF-16 encoding with the specified byte order */ - (const OFChar16 *)UTF16StringWithByteOrder: (OFByteOrder)byteOrder @@ -1207,10 +1207,12 @@ * @brief Returns the string in UTF-32 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. + * + * The returned string is null-terminated. * * @param byteOrder The byte order for the UTF-32 encoding * @return The string in UTF-32 encoding with the specified byte order */ - (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -2038,18 +2038,10 @@ [new appendFormat: format arguments: arguments]; [new makeImmutable]; return new; } -- (OFString *)stringByPrependingString: (OFString *)string -{ - OFMutableString *new = [[string mutableCopy] autorelease]; - [new appendString: self]; - [new makeImmutable]; - return new; -} - - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement { OFMutableString *new = [[self mutableCopy] autorelease]; [new replaceOccurrencesOfString: string withString: replacement]; Index: src/platform/Windows/OFString+PathAdditions.m ================================================================== --- src/platform/Windows/OFString+PathAdditions.m +++ src/platform/Windows/OFString+PathAdditions.m @@ -363,11 +363,11 @@ objectsInRange: OFMakeRange(2, components.count - 2)]]; } path = [path stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; - path = [path stringByPrependingString: @"/"]; + path = [@"/" stringByApppendingString: path]; return path; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost Index: src/platform/libfat/OFString+PathAdditions.m ================================================================== --- src/platform/libfat/OFString+PathAdditions.m +++ src/platform/libfat/OFString+PathAdditions.m @@ -342,11 +342,11 @@ [OFFileURLHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost { - return [self stringByPrependingString: @"/"]; + return [@"/" stringByApppendingString: self]; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost { OFString *path = self;