Fixed equals on zstring when length mismatches occured.

This commit is contained in:
Brad Arant 2021-08-31 17:59:24 -07:00
parent deb88cb14d
commit 191899fbb7
2 changed files with 24 additions and 11 deletions

View File

@ -36,7 +36,7 @@ namespace coreutils {
data = zstring.data; data = zstring.data;
length = zstring.length; length = zstring.length;
cursor = zstring.cursor; cursor = zstring.cursor;
Log(LOG_DEBUG_2) << "ZSrting Copy Constructor: "; // Log(LOG_DEBUG_2) << "ZSrting Copy Constructor: ";
} }
std::vector<ZString> &ZString::getList() { std::vector<ZString> &ZString::getList() {
@ -115,6 +115,14 @@ namespace coreutils {
} }
bool ZString::equals(const char *value) { bool ZString::equals(const char *value) {
if(strlen(value) != length)
return false;
return strncmp(data, value, length) == 0;
}
bool ZString::equals(char *value) {
if(strlen(value) != length)
return false;
return strncmp(data, value, length) == 0; return strncmp(data, value, length) == 0;
} }

View File

@ -58,7 +58,6 @@ namespace coreutils {
friend std::ostream& operator<<(std::ostream& os, const ZString& zstring); friend std::ostream& operator<<(std::ostream& os, const ZString& zstring);
friend std::ostream& operator<<(std::ostream& os, const std::string& string); friend std::ostream& operator<<(std::ostream& os, const std::string& string);
friend std::ostream& operator+(std::ostream& os, const ZString& zstring); friend std::ostream& operator+(std::ostream& os, const ZString& zstring);
/// ///
@ -138,6 +137,12 @@ namespace coreutils {
/// ///
/// ///
bool equals(char *value);
///
///
///
bool equals(ZString &zstring); bool equals(ZString &zstring);
/// ///