Completed ZString::compare method.

This commit is contained in:
Brad Arant committed 2024-07-24 17:01:25 +00:00
1 parent 6409bd2444
commit ad74a9de85
2 files changed
+26 -2

No files matched your search

+18 -1
View File
@@ -1,3 +1,4 @@
#include "ZString.h"
#include "Log.h"
#include "Exception.h"
@@ -251,7 +252,23 @@ namespace coreutils {
}
int ZString::compare(ZString zstring) {
char *end1 = data + length;
char *end2 = zstring.getData() + getLength();
char *cursor1 = cursor;
char *cursor2 = zstring.getCursor();
while((cursor1 < end1) && (cursor2 < end2)) {
if(*cursor1 < *cursor2)
return -1;
if(*cursor1 > *cursor2)
return 1;
++cursor1;
++cursor2;
}
if((cursor1 == end1) && (cursor2 != end2))
return -1;
if((cursor2 == end2) && (cursor1 != end1))
return 1;
return 0;
}
bool ZString::equals(const char *value) {