OSDN Git Service

Remove IF_IS_TRUE_ALL macro
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Mar 2019 01:54:30 +0000 (10:54 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Mar 2019 01:54:30 +0000 (10:54 +0900)
Src/LocationView.cpp
Src/MergeDoc.cpp
Src/MergeDocLineDiffs.cpp
Src/StdAfx.h

index b266dc9..7769f44 100644 (file)
@@ -976,8 +976,9 @@ void CLocationView::UpdateVisiblePos(int nTopLine, int nBottomLine)
        {
                CMergeDoc *pDoc = GetDocument();
                int nGroup = pDoc->GetActiveMergeView()->m_nThisGroup;
-               int pane;
-               IF_IS_TRUE_ALL(m_nSubLineCount[pane] == pDoc->GetView(nGroup, pane)->GetSubLineCount(), pane, pDoc->m_nBuffers)
+               int pane = 0;
+               if (std::all_of(m_nSubLineCount, m_nSubLineCount + pDoc->m_nBuffers,
+                       [&](int nSubLineCount) { return nSubLineCount == pDoc->GetView(nGroup, pane++)->GetSubLineCount(); }))
                {
                        int nTopCoord = static_cast<int>(Y_OFFSET +
                                        (static_cast<double>(nTopLine * m_lineInPix)));
index 61dbaeb..b3bc4f2 100644 (file)
@@ -384,10 +384,8 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical,
        m_diffWrapper.GetOptions(&diffOptions);
 
        bool bForceUTF8 = diffOptions.bIgnoreCase;
-       IF_IS_TRUE_ALL (
-               m_ptBuf[0]->getCodepage() == m_ptBuf[nBuffer]->getCodepage() && m_ptBuf[nBuffer]->getUnicoding() == ucr::NONE,
-               nBuffer, m_nBuffers) {}
-       else
+       if (std::any_of(m_ptBuf, m_ptBuf + m_nBuffers,
+               [&](auto& ptBuf) { return m_ptBuf[0]->getCodepage() != ptBuf->getCodepage() || ptBuf->getUnicoding() != ucr::NONE; }))
                bForceUTF8 = true;
 
        // Clear diff list
@@ -408,8 +406,6 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical,
                m_diffWrapper.SetPaths(PathContext(m_tempFiles[0].GetPath(), m_tempFiles[1].GetPath(), m_tempFiles[2].GetPath()), true);
        m_diffWrapper.SetCompareFiles(m_filePaths);
        m_diffWrapper.SetCodepage(bForceUTF8 ? ucr::CP_UTF_8 : (m_ptBuf[0]->m_encoding.m_unicoding ? CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage));
-       m_diffWrapper.SetCodepage(m_ptBuf[0]->m_encoding.m_unicoding ?
-                       CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage);
 
        DIFFSTATUS status;
 
index 802c4aa..8078faa 100644 (file)
@@ -53,7 +53,7 @@ void CMergeDoc::Showlinediff(CMergeEditView *pView, bool bReversed)
 
        Computelinediff(pView, rc, bReversed);
 
-       IF_IS_TRUE_ALL ((rc[nBuffer].top == -1), nBuffer, m_nBuffers)
+       if (std::all_of(rc, rc + m_nBuffers, [](auto& rc) { return rc.top == -1; }))
        {
                String caption = _("Line difference");
                String msg = _("No difference");
index 657c42f..0f21040 100644 (file)
 #include <ctime>
 #include <tchar.h>
 
-#define IF_IS_TRUE_ALL(expression, index, count) \
-       for (index = 0; index < count; index++) { if ((expression)) ; else break; } \
-       if (index == count)
-
-
 /**
  * @name User-defined Windows-messages
  */