diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2014-07-14 05:00:54 -0700 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2014-07-14 05:00:54 -0700 |
commit | 9278e054e9a9a2aa8c73aed98cb42bf1f9bfd0fe (patch) | |
tree | e37940e2804c6c912e7a5891479d10ec576c88f1 | |
parent | 7b636720a46699e82c7caadf4550a0cd23571465 (diff) |
string fields: full compare
String fields also get used for arbitrary binary data, like
photos. In that case we need to compare the entire std::string,
not just the part before any embedded null byte.
This gets done using std::string::compare. Case-insensitive
comparison still uses C strucmp() and thus should never be used
for non-string data.
-rw-r--r-- | src/sysync/itemfield.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sysync/itemfield.cpp b/src/sysync/itemfield.cpp index e6f7d71..64867e0 100644 --- a/src/sysync/itemfield.cpp +++ b/src/sysync/itemfield.cpp @@ -801,7 +801,7 @@ bool TStringField::merge(TItemField &aItemField, const char aSep) // Note: Both fields must be assigned. NO TEST IS DONE HERE! sInt16 TStringField::compareWith(TItemField &aItemField, bool aCaseInsensitive) { - sInt16 result; + int result; PULLFROMPROXY; if (aItemField.isBasedOn(fty_string)) { TStringField *sfP = static_cast<TStringField *>(&aItemField); @@ -812,7 +812,7 @@ sInt16 TStringField::compareWith(TItemField &aItemField, bool aCaseInsensitive) if (aCaseInsensitive) result=strucmp(fString.c_str(),sfP->fString.c_str()); else - result=strcmp(fString.c_str(),sfP->fString.c_str()); + result=fString.compare(sfP->fString); } else { // convert other field to string @@ -821,7 +821,7 @@ sInt16 TStringField::compareWith(TItemField &aItemField, bool aCaseInsensitive) if (aCaseInsensitive) result=strucmp(fString.c_str(),s.c_str()); else - result=strcmp(fString.c_str(),s.c_str()); + result=fString.compare(s); } return result >0 ? 1 : (result<0 ? -1 : 0); } // TStringField::compareWith |