Fix comparing strings of different lengths

Strings should not compare equal if they only share a common prefix.
qteditor
Armin Burgmeier 2016-04-10 12:06:34 -07:00
parent 208cb12b2e
commit d04c4a16ae
1 changed files with 6 additions and 1 deletions

View File

@ -484,7 +484,12 @@ public:
int Compare(const StdStrBuf &Buf2, size_t iAt = 0) const
{
assert(iAt <= getLength());
return StdBuf::Compare(Buf2.getData(), std::min(getLength(), Buf2.getLength()), iAt);
const int result = StdBuf::Compare(Buf2.getData(), std::min(getLength() - iAt, Buf2.getLength()), iAt);
if (result) return result;
if (getLength() < Buf2.getLength()) return -1;
else if (getLength() > Buf2.getLength()) return 1;
return 0;
}
int Compare_(const char *pCData, size_t iAt = 0) const
{