Index: src/OFConstString.h ================================================================== --- src/OFConstString.h +++ src/OFConstString.h @@ -21,6 +21,7 @@ + new: (const char*)str; - init; - init: (const char*)str; - (const char*)cString; - (size_t)length; +- (int)compare: (OFConstString*)str; @end Index: src/OFConstString.m ================================================================== --- src/OFConstString.m +++ src/OFConstString.m @@ -44,6 +44,11 @@ - (size_t)length { return length; } + +- (int)compare: (OFConstString*)str +{ + return strcmp(string, [str cString]); +} @end Index: src/OFConstWideString.h ================================================================== --- src/OFConstWideString.h +++ src/OFConstWideString.h @@ -22,6 +22,7 @@ + new: (const wchar_t*)wstr; - init; - init: (const wchar_t*)wstr; - (const wchar_t*)wcString; - (size_t)length; +- (int)compare: (OFConstWideString*)str; @end Index: src/OFConstWideString.m ================================================================== --- src/OFConstWideString.m +++ src/OFConstWideString.m @@ -44,6 +44,11 @@ - (size_t)length { return length; } + +- (int)compare: (OFConstWideString*)str +{ + return wcscmp(wstring, [str wcString]); +} @end Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -24,6 +24,7 @@ - (char*)cString; - (size_t)length; - (OFString*)setTo: (const char*)str; - (OFString*)clone; - (OFString*)append: (const char*)str; +- (int)compare: (OFString*)str; @end Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -101,6 +101,11 @@ length = newlen; string = newstr; return self; } + +- (int)compare: (OFString*)str +{ + return strcmp(string, [str cString]); +} @end Index: src/OFWideString.h ================================================================== --- src/OFWideString.h +++ src/OFWideString.h @@ -25,6 +25,7 @@ - (wchar_t*)wcString; - (size_t)length; - (OFWideString*)setTo: (const wchar_t*)wstr; - (OFWideString*)clone; - (OFWideString*)append: (const wchar_t*)wstr; +- (int)compare: (OFWideString*)str; @end Index: src/OFWideString.m ================================================================== --- src/OFWideString.m +++ src/OFWideString.m @@ -102,6 +102,11 @@ length = newlen; wstring = newstr; return self; } + +- (int)compare: (OFWideString*)str +{ + return wcscmp(wstring, [str wcString]); +} @end Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -27,18 +27,18 @@ [s2 append: "123"]; s3 = [s1 clone]; [s4 setTo: [s2 cString]]; - if (!strcmp([s1 cString], [s3 cString])) + if (![s1 compare: s3]) puts("s1 and s3 match! GOOD!"); else { puts("s1 and s3 don't match!"); return 1; } - if (!strcmp([s2 cString], [s4 cString])) + if (![s2 compare: s4]) puts("s2 and s4 match! GOOD!"); else { puts("s1 and s3 don't match!"); return 1; } Index: tests/OFWideString/OFWideString.m ================================================================== --- tests/OFWideString/OFWideString.m +++ tests/OFWideString/OFWideString.m @@ -26,18 +26,18 @@ [s2 append: L"123"]; s3 = [s1 clone]; [s4 setTo: [s2 wcString]]; - if (!wcscmp([s1 wcString], [s3 wcString])) + if (![s1 compare: s3]) puts("s1 and s3 match! GOOD!"); else { puts("s1 and s3 don't match!"); return 1; } - if (!wcscmp([s2 wcString], [s4 wcString])) + if (![s2 compare: s4]) puts("s2 and s4 match! GOOD!"); else { puts("s1 and s3 don't match!"); return 1; }