Commit 596d6e85 authored by Michael Reeves's avatar Michael Reeves

Do basic diff against empty/non-existant files.

Fix runDiff to work with empty/non-existant files.
No need for fineDiff in this case it adds no value to the result for
such files.
parent ec530963
......@@ -542,10 +542,10 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
pp.setCurrent(0);
diffList.clear();
if(p1[0].getLine() == nullptr || p2[0].getLine() == nullptr || size1 == 0 || size2 == 0)
if(p1 == nullptr || p1[0].getLine() == nullptr || p2 == nullptr || p2[0].getLine() == nullptr || size1 == 0 || size2 == 0)
{
Diff d(0, 0, 0);
if(p1[0].getLine() == nullptr && p2[0].getLine() == nullptr && size1 == size2)
if(p1 != nullptr && p2 != nullptr && p1[0].getLine() == nullptr && p2[0].getLine() == nullptr && size1 == size2)
d.nofEquals = size1;
else
{
......@@ -642,7 +642,6 @@ bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineDa
int winIdx1, int winIdx2,
Options* pOptions)
{
Q_ASSERT(p1 != nullptr && p2 != nullptr);
diffList.clear();
DiffList diffList2;
......
......@@ -194,7 +194,7 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
{
pTotalDiffStatus->bBinaryAEqB = m_sd1.isBinaryEqualWith(m_sd2);
if(m_sd1.hasData() && m_sd1.isText() && m_sd2.hasData() && m_sd2.isText())
if(m_sd1.isText() && m_sd2.isText())
{
pp.setInformation(i18n("Diff: A <-> B"));
m_manualDiffHelpList.runDiff(m_sd1.getLineDataForDiff(), m_sd1.getSizeLines(), m_sd2.getLineDataForDiff(), m_sd2.getSizeLines(), m_diffList12, 1, 2,
......@@ -237,7 +237,7 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
pTotalDiffStatus->bBinaryBEqC = m_sd3.isBinaryEqualWith(m_sd2);
pp.setInformation(i18n("Diff: A <-> B"));
if(m_sd1.hasData() && m_sd2.hasData() && m_sd1.isText() && m_sd2.isText())
if(m_sd1.isText() && m_sd2.isText())
{
m_manualDiffHelpList.runDiff(m_sd1.getLineDataForDiff(), m_sd1.getSizeLines(), m_sd2.getLineDataForDiff(), m_sd2.getSizeLines(), m_diffList12, 1, 2,
&m_pOptionDialog->m_options);
......@@ -246,7 +246,7 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
}
pp.step();
pp.setInformation(i18n("Diff: A <-> C"));
if(m_sd1.hasData() && m_sd1.isText() && m_sd3.hasData() && m_sd3.isText())
if(m_sd1.isText() && m_sd3.isText())
{
m_manualDiffHelpList.runDiff(m_sd1.getLineDataForDiff(), m_sd1.getSizeLines(), m_sd3.getLineDataForDiff(), m_sd3.getSizeLines(), m_diffList13, 1, 3,
&m_pOptionDialog->m_options);
......@@ -257,7 +257,7 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
}
pp.step();
pp.setInformation(i18n("Diff: B <-> C"));
if(m_sd2.hasData() && m_sd2.isText() && m_sd3.hasData() && m_sd3.isText())
if(m_sd2.isText() && m_sd3.isText())
{
m_manualDiffHelpList.runDiff(m_sd2.getLineDataForDiff(), m_sd2.getSizeLines(), m_sd3.getLineDataForDiff(), m_sd3.getSizeLines(), m_diffList23, 2, 3,
&m_pOptionDialog->m_options);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment