Commit 29042af9 authored by Michael Reeves's avatar Michael Reeves

Stop abusing []

Pass QVector<LineData> if that's needed don't make assumtions
about the memmory layout of classes especial ones we don't control.
parent 86b756db
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "MergeEditLine.h" #include "MergeEditLine.h"
QString MergeEditLine::getString(const LineData* pLineDataA, const LineData* pLineDataB, const LineData* pLineDataC) QString MergeEditLine::getString(const QVector<LineData>* pLineDataA, const QVector<LineData>* pLineDataB, const QVector<LineData>* pLineDataC)
{ {
if(isRemoved()) if(isRemoved())
{ {
...@@ -29,11 +29,11 @@ QString MergeEditLine::getString(const LineData* pLineDataA, const LineData* pLi ...@@ -29,11 +29,11 @@ QString MergeEditLine::getString(const LineData* pLineDataA, const LineData* pLi
const LineData* pld = nullptr; const LineData* pld = nullptr;
Q_ASSERT(src == A || src == B || src == C); Q_ASSERT(src == A || src == B || src == C);
if(src == A && d3l.getLineA().isValid()) if(src == A && d3l.getLineA().isValid())
pld = &pLineDataA[d3l.getLineA()]; pld = &(*pLineDataA)[d3l.getLineA()];
else if(src == B && d3l.getLineB().isValid()) else if(src == B && d3l.getLineB().isValid())
pld = &pLineDataB[d3l.getLineB()]; pld = &(*pLineDataB)[d3l.getLineB()];
else if(src == C && d3l.getLineC().isValid()) else if(src == C && d3l.getLineC().isValid())
pld = &pLineDataC[d3l.getLineC()]; pld = &(*pLineDataC)[d3l.getLineC()];
//Not an error. //Not an error.
if(pld == nullptr) if(pld == nullptr)
......
...@@ -47,7 +47,7 @@ class MergeEditLine ...@@ -47,7 +47,7 @@ class MergeEditLine
m_bLineRemoved = false; m_bLineRemoved = false;
m_src = None; m_src = None;
} }
QString getString(const LineData* pLineDataA, const LineData* pLineDataB, const LineData* pLineDataC); QString getString(const QVector<LineData>* pLineDataA, const QVector<LineData>* pLineDataB, const QVector<LineData>* pLineDataC);
bool isModified() { return !m_str.isEmpty() || (m_bLineRemoved && m_src == None); } bool isModified() { return !m_str.isEmpty() || (m_bLineRemoved && m_src == None); }
void setSource(e_SrcSelector src, bool bLineRemoved) void setSource(e_SrcSelector src, bool bLineRemoved)
......
...@@ -159,17 +159,17 @@ QStringList SourceData::setData(const QString& data) ...@@ -159,17 +159,17 @@ QStringList SourceData::setData(const QString& data)
return errors; return errors;
} }
const LineData* SourceData::getLineDataForDiff() const const QVector<LineData>* SourceData::getLineDataForDiff() const
{ {
if(m_lmppData.m_pBuf == nullptr) if(m_lmppData.m_pBuf == nullptr)
return m_normalData.m_v.size() > 0 ? &m_normalData.m_v[0] : nullptr; return m_normalData.m_v.size() > 0 ? &m_normalData.m_v : nullptr;
else else
return m_lmppData.m_v.size() > 0 ? &m_lmppData.m_v[0] : nullptr; return m_lmppData.m_v.size() > 0 ? &m_lmppData.m_v : nullptr;
} }
const LineData* SourceData::getLineDataForDisplay() const const QVector<LineData>* SourceData::getLineDataForDisplay() const
{ {
return m_normalData.m_v.size() > 0 ? &m_normalData.m_v[0] : nullptr; return m_normalData.m_v.size() > 0 ? &m_normalData.m_v : nullptr;
} }
LineRef SourceData::getSizeLines() const LineRef SourceData::getSizeLines() const
......
...@@ -33,8 +33,8 @@ class SourceData ...@@ -33,8 +33,8 @@ class SourceData
qint64 getSizeBytes() const; qint64 getSizeBytes() const;
const char* getBuf() const; const char* getBuf() const;
const QString& getText() const; const QString& getText() const;
const LineData* getLineDataForDisplay() const; const QVector<LineData>* getLineDataForDisplay() const;
const LineData* getLineDataForDiff() const; const QVector<LineData>* getLineDataForDiff() const;
void setFilename(const QString& filename); void setFilename(const QString& filename);
void setFileAccess(const FileAccess& fileAccess); void setFileAccess(const FileAccess& fileAccess);
......
...@@ -536,7 +536,7 @@ bool ManualDiffHelpEntry::isValidMove(int line1, int line2, e_SrcSelector winIdx ...@@ -536,7 +536,7 @@ bool ManualDiffHelpEntry::isValidMove(int line1, int line2, e_SrcSelector winIdx
return true; return true;
} }
static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineRef size2, DiffList& diffList, static bool runDiff(const QVector<LineData>* p1, const qint32 index1, LineRef size1, const QVector<LineData>* p2, const qint32 index2, LineRef size2, DiffList& diffList,
Options* pOptions) Options* pOptions)
{ {
ProgressProxy pp; ProgressProxy pp;
...@@ -545,10 +545,10 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR ...@@ -545,10 +545,10 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
pp.setCurrent(0); pp.setCurrent(0);
diffList.clear(); diffList.clear();
if(p1 == nullptr || p1[0].getLine() == nullptr || p2 == nullptr || p2[0].getLine() == nullptr || size1 == 0 || size2 == 0) if(p1 == nullptr || (*p1)[index1].getLine() == nullptr || p2 == nullptr || (*p2)[index2].getLine() == nullptr || size1 == 0 || size2 == 0)
{ {
Diff d(0, 0, 0); Diff d(0, 0, 0);
if(p1 != nullptr && p2 != nullptr && p1[0].getLine() == nullptr && p2[0].getLine() == nullptr && size1 == size2) if(p1 != nullptr && p2 != nullptr && (*p1)[index1].getLine() == nullptr && (*p2)[index2].getLine() == nullptr && size1 == size2)
d.nofEquals = size1; d.nofEquals = size1;
else else
{ {
...@@ -563,10 +563,10 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR ...@@ -563,10 +563,10 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
GnuDiff::comparison comparisonInput; GnuDiff::comparison comparisonInput;
memset(&comparisonInput, 0, sizeof(comparisonInput)); memset(&comparisonInput, 0, sizeof(comparisonInput));
comparisonInput.parent = nullptr; comparisonInput.parent = nullptr;
comparisonInput.file[0].buffer = p1[0].getLine(); //ptr to buffer comparisonInput.file[0].buffer = (*p1)[index1].getLine(); //ptr to buffer
comparisonInput.file[0].buffered = (p1[size1 - 1].getLine() - p1[0].getLine() + p1[size1 - 1].size()); // size of buffer comparisonInput.file[0].buffered = ((*p1)[size1 - 1].getLine() - (*p1)[index1].getLine() + (*p1)[size1 - 1].size()); // size of buffer
comparisonInput.file[1].buffer = p2[0].getLine(); //ptr to buffer comparisonInput.file[1].buffer = (*p2)[index2].getLine(); //ptr to buffer
comparisonInput.file[1].buffered = (p2[size2 - 1].getLine() - p2[0].getLine() + p2[size2 - 1].size()); // size of buffer comparisonInput.file[1].buffered = ((*p2)[size2 - 1].getLine() - (*p2)[index2].getLine() + (*p2)[size2 - 1].size()); // size of buffer
gnuDiff.ignore_white_space = GnuDiff::IGNORE_ALL_SPACE; // I think nobody needs anything else ... gnuDiff.ignore_white_space = GnuDiff::IGNORE_ALL_SPACE; // I think nobody needs anything else ...
gnuDiff.bIgnoreWhiteSpace = true; gnuDiff.bIgnoreWhiteSpace = true;
...@@ -641,7 +641,7 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR ...@@ -641,7 +641,7 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
return true; return true;
} }
bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineRef size2, DiffList& diffList, bool ManualDiffHelpList::runDiff(const QVector<LineData>* p1, LineRef size1, const QVector<LineData>* p2, LineRef size2, DiffList& diffList,
e_SrcSelector winIdx1, e_SrcSelector winIdx2, e_SrcSelector winIdx1, e_SrcSelector winIdx2,
Options* pOptions) Options* pOptions)
{ {
...@@ -660,7 +660,7 @@ bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineDa ...@@ -660,7 +660,7 @@ bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineDa
if(l1end >= 0 && l2end >= 0) if(l1end >= 0 && l2end >= 0)
{ {
::runDiff(p1 + l1begin, l1end - l1begin, p2 + l2begin, l2end - l2begin, diffList2, pOptions); ::runDiff(p1, l1begin, l1end - l1begin, p2, l2begin, l2end - l2begin, diffList2, pOptions);
diffList.splice(diffList.end(), diffList2); diffList.splice(diffList.end(), diffList2);
l1begin = l1end; l1begin = l1end;
l2begin = l2end; l2begin = l2end;
...@@ -672,14 +672,14 @@ bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineDa ...@@ -672,14 +672,14 @@ bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineDa
{ {
++l1end; // point to line after last selected line ++l1end; // point to line after last selected line
++l2end; ++l2end;
::runDiff(p1 + l1begin, l1end - l1begin, p2 + l2begin, l2end - l2begin, diffList2, pOptions); ::runDiff(p1, l1begin, l1end - l1begin, p2, l2begin, l2end - l2begin, diffList2, pOptions);
diffList.splice(diffList.end(), diffList2); diffList.splice(diffList.end(), diffList2);
l1begin = l1end; l1begin = l1end;
l2begin = l2end; l2begin = l2end;
} }
} }
} }
::runDiff(p1 + l1begin, size1 - l1begin, p2 + l2begin, size2 - l2begin, diffList2, pOptions); ::runDiff(p1, l1begin, size1 - l1begin, p2, l2begin, size2 - l2begin, diffList2, pOptions);
diffList.splice(diffList.end(), diffList2); diffList.splice(diffList.end(), diffList2);
return true; return true;
} }
...@@ -848,7 +848,7 @@ void correctManualDiffAlignment(Diff3LineList& d3ll, ManualDiffHelpList* pManual ...@@ -848,7 +848,7 @@ void correctManualDiffAlignment(Diff3LineList& d3ll, ManualDiffHelpList* pManual
// Fourth step // Fourth step
void calcDiff3LineListTrim( void calcDiff3LineListTrim(
Diff3LineList& d3ll, const LineData* pldA, const LineData* pldB, const LineData* pldC, ManualDiffHelpList* pManualDiffHelpList) Diff3LineList& d3ll, const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC, ManualDiffHelpList* pManualDiffHelpList)
{ {
const Diff3Line d3l_empty; const Diff3Line d3l_empty;
d3ll.remove(d3l_empty); d3ll.remove(d3l_empty);
...@@ -887,7 +887,7 @@ void calcDiff3LineListTrim( ...@@ -887,7 +887,7 @@ void calcDiff3LineListTrim(
} }
if(line > lineA && i3->getLineA().isValid() && i3A->getLineB().isValid() && i3A->isEqualBC() && if(line > lineA && i3->getLineA().isValid() && i3A->getLineB().isValid() && i3A->isEqualBC() &&
LineData::equal(pldA[i3->getLineA()], pldB[i3A->getLineB()], false) && LineData::equal((*pldA)[i3->getLineA()], (*pldB)[i3A->getLineB()], false) &&
pManualDiffHelpList->isValidMove(i3->getLineA(), i3A->getLineB(), A, B) && pManualDiffHelpList->isValidMove(i3->getLineA(), i3A->getLineB(), A, B) &&
pManualDiffHelpList->isValidMove(i3->getLineA(), i3A->getLineC(), A, C)) pManualDiffHelpList->isValidMove(i3->getLineA(), i3A->getLineC(), A, C))
{ {
...@@ -904,7 +904,7 @@ void calcDiff3LineListTrim( ...@@ -904,7 +904,7 @@ void calcDiff3LineListTrim(
} }
if(line > lineB && i3->getLineB().isValid() && i3B->getLineA().isValid() && i3B->isEqualAC() && if(line > lineB && i3->getLineB().isValid() && i3B->getLineA().isValid() && i3B->isEqualAC() &&
LineData::equal(pldB[i3->getLineB()], pldA[i3B->getLineA()], false) && LineData::equal((*pldB)[i3->getLineB()], (*pldA)[i3B->getLineA()], false) &&
pManualDiffHelpList->isValidMove(i3->getLineB(), i3B->getLineA(), B, A) && pManualDiffHelpList->isValidMove(i3->getLineB(), i3B->getLineA(), B, A) &&
pManualDiffHelpList->isValidMove(i3->getLineB(), i3B->getLineC(), B, C)) pManualDiffHelpList->isValidMove(i3->getLineB(), i3B->getLineC(), B, C))
{ {
...@@ -920,7 +920,7 @@ void calcDiff3LineListTrim( ...@@ -920,7 +920,7 @@ void calcDiff3LineListTrim(
} }
if(line > lineC && i3->getLineC().isValid() && i3C->getLineA().isValid() && i3C->isEqualAB() && if(line > lineC && i3->getLineC().isValid() && i3C->getLineA().isValid() && i3C->isEqualAB() &&
LineData::equal(pldC[i3->getLineC()], pldA[i3C->getLineA()], false) && LineData::equal((*pldC)[i3->getLineC()], (*pldA)[i3C->getLineA()], false) &&
pManualDiffHelpList->isValidMove(i3->getLineC(), i3C->getLineA(), C, A) && pManualDiffHelpList->isValidMove(i3->getLineC(), i3C->getLineA(), C, A) &&
pManualDiffHelpList->isValidMove(i3->getLineC(), i3C->getLineB(), C, B)) pManualDiffHelpList->isValidMove(i3->getLineC(), i3C->getLineB(), C, B))
{ {
...@@ -943,12 +943,12 @@ void calcDiff3LineListTrim( ...@@ -943,12 +943,12 @@ void calcDiff3LineListTrim(
i3A->setLineA(i3->getLineA()); i3A->setLineA(i3->getLineA());
i3->getLineA().invalidate(); i3->getLineA().invalidate();
if(i3A->getLineB().isValid() && LineData::equal(pldA[i3A->getLineA()], pldB[i3A->getLineB()], false)) if(i3A->getLineB().isValid() && LineData::equal((*pldA)[i3A->getLineA()], (*pldB)[i3A->getLineB()], false))
{ {
i3A->bAEqB = true; i3A->bAEqB = true;
} }
if((i3A->isEqualAB() && i3A->isEqualBC()) || if((i3A->isEqualAB() && i3A->isEqualBC()) ||
(i3A->getLineC().isValid() && LineData::equal(pldA[i3A->getLineA()], pldC[i3A->getLineC()], false))) (i3A->getLineC().isValid() && LineData::equal((*pldA)[i3A->getLineA()], (*pldC)[i3A->getLineC()], false)))
{ {
i3A->bAEqC = true; i3A->bAEqC = true;
} }
...@@ -965,12 +965,12 @@ void calcDiff3LineListTrim( ...@@ -965,12 +965,12 @@ void calcDiff3LineListTrim(
i3B->setLineB(i3->getLineB()); i3B->setLineB(i3->getLineB());
i3->getLineB().invalidate(); i3->getLineB().invalidate();
if(i3B->getLineA().isValid() && LineData::equal(pldA[i3B->getLineA()], pldB[i3B->getLineB()], false)) if(i3B->getLineA().isValid() && LineData::equal((*pldA)[i3B->getLineA()], (*pldB)[i3B->getLineB()], false))
{ {
i3B->bAEqB = true; i3B->bAEqB = true;
} }
if((i3B->isEqualAB() && i3B->isEqualAC()) || if((i3B->isEqualAB() && i3B->isEqualAC()) ||
(i3B->getLineC().isValid() && LineData::equal(pldB[i3B->getLineB()], pldC[i3B->getLineC()], false))) (i3B->getLineC().isValid() && LineData::equal((*pldB)[i3B->getLineB()], (*pldC)[i3B->getLineC()], false)))
{ {
i3B->bBEqC = true; i3B->bBEqC = true;
} }
...@@ -987,12 +987,12 @@ void calcDiff3LineListTrim( ...@@ -987,12 +987,12 @@ void calcDiff3LineListTrim(
i3C->setLineC(i3->getLineC()); i3C->setLineC(i3->getLineC());
i3->getLineC().invalidate(); i3->getLineC().invalidate();
if(i3C->getLineA().isValid() && LineData::equal(pldA[i3C->getLineA()], pldC[i3C->getLineC()], false)) if(i3C->getLineA().isValid() && LineData::equal((*pldA)[i3C->getLineA()], (*pldC)[i3C->getLineC()], false))
{ {
i3C->bAEqC = true; i3C->bAEqC = true;
} }
if((i3C->isEqualAC() && i3C->isEqualAB()) || if((i3C->isEqualAC() && i3C->isEqualAB()) ||
(i3C->getLineB().isValid() && LineData::equal(pldB[i3C->getLineB()], pldC[i3C->getLineC()], false))) (i3C->getLineB().isValid() && LineData::equal((*pldB)[i3C->getLineB()], (*pldC)[i3C->getLineC()], false)))
{ {
i3C->bBEqC = true; i3C->bBEqC = true;
} }
...@@ -1014,7 +1014,7 @@ void calcDiff3LineListTrim( ...@@ -1014,7 +1014,7 @@ void calcDiff3LineListTrim(
i->setLineB(i3->getLineB()); i->setLineB(i3->getLineB());
i->bAEqB = true; i->bAEqB = true;
if(i->getLineC().isValid() && LineData::equal(pldA[i->getLineA()], pldC[i->getLineC()], false)) if(i->getLineC().isValid() && LineData::equal((*pldA)[i->getLineA()], (*pldC)[i->getLineC()], false))
{ {
i->bAEqC = true; i->bAEqC = true;
i->bBEqC = true; i->bBEqC = true;
...@@ -1044,7 +1044,7 @@ void calcDiff3LineListTrim( ...@@ -1044,7 +1044,7 @@ void calcDiff3LineListTrim(
i->setLineC(i3->getLineC()); i->setLineC(i3->getLineC());
i->bAEqC = true; i->bAEqC = true;
if(i->getLineB().isValid() && LineData::equal(pldA[i->getLineA()], pldB[i->getLineB()], false)) if(i->getLineB().isValid() && LineData::equal((*pldA)[i->getLineA()], (*pldB)[i->getLineB()], false))
{ {
i->bAEqB = true; i->bAEqB = true;
i->bBEqC = true; i->bBEqC = true;
...@@ -1074,7 +1074,7 @@ void calcDiff3LineListTrim( ...@@ -1074,7 +1074,7 @@ void calcDiff3LineListTrim(
i->setLineC(i3->getLineC()); i->setLineC(i3->getLineC());
i->bBEqC = true; i->bBEqC = true;
if(i->getLineA().isValid() && LineData::equal(pldA[i->getLineA()], pldB[i->getLineB()], false)) if(i->getLineA().isValid() && LineData::equal((*pldA)[i->getLineA()], (*pldB)[i->getLineB()], false))
{ {
i->bAEqB = true; i->bAEqB = true;
i->bAEqC = true; i->bAEqC = true;
...@@ -1129,7 +1129,7 @@ void calcDiff3LineListTrim( ...@@ -1129,7 +1129,7 @@ void calcDiff3LineListTrim(
} }
void DiffBufferInfo::init(Diff3LineList* pD3ll, const Diff3LineVector* pD3lv, void DiffBufferInfo::init(Diff3LineList* pD3ll, const Diff3LineVector* pD3lv,
const LineData* pldA, LineCount sizeA, const LineData* pldB, LineCount sizeB, const LineData* pldC, LineCount sizeC) const QVector<LineData>* pldA, LineCount sizeA, const QVector<LineData>* pldB, LineCount sizeB, const QVector<LineData>* pldC, LineCount sizeC)
{ {
m_pDiff3LineList = pD3ll; m_pDiff3LineList = pD3ll;
m_pDiff3LineVector = pD3lv; m_pDiff3LineVector = pD3lv;
...@@ -1147,15 +1147,15 @@ void DiffBufferInfo::init(Diff3LineList* pD3ll, const Diff3LineVector* pD3lv, ...@@ -1147,15 +1147,15 @@ void DiffBufferInfo::init(Diff3LineList* pD3ll, const Diff3LineVector* pD3lv,
} }
void Diff3LineList::calcWhiteDiff3Lines( void Diff3LineList::calcWhiteDiff3Lines(
const LineData* pldA, const LineData* pldB, const LineData* pldC) const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC)
{ {
Diff3LineList::iterator i3; Diff3LineList::iterator i3;
for(i3 = begin(); i3 != end(); ++i3) for(i3 = begin(); i3 != end(); ++i3)
{ {
i3->bWhiteLineA = (!i3->getLineA().isValid() || pldA == nullptr || pldA[i3->getLineA()].whiteLine() || pldA[i3->getLineA()].isPureComment()); i3->bWhiteLineA = (!i3->getLineA().isValid() || pldA == nullptr || (*pldA)[i3->getLineA()].whiteLine() || (*pldA)[i3->getLineA()].isPureComment());
i3->bWhiteLineB = (!i3->getLineA().isValid() || pldB == nullptr || pldB[i3->getLineB()].whiteLine() || pldB[i3->getLineB()].isPureComment()); i3->bWhiteLineB = (!i3->getLineA().isValid() || pldB == nullptr || (*pldB)[i3->getLineB()].whiteLine() || (*pldB)[i3->getLineB()].isPureComment());
i3->bWhiteLineC = (!i3->getLineC().isValid() || pldC == nullptr || pldC[i3->getLineC()].whiteLine() || pldC[i3->getLineC()].isPureComment()); i3->bWhiteLineC = (!i3->getLineC().isValid() || pldC == nullptr || (*pldC)[i3->getLineC()].whiteLine() || (*pldC)[i3->getLineC()].isPureComment());
} }
} }
...@@ -1315,7 +1315,7 @@ void calcDiff(const QChar* p1, LineRef size1, const QChar* p2, LineRef size2, Di ...@@ -1315,7 +1315,7 @@ void calcDiff(const QChar* p1, LineRef size1, const QChar* p2, LineRef size2, Di
} }
} }
bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector, const LineData* v1, const LineData* v2) bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2)
{ {
LineRef k1 = 0; LineRef k1 = 0;
LineRef k2 = 0; LineRef k2 = 0;
...@@ -1344,11 +1344,11 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector, ...@@ -1344,11 +1344,11 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector,
if((!k1.isValid() && k2.isValid()) || (k1.isValid() && !k2.isValid())) bTextsTotalEqual = false; if((!k1.isValid() && k2.isValid()) || (k1.isValid() && !k2.isValid())) bTextsTotalEqual = false;
if(k1.isValid() && k2.isValid()) if(k1.isValid() && k2.isValid())
{ {
if(v1[k1].size() != v2[k2].size() || memcmp(v1[k1].getLine(), v2[k2].getLine(), v1[k1].size() << 1) != 0) if((*v1)[k1].size() != (*v2)[k2].size() || memcmp((*v1)[k1].getLine(), (*v2)[k2].getLine(), (*v1)[k1].size() << 1) != 0)
{ {
bTextsTotalEqual = false; bTextsTotalEqual = false;
DiffList* pDiffList = new DiffList; DiffList* pDiffList = new DiffList;
calcDiff(v1[k1].getLine(), v1[k1].size(), v2[k2].getLine(), v2[k2].size(), *pDiffList, 2, maxSearchLength); calcDiff((*v1)[k1].getLine(), (*v1)[k1].size(), (*v2)[k2].getLine(), (*v2)[k2].size(), *pDiffList, 2, maxSearchLength);
// Optimize the diff list. // Optimize the diff list.
DiffList::iterator dli; DiffList::iterator dli;
...@@ -1375,7 +1375,7 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector, ...@@ -1375,7 +1375,7 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector,
setFineDiff(selector, pDiffList); setFineDiff(selector, pDiffList);
} }
if((v1[k1].isPureComment() || v1[k1].whiteLine()) && (v2[k2].isPureComment() || v2[k2].whiteLine())) if(((*v1)[k1].isPureComment() || (*v1)[k1].whiteLine()) && ((*v2)[k2].isPureComment() || (*v2)[k2].whiteLine()))
{ {
if(selector == A) if(selector == A)
{ {
...@@ -1435,7 +1435,7 @@ void Diff3Line::getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int ...@@ -1435,7 +1435,7 @@ void Diff3Line::getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int
} }
} }
bool Diff3LineList::fineDiff(const e_SrcSelector selector, const LineData* v1, const LineData* v2) bool Diff3LineList::fineDiff(const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2)
{ {
// Finetuning: Diff each line with deltas // Finetuning: Diff each line with deltas
ProgressProxy pp; ProgressProxy pp;
......
...@@ -106,16 +106,16 @@ class Diff3LineVector; ...@@ -106,16 +106,16 @@ class Diff3LineVector;
class DiffBufferInfo class DiffBufferInfo
{ {
public: public:
const LineData* m_pLineDataA; const QVector<LineData>* m_pLineDataA;
const LineData* m_pLineDataB; const QVector<LineData>* m_pLineDataB;
const LineData* m_pLineDataC; const QVector<LineData>* m_pLineDataC;
LineCount m_sizeA; LineCount m_sizeA;
LineCount m_sizeB; LineCount m_sizeB;
LineCount m_sizeC; LineCount m_sizeC;
const Diff3LineList* m_pDiff3LineList; const Diff3LineList* m_pDiff3LineList;
const Diff3LineVector* m_pDiff3LineVector; const Diff3LineVector* m_pDiff3LineVector;
void init(Diff3LineList* d3ll, const Diff3LineVector* d3lv, void init(Diff3LineList* d3ll, const Diff3LineVector* d3lv,
const LineData* pldA, LineCount sizeA, const LineData* pldB, LineCount sizeB, const LineData* pldC, LineCount sizeC); const QVector<LineData>* pldA, LineCount sizeA, const QVector<LineData>* pldB, LineCount sizeB, const QVector<LineData>* pldC, LineCount sizeC);
}; };
class Diff3Line class Diff3Line
...@@ -173,9 +173,9 @@ class Diff3Line ...@@ -173,9 +173,9 @@ class Diff3Line
const LineData* getLineData(e_SrcSelector src) const const LineData* getLineData(e_SrcSelector src) const
{ {
Q_ASSERT(m_pDiffBufferInfo != nullptr); Q_ASSERT(m_pDiffBufferInfo != nullptr);
if(src == A && lineA >= 0) return &m_pDiffBufferInfo->m_pLineDataA[lineA]; if(src == A && lineA >= 0) return &(*m_pDiffBufferInfo->m_pLineDataA)[lineA];
if(src == B && lineB >= 0) return &m_pDiffBufferInfo->m_pLineDataB[lineB]; if(src == B && lineB >= 0) return &(*m_pDiffBufferInfo->m_pLineDataB)[lineB];
if(src == C && lineC >= 0) return &m_pDiffBufferInfo->m_pLineDataC[lineC]; if(src == C && lineC >= 0) return &(*m_pDiffBufferInfo->m_pLineDataC)[lineC];
return nullptr; return nullptr;
} }
QString getString(const e_SrcSelector src) const QString getString(const e_SrcSelector src) const
...@@ -194,7 +194,7 @@ class Diff3Line ...@@ -194,7 +194,7 @@ class Diff3Line
return -1; return -1;
} }
bool fineDiff(bool bTextsTotalEqual, const e_SrcSelector selector, const LineData* v1, const LineData* v2); bool fineDiff(bool bTextsTotalEqual, const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2);
void mergeOneLine(e_MergeDetails& mergeDetails, bool& bConflict, bool& bLineRemoved, e_SrcSelector& src, bool bTwoInputs) const; void mergeOneLine(e_MergeDetails& mergeDetails, bool& bConflict, bool& bLineRemoved, e_SrcSelector& src, bool bTwoInputs) const;
void getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int& lineIdx, void getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int& lineIdx,
...@@ -229,9 +229,9 @@ class Diff3Line ...@@ -229,9 +229,9 @@ class Diff3Line
class Diff3LineList : public std::list<Diff3Line> class Diff3LineList : public std::list<Diff3Line>
{ {
public: public:
bool fineDiff(const e_SrcSelector selector, const LineData* v1, const LineData* v2); bool fineDiff(const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2);
void calcDiff3LineVector(Diff3LineVector& d3lv); void calcDiff3LineVector(Diff3LineVector& d3lv);
void calcWhiteDiff3Lines(const LineData* pldA, const LineData* pldB, const LineData* pldC); void calcWhiteDiff3Lines(const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC);
//TODO: Add safety guards to prevent list from getting too large. Same problem as with QLinkedList. //TODO: Add safety guards to prevent list from getting too large. Same problem as with QLinkedList.
int size() const { int size() const {
if(std::list<Diff3Line>::size() > std::numeric_limits<int>::max()) if(std::list<Diff3Line>::size() > std::numeric_limits<int>::max())
...@@ -364,7 +364,7 @@ class ManualDiffHelpList: public std::list<ManualDiffHelpEntry> ...@@ -364,7 +364,7 @@ class ManualDiffHelpList: public std::list<ManualDiffHelpEntry>
bool isValidMove(int line1, int line2, e_SrcSelector winIdx1, e_SrcSelector winIdx2) const; bool isValidMove(int line1, int line2, e_SrcSelector winIdx1, e_SrcSelector winIdx2) const;
void insertEntry(e_SrcSelector winIdx, LineRef firstLine, LineRef lastLine); void insertEntry(e_SrcSelector winIdx, LineRef firstLine, LineRef lastLine);
bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineRef size2, DiffList& diffList, bool runDiff(const QVector<LineData>* p1, LineRef size1, const QVector<LineData>* p2, LineRef size2, DiffList& diffList,
e_SrcSelector winIdx1, e_SrcSelector winIdx2, e_SrcSelector winIdx1, e_SrcSelector winIdx2,
Options* pOptions); Options* pOptions);
}; };
...@@ -383,15 +383,15 @@ void calcDiff3LineListUsingBC( ...@@ -383,15 +383,15 @@ void calcDiff3LineListUsingBC(
void correctManualDiffAlignment(Diff3LineList& d3ll, ManualDiffHelpList* pManualDiffHelpList); void correctManualDiffAlignment(Diff3LineList& d3ll, ManualDiffHelpList* pManualDiffHelpList);
void calcDiff3LineListTrim(Diff3LineList& d3ll, const LineData* pldA, const LineData* pldB, const LineData* pldC, ManualDiffHelpList* pManualDiffHelpList); void calcDiff3LineListTrim(Diff3LineList& d3ll, const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC, ManualDiffHelpList* pManualDiffHelpList);
bool fineDiff( bool fineDiff(
Diff3LineList& diff3LineList, Diff3LineList& diff3LineList,
int selector, int selector,
const LineData* v1, const QVector<LineData>* v1,
const LineData* v2); const QVector<LineData>* v2);
inline bool isWhite(QChar c) inline bool isWhite(QChar c)
{ {
......
...@@ -84,7 +84,7 @@ class DiffTextWindowData ...@@ -84,7 +84,7 @@ class DiffTextWindowData
QTextCodec* m_pTextCodec; QTextCodec* m_pTextCodec;
e_LineEndStyle m_eLineEndStyle; e_LineEndStyle m_eLineEndStyle;
const LineData* m_pLineData;