From a0819b32b2245ee378446f4dc5b592e45fd2998a Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 9 Apr 2016 11:36:48 +0900 Subject: [PATCH] Compare result was not correct when using Synchronization Point --- Src/DiffWrapper.h | 15 +++++++++++++++ Src/MergeDoc.cpp | 20 ++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Src/DiffWrapper.h b/Src/DiffWrapper.h index 221613a77..90869fd3b 100644 --- a/Src/DiffWrapper.h +++ b/Src/DiffWrapper.h @@ -136,6 +136,21 @@ struct DIFFSTATUS bool bPatchFileFailed; /**< Creating patch file failed */ DIFFSTATUS() { memset(this, 0, sizeof(*this)); } // start out with all flags clear + void MergeStatus(const DIFFSTATUS& other) + { + if (Identical == IDENTLEVEL_ALL) + Identical = Identical; + else if ( + (Identical == IDENTLEVEL_EXCEPTLEFT && other.Identical != IDENTLEVEL_EXCEPTLEFT) || + (Identical == IDENTLEVEL_EXCEPTRIGHT && other.Identical != IDENTLEVEL_EXCEPTRIGHT) || + (Identical == IDENTLEVEL_EXCEPTMIDDLE && other.Identical != IDENTLEVEL_EXCEPTMIDDLE)) + Identical = IDENTLEVEL_NONE; + if (other.bPatchFileFailed) + bPatchFileFailed = true; + if (other.bBinaries) + bBinaries = true; + std::copy(other.bMissingNL, other.bMissingNL + 3, bMissingNL); + } }; class FilterCommentsManager; diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index 478b5264b..76632b04b 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -448,6 +448,8 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical, m_diffWrapper.SetCodepage(m_ptBuf[0]->m_encoding.m_unicoding ? CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage); + DIFFSTATUS status; + if (!HasSyncPoints()) { // Save text buffer to file @@ -459,6 +461,11 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical, m_diffWrapper.SetCreateDiffList(&m_diffList); diffSuccess = !!m_diffWrapper.RunFileDiff(); + + // Read diff-status + m_diffWrapper.GetDiffStatus(&status); + if (bBinary) // believe caller if we were told these are binaries + status.bBinaries = true; } else { @@ -484,16 +491,17 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical, m_diffList.AppendDiffList(templist, nRealLine); for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++) nStartLine[nBuffer] += nLines[nBuffer]; + + // Read diff-status + DIFFSTATUS status_part; + m_diffWrapper.GetDiffStatus(&status_part); + if (bBinary) // believe caller if we were told these are binaries + status.bBinaries = true; + status.MergeStatus(status_part); } m_diffWrapper.SetCreateDiffList(&m_diffList); } - // Read diff-status - DIFFSTATUS status; - m_diffWrapper.GetDiffStatus(&status); - if (bBinary) // believe caller if we were told these are binaries - status.bBinaries = true; - // If comparing whitespaces and // other file has EOL before EOF and other not... if (!diffOptions.nIgnoreWhitespace && !diffOptions.bIgnoreBlankLines) -- 2.11.0