OSDN Git Service

Compare result was not correct when using Synchronization Point
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 9 Apr 2016 02:36:48 +0000 (11:36 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 9 Apr 2016 02:36:48 +0000 (11:36 +0900)
Src/DiffWrapper.h
Src/MergeDoc.cpp

index 221613a..90869fd 100644 (file)
@@ -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;
index 478b526..76632b0 100644 (file)
@@ -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)