OSDN Git Service

PATCH: [ 712429 ] Fix UpdateItemStatus bug 712093
authorPerry Rapp <elsapo@users.sourceforge.net>
Mon, 31 Mar 2003 15:48:45 +0000 (15:48 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Mon, 31 Mar 2003 15:48:45 +0000 (15:48 +0000)
Src/DirActions.cpp
Src/DirView.cpp
Src/paths.cpp
Src/paths.h
Src/readme.txt

index 0048e34..7474b8d 100644 (file)
@@ -15,6 +15,7 @@
 #include "MainFrm.h"
 #include "coretools.h"
 #include "OutputDlg.h"
+#include "paths.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -518,16 +519,15 @@ void CDirView::GetItemFileNames(int sel, CString& strLeft, CString& strRight) co
        CString name, pathex;
        name = m_pList->GetItemText(sel, DV_NAME);
        pathex = m_pList->GetItemText(sel, DV_PATH);
+       strLeft = pd->m_pCtxt->m_strLeft;
+       strRight = pd->m_pCtxt->m_strRight;
        if (pathex.Left(2) == _T(".\\") || pathex.Left(2) == _T("./"))
        {
-               strLeft.Format(_T("%s\\%s\\%s"), pd->m_pCtxt->m_strLeft, pathex.Right(pathex.GetLength()-2), name);
-               strRight.Format(_T("%s\\%s\\%s"), pd->m_pCtxt->m_strRight, pathex.Right(pathex.GetLength()-2), name);
-       }
-       else
-       {
-               strLeft.Format(_T("%s\\%s"), pd->m_pCtxt->m_strLeft, name);
-               strRight.Format(_T("%s\\%s"), pd->m_pCtxt->m_strRight, name);
+               strLeft = paths_ConcatPath(strLeft, pathex.Right(pathex.GetLength()-2));
+               strRight = paths_ConcatPath(strRight, pathex.Right(pathex.GetLength()-2));
        }
+       strLeft = paths_ConcatPath(strLeft, name);
+       strRight = paths_ConcatPath(strRight, name);
 }
 
 // Open selected file on specified side
index fd1fd92..dcd1e2c 100644 (file)
@@ -502,8 +502,8 @@ void CDirView::OpenSelection()
                case FILE_DIFF:
                        {
                                CString left, right;
-                               if (GetSelectedFileNames(left, right))
-                                       mf->ShowMergeDoc(GetDocument(), left, right);
+                               GetItemFileNames(sel, left, right);
+                               mf->ShowMergeDoc(GetDocument(), left, right);
                        }
                        break;
                case FILE_SAME:
index a3e6e8e..72e4487 100644 (file)
@@ -300,3 +300,34 @@ CString ExpandShortcut(CString &inFile)
        // if this fails, outFile == ""
     return outFile;
 }
+
+// Append subpath to path
+// Skip empty arguments
+// Ensure exactly one backslash between them in result
+CString paths_ConcatPath(const CString & path, const CString & subpath)
+{
+       if (path.IsEmpty()) return subpath;
+       if (subpath.IsEmpty()) return path;
+       if (EndsWithSlash(path))
+       {
+               if (IsSlash(subpath[0]))
+               {
+                       return path + subpath.Mid(1);
+               }
+               else
+               {
+                       return path + subpath;
+               }
+       }
+       else
+       {
+               if (IsSlash(subpath[0]))
+               {
+                       return path + subpath;
+               }
+               else
+               {
+                       return path + _T("\\") + subpath;
+               }
+       }
+}
index 5fc7334..ceb9519 100644 (file)
@@ -11,5 +11,6 @@ CString paths_GetCurrentDirectory();
 TCHAR paths_GetCurrentDriveUpper();
 PATH_EXISTENCE GetPairComparability(LPCTSTR pszLeft, LPCTSTR pszRight);
 CString ExpandShortcut(CString &inFile);
+CString paths_ConcatPath(const CString & path, const CString & subpath);
 
 #endif // paths_h_included
index e039b10..7b464c0 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-31 Perry
+ PATCH: [ 712429 ] Fix UpdateItemStatus bug 712093
+ WinMerge: DirActions.cpp DirView.cpp paths.cpp paths.h
+
 2003-03-30 Perry
  PATCH: [ 712417 ] Fix save of open doc before next merge
  WinMerge: ChildFrm.cpp ChildFrm.h DirDoc.cpp DirDoc.h DirFrame.cpp DirFrame.h