Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -16,11 +16,11 @@ #import "OFDictionary.h" #import "OFIterator.h" #import "OFExceptions.h" /* Reference for static linking */ -void _reference_to_OFIterator_in_OFDictionary() +void _references_to_categories_of_OFDictionary() { _OFIterator_reference = 1; } @implementation OFDictionary Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -30,10 +30,21 @@ * * \param str A C string to append */ - appendCString: (const char*)str; +/** + * Appends a C string to the OFString without checking whether it is valid + * UTF-8. + * + * Only use this if you are 100% sure the string you append is either ASCII or + * UTF-8! + * + * \param str A C string to append + */ +- appendCStringWithoutUTF8Checking: (const char*)str; + /** * Appends another OFString to the OFString. * * \param str An OFString to append */ Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -83,14 +83,27 @@ memcpy(string + length, str, strlength + 1); length += strlength; return self; } + +- 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; +} - appendString: (OFString*)str { - return [self appendCString: [str cString]]; + return [self appendCStringWithoutUTF8Checking: [str cString]]; } - appendWithFormat: (OFString*)fmt, ... { id ret; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -134,10 +134,11 @@ */ - (OFArray*)splitWithDelimiter: (OFString*)delimiter; - setToCString: (const char*)str; - appendCString: (const char*)str; +- appendCStringWithoutUTF8Checking: (const char*)str; - appendString: (OFString*)str; - appendWithFormat: (OFString*)fmt, ...; - appendWithFormat: (OFString*)fmt andArguments: (va_list)args; - reverse; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -29,11 +29,11 @@ #import "OFMacros.h" #import "asprintf.h" /* Reference for static linking */ -void _reference_to_OFURLEncoding_in_OFString() +void _references_to_categories_of_OFString() { _OFURLEncoding_reference = 1; }; int @@ -369,10 +369,16 @@ @throw [OFNotImplementedException newWithClass: isa andSelector: _cmd]; } - appendCString: (const char*)str +{ + @throw [OFNotImplementedException newWithClass: isa + andSelector: _cmd]; +} + +- appendCStringWithoutUTF8Checking: (const char*)str { @throw [OFNotImplementedException newWithClass: isa andSelector: _cmd]; }