forked from qt-creator/qt-creator
Differ: Fix broken logical XOR
I bet the intention was to do logical XOR operation.
In cpp it's done with operator!=().
Amends: 24a25eed14
Change-Id: Idfc5dbf09b4f4b6c81aa237a956d5d4e04155c09
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -496,7 +496,7 @@ static QString encodeExpandedWhitespace(const QString &leftEquality,
|
|||||||
*ok = false;
|
*ok = false;
|
||||||
|
|
||||||
if (!leftCodeMap || !rightCodeMap)
|
if (!leftCodeMap || !rightCodeMap)
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
leftCodeMap->clear();
|
leftCodeMap->clear();
|
||||||
rightCodeMap->clear();
|
rightCodeMap->clear();
|
||||||
@@ -520,17 +520,17 @@ static QString encodeExpandedWhitespace(const QString &leftEquality,
|
|||||||
|
|
||||||
if (leftIndex < leftCount && rightIndex < rightCount) {
|
if (leftIndex < leftCount && rightIndex < rightCount) {
|
||||||
if (leftEquality.at(leftIndex) != rightEquality.at(rightIndex))
|
if (leftEquality.at(leftIndex) != rightEquality.at(rightIndex))
|
||||||
return QString(); // equalities broken
|
return {}; // equalities broken
|
||||||
|
|
||||||
} else if (leftIndex == leftCount && rightIndex == rightCount) {
|
} else if (leftIndex == leftCount && rightIndex == rightCount) {
|
||||||
; // do nothing, the last iteration
|
; // do nothing, the last iteration
|
||||||
} else {
|
} else {
|
||||||
return QString(); // equalities broken
|
return {}; // equalities broken
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftWhitespaces.isEmpty() ^ rightWhitespaces.isEmpty()) {
|
if (leftWhitespaces.isEmpty() != rightWhitespaces.isEmpty()) {
|
||||||
// there must be at least 1 corresponding whitespace, equalities broken
|
// there must be at least 1 corresponding whitespace, equalities broken
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!leftWhitespaces.isEmpty() && !rightWhitespaces.isEmpty()) {
|
if (!leftWhitespaces.isEmpty() && !rightWhitespaces.isEmpty()) {
|
||||||
@@ -1233,8 +1233,7 @@ QStringList Differ::encode(const QString &text1,
|
|||||||
QString *encodedText1,
|
QString *encodedText1,
|
||||||
QString *encodedText2)
|
QString *encodedText2)
|
||||||
{
|
{
|
||||||
QStringList lines;
|
QStringList lines{{}}; // don't use code: 0
|
||||||
lines.append(QString()); // don't use code: 0
|
|
||||||
QMap<QString, int> lineToCode;
|
QMap<QString, int> lineToCode;
|
||||||
|
|
||||||
*encodedText1 = encode(text1, &lines, &lineToCode);
|
*encodedText1 = encode(text1, &lines, &lineToCode);
|
||||||
|
Reference in New Issue
Block a user