Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -305,10 +305,16 @@ * \return The index of the last occurrence of the string or SIZE_MAX if it * was not found */ - (size_t)indexOfLastOccurrenceOfString: (OFString*)str; +/** + * \param str The string to search + * \return Whether the string contains the specified string + */ +- (BOOL)containsString: (OFString*)str; + /** * \param start The index where the substring starts * \param end The index where the substring ends. * This points BEHIND the last character! * \return The substring as a new autoreleased OFString Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -888,10 +888,29 @@ /* Did not match and we're at the last char */ if (i == 0) return SIZE_MAX; } } + +- (BOOL)containsString: (OFString*)str +{ + const char *str_c = [str cString]; + size_t str_len = [str cStringLength]; + size_t i; + + if (str_len == 0) + return YES; + + if (str_len > length) + return NO; + + for (i = 0; i <= length - str_len; i++) + if (!memcmp(string + i, str_c, str_len)) + return YES; + + return NO; +} - (OFString*)substringFromIndex: (size_t)start toIndex: (size_t)end { if ([self isUTF8]) {