Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -320,12 +320,12 @@ - replaceOccurrencesOfString: (OFString*)str withString: (OFString*)repl { const char *str_c = [str cString]; const char *repl_c = [repl cString]; - size_t str_len = [str length]; - size_t repl_len = [repl length]; + 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; Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -25,11 +25,11 @@ size_t pathlen, suffixlen; void *handle; OFPlugin *(*init_plugin)(); OFPlugin *plugin; - pathlen = [path length]; + pathlen = [path cStringLength]; suffixlen = strlen(PLUGIN_SUFFIX); if ((file = malloc(pathlen + suffixlen + 1)) == NULL) { @throw [OFOutOfMemoryException newWithClass: self size: pathlen + Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -203,11 +203,11 @@ selector: _cmd]; } - (size_t)writeString: (OFString*)str { - return [self writeNBytes: [str length] + return [self writeNBytes: [str cStringLength] fromBuffer: [str cString]]; } - (size_t)getCache: (char**)ptr { Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -69,11 +69,11 @@ * Creates a new OFString from a C string with the specified encoding and * length. * * \param str A C string to initialize the OFString with * \param encoding The encoding of the C string - * \param len The length of the string + * \param len The length of the C string * \return A new autoreleased OFString */ + stringWithCString: (const char*)str encoding: (enum of_string_encoding)encoding length: (size_t)len; @@ -81,11 +81,11 @@ /** * Creates a new OFString from a UTF-8 encoded C string with the specified * length. * * \param str A UTF-8 encoded C string to initialize the OFString with - * \param len The length of the string + * \param len The length of the UTF-8 encoded C string * \return A new autoreleased OFString */ + stringWithCString: (const char*)str length: (size_t)len; @@ -136,11 +136,11 @@ * Initializes an already allocated OFString from a C string with the specified * encoding and length. * * \param str A C string to initialize the OFString with * \param encoding The encoding of the C string - * \param len The length of the string + * \param len The length of the C string * \return An initialized OFString */ - initWithCString: (const char*)str encoding: (enum of_string_encoding)encoding length: (size_t)len; @@ -148,11 +148,11 @@ /** * Initializes an already allocated OFString from a UTF-8 encoded C string with * the specified length. * * \param str A UTF-8 encoded C string to initialize the OFString with - * \param len The length of the string + * \param len The length of the UTF-8 encoded C string * \return An initialized OFString */ - initWithCString: (const char*)str length: (size_t)len; @@ -188,13 +188,13 @@ * \return The OFString as a UTF-8 encoded C string */ - (const char*)cString; /** - * \return The length of the OFString + * \return The length of the string which cString would return */ -- (size_t)length; +- (size_t)cStringLength; /** * Compares the OFString to another object. * * \param obj An object to compare with Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -435,11 +435,11 @@ - initWithString: (OFString*)str { self = [super init]; string = strdup([str cString]); - length = [str length]; + length = [str cStringLength]; @try { [self addMemoryToPool: string]; } @catch (OFException *e) { /* @@ -458,11 +458,11 @@ - (const char*)cString { return string; } -- (size_t)length +- (size_t)cStringLength { return length; } - (BOOL)isEqual: (id)obj @@ -508,11 +508,11 @@ } - (size_t)indexOfFirstOccurrenceOfString: (OFString*)str { const char *str_c = [str cString]; - size_t str_len = [str length]; + size_t str_len = [str cStringLength]; size_t i; if (str_len == 0) return 0; @@ -527,11 +527,11 @@ } - (size_t)indexOfLastOccurrenceOfString: (OFString*)str { const char *str_c = [str cString]; - size_t str_len = [str length]; + size_t str_len = [str cStringLength]; size_t i; if (str_len == 0) return length; @@ -567,21 +567,21 @@ return [[OFMutableString stringWithString: self] appendString: str]; } - (BOOL)hasPrefix: (OFString*)prefix { - size_t len = [prefix length]; + size_t len = [prefix cStringLength]; if (len > length) return NO; return (memcmp(string, [prefix cString], len) ? NO : YES); } - (BOOL)hasSuffix: (OFString*)suffix { - size_t len = [suffix length]; + size_t len = [suffix cStringLength]; if (len > length) return NO; return (memcmp(string + (length - len), [suffix cString], len) @@ -591,11 +591,11 @@ - (OFArray*)splitWithDelimiter: (OFString*)delimiter { OFAutoreleasePool *pool; OFArray *array; const char *delim = [delimiter cString]; - size_t delim_len = [delimiter length]; + size_t delim_len = [delimiter cStringLength]; size_t i, last; array = [OFMutableArray array]; pool = [[OFAutoreleasePool alloc] init]; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -124,17 +124,17 @@ char *str_c; size_t len, i, j, attrs_count; OFXMLAttribute **attrs_data; OFString *ret, *tmp; - len = [name length] + 4; + len = [name cStringLength] + 4; str_c = [self allocMemoryWithSize: len]; /* Start of tag */ *str_c = '<'; - memcpy(str_c + 1, [name cString], [name length]); - i = [name length] + 1; + memcpy(str_c + 1, [name cString], [name cStringLength]); + i = [name cStringLength] + 1; /* Attributes */ attrs_data = [attrs data]; attrs_count = [attrs count]; @@ -141,11 +141,11 @@ for (j = 0; j < attrs_count; j++) { /* FIXME: Add namespace support */ OFString *attr_name = [attrs_data[j] name]; tmp = [[attrs_data[j] stringValue] stringByXMLEscaping]; - len += [attr_name length] + [tmp length] + 4; + len += [attr_name cStringLength] + [tmp cStringLength] + 4; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (OFException *e) { [self freeMemory: str_c]; @@ -152,16 +152,16 @@ @throw e; } str_c[i++] = ' '; memcpy(str_c + i, [attr_name cString], - [attr_name length]); - i += [attr_name length]; + [attr_name cStringLength]); + i += [attr_name cStringLength]; str_c[i++] = '='; str_c[i++] = '\''; - memcpy(str_c + i, [tmp cString], [tmp length]); - i += [tmp length]; + memcpy(str_c + i, [tmp cString], [tmp cStringLength]); + i += [tmp cStringLength]; str_c[i++] = '\''; [pool releaseObjects]; } @@ -182,26 +182,26 @@ append(tmp, @selector( appendCStringWithoutUTF8Checking:), [[data[j] string] cString]); } - len += [tmp length] + [name length] + 2; + len += [tmp cStringLength] + [name cStringLength] + 2; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (OFException *e) { [self freeMemory: str_c]; @throw e; } str_c[i++] = '>'; - memcpy(str_c + i, [tmp cString], [tmp length]); - i += [tmp length]; + memcpy(str_c + i, [tmp cString], [tmp cStringLength]); + i += [tmp cStringLength]; str_c[i++] = '<'; str_c[i++] = '/'; - memcpy(str_c + i, [name cString], [name length]); - i += [name length]; + memcpy(str_c + i, [name cString], [name cStringLength]); + i += [name cStringLength]; } else str_c[i++] = '/'; str_c[i++] = '>'; str_c[i++] = '\0'; Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -145,11 +145,11 @@ if (len > 0) [cache appendCString: buf + last withLength: len]; - if ([cache length] > 0) { + if ([cache cStringLength] > 0) { OFString *str; pool = [[OFAutoreleasePool alloc] init]; str = transform_string(cache, self); [delegate xmlParser: self @@ -187,11 +187,11 @@ len = i - last; if (len > 0) [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; - cache_len = [cache length]; + cache_len = [cache cStringLength]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 @@ -249,11 +249,11 @@ len = i - last; if (len > 0) [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; - cache_len = [cache length]; + cache_len = [cache cStringLength]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 @@ -349,11 +349,11 @@ if (len > 0) [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; - cache_len = [cache length]; + cache_len = [cache cStringLength]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL ) { attr_name = [[OFString alloc] initWithCString: tmp + 1 @@ -456,11 +456,11 @@ if (buf[i] == '-') { size_t cache_len; [cache appendCString: buf + last withLength: i - last]; - cache_len = [cache length]; + cache_len = [cache cStringLength]; pool = [[OFAutoreleasePool alloc] init]; [cache removeCharactersFromIndex: cache_len - 1 toIndex: cache_len]; [cache removeLeadingAndTrailingWhitespaces]; Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -86,11 +86,11 @@ [s2 appendString: @"3"]; [s4 setToCString: [s2 cString]]; CHECK(![s2 compare: s4]) CHECK([[s1 appendString: s2] isEqual: @"test123"]) - CHECK([s1 length] == 7) + CHECK([s1 cStringLength] == 7) CHECK([s1 hash] == 0xC44F49A4) CHECK([[s1 reverse] isEqual: @"321tset"]) CHECK([[s1 upper] isEqual: @"321TSET"]) CHECK([[s1 lower] isEqual: @"321tset"])