@@ -1265,11 +1265,11 @@ characters = [self characters]; otherCharacters = [otherString characters]; if (memcmp(characters, otherCharacters, - length * sizeof(of_unichar_t))) { + length * sizeof(of_unichar_t)) != 0) { objc_autoreleasePoolPop(pool); return false; } objc_autoreleasePoolPop(pool); @@ -1594,12 +1594,12 @@ [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (i = range.length - searchLength;; i--) { - if (!memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t))) { + if (memcmp(characters + i, searchCharacters, + searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); } @@ -1607,12 +1607,12 @@ if (i == 0) break; } } else { for (i = 0; i <= range.length - searchLength; i++) { - if (!memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t))) { + if (memcmp(characters + i, searchCharacters, + searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); } } @@ -1642,12 +1642,12 @@ characters = [self characters]; searchCharacters = [string characters]; for (i = 0; i <= length - searchLength; i++) { - if (!memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t))) { + if (memcmp(characters + i, searchCharacters, + searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return true; } } @@ -1836,11 +1836,11 @@ - (bool)hasPrefix: (OFString*)prefix { of_unichar_t *tmp; const of_unichar_t *prefixCharacters; size_t prefixLength; - int compare; + bool hasPrefix; if ((prefixLength = [prefix length]) > [self length]) return false; tmp = [self allocMemoryWithSize: sizeof(of_unichar_t) @@ -1850,27 +1850,27 @@ [self getCharacters: tmp inRange: of_range(0, prefixLength)]; prefixCharacters = [prefix characters]; - compare = memcmp(tmp, prefixCharacters, - prefixLength * sizeof(of_unichar_t)); + hasPrefix = (memcmp(tmp, prefixCharacters, + prefixLength * sizeof(of_unichar_t)) == 0); objc_autoreleasePoolPop(pool); } @finally { [self freeMemory: tmp]; } - return !compare; + return hasPrefix; } - (bool)hasSuffix: (OFString*)suffix { of_unichar_t *tmp; const of_unichar_t *suffixCharacters; size_t length, suffixLength; - int compare; + bool hasSuffix; if ((suffixLength = [suffix length]) > [self length]) return false; length = [self length]; @@ -1883,19 +1883,19 @@ [self getCharacters: tmp inRange: of_range(length - suffixLength, suffixLength)]; suffixCharacters = [suffix characters]; - compare = memcmp(tmp, suffixCharacters, - suffixLength * sizeof(of_unichar_t)); + hasSuffix = (memcmp(tmp, suffixCharacters, + suffixLength * sizeof(of_unichar_t)) == 0); objc_autoreleasePoolPop(pool); } @finally { [self freeMemory: tmp]; } - return !compare; + return hasSuffix; } - (OFArray*)componentsSeparatedByString: (OFString*)delimiter { return [self componentsSeparatedByString: delimiter @@ -1928,11 +1928,11 @@ return array; } for (i = 0, last = 0; i <= length - delimiterLength; i++) { if (memcmp(characters + i, delimiterCharacters, - delimiterLength * sizeof(of_unichar_t))) + delimiterLength * sizeof(of_unichar_t)) != 0) continue; component = [self substringWithRange: of_range(last, i - last)]; if (!skipEmpty || [component length] > 0) [array addObject: component];