From fe1c267d4e12472042e81d587a4c14262744580d Mon Sep 17 00:00:00 2001 From: Perry Rapp Date: Mon, 31 Mar 2003 15:48:45 +0000 Subject: [PATCH] PATCH: [ 712429 ] Fix UpdateItemStatus bug 712093 --- Src/DirActions.cpp | 14 +++++++------- Src/DirView.cpp | 4 ++-- Src/paths.cpp | 31 +++++++++++++++++++++++++++++++ Src/paths.h | 1 + Src/readme.txt | 4 ++++ 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Src/DirActions.cpp b/Src/DirActions.cpp index 0048e3452..7474b8d43 100644 --- a/Src/DirActions.cpp +++ b/Src/DirActions.cpp @@ -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 diff --git a/Src/DirView.cpp b/Src/DirView.cpp index fd1fd9200..dcd1e2c9a 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -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: diff --git a/Src/paths.cpp b/Src/paths.cpp index a3e6e8ec7..72e448725 100644 --- a/Src/paths.cpp +++ b/Src/paths.cpp @@ -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; + } + } +} diff --git a/Src/paths.h b/Src/paths.h index 5fc733457..ceb9519f2 100644 --- a/Src/paths.h +++ b/Src/paths.h @@ -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 diff --git a/Src/readme.txt b/Src/readme.txt index e039b10cf..7b464c00b 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -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 -- 2.11.0