From: Kimmo Varis Date: Thu, 14 Apr 2005 20:00:34 +0000 (+0000) Subject: PATCH: [ 1182416 ] Fix Compare by date hang X-Git-Tag: 2.16.5~6056 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9e6d75a111a384785a0b8d88dd8a7b94dbb64be9;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 1182416 ] Fix Compare by date hang --- diff --git a/Src/DiffContext.cpp b/Src/DiffContext.cpp index 5c6a2b4c0..ea4446b6e 100644 --- a/Src/DiffContext.cpp +++ b/Src/DiffContext.cpp @@ -62,6 +62,7 @@ CDiffContext::CDiffContext(LPCTSTR pszLeft /*=NULL*/, LPCTSTR pszRight /*=NULL*/ , m_piPluginInfos(NULL) , m_msgUpdateStatus(0) , m_hDirFrame(NULL) +, m_nCompMethod(-1) { m_strLeft = pszLeft; m_strRight = pszRight; @@ -97,6 +98,7 @@ CDiffContext::CDiffContext(LPCTSTR pszLeft, LPCTSTR pszRight, CDiffContext& src) m_piFilterGlobal = src.m_piFilterGlobal; m_msgUpdateStatus = src.m_msgUpdateStatus; m_hDirFrame = src.m_hDirFrame; + m_nCompMethod = src.m_nCompMethod; m_strNormalizedLeft = pszLeft; paths_normalize(m_strNormalizedLeft); diff --git a/Src/DiffContext.h b/Src/DiffContext.h index f2fd611bf..afd13219f 100644 --- a/Src/DiffContext.h +++ b/Src/DiffContext.h @@ -76,6 +76,9 @@ class CDiffContext; * One dimension is existence: both sides, left only, or right only * * One dimension is type: directory, or file + * + * @note times in fileinfo's are seconds since January 1, 1970. + * See Dirscan.cpp/fentry and Dirscan.cpp/LoadFiles() */ struct DIFFITEM : DIFFCODE @@ -109,8 +112,13 @@ public: PrediffingInfo ** infoPrediffer) = 0; }; - -class CDiffContext +/** + * @brief Directory compare context. + * + * @note If you add new member variables, remember to copy values in + * CDiffContext::CDiffContext(..,CDiffContext) constructor! + */ +class CDiffContext { public: CDiffContext(LPCTSTR pszLeft, LPCTSTR pszRight); diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index 95fef81f0..b9d879459 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -1507,16 +1507,22 @@ DiffFileData::prepAndCompareTwoFiles(CDiffContext * pCtxt, const CString & filep } - if (pCtxt->m_nCompMethod == 0) + if (pCtxt->m_nCompMethod == CMP_CONTENT) { // use diffutils code = diffutils_compare_files(0); } - else + else if (pCtxt->m_nCompMethod == CMP_QUICK_CONTENT) { // use our own byte-by-byte compare code = byte_compare_files(); } + else + { + // Print error since we should have handled by date compare earlier + _RPTF0(_CRT_ERROR, "Invalid compare type, DiffFileData can't handle it"); + goto exitPrepAndCompare; + } if ((code & DIFFCODE::CMPERR) == 0) { diff --git a/Src/DiffWrapper.h b/Src/DiffWrapper.h index b7fa55ebc..216d22324 100644 --- a/Src/DiffWrapper.h +++ b/Src/DiffWrapper.h @@ -39,6 +39,7 @@ struct DiffFileData; enum { CMP_CONTENT = 0, /**< Normal by content compare */ + CMP_QUICK_CONTENT, /**< Custom content compare */ CMP_DATE, /**< Compare by modified date */ }; diff --git a/Src/DirScan.cpp b/Src/DirScan.cpp index eb45e719d..3c6aa67cf 100644 --- a/Src/DirScan.cpp +++ b/Src/DirScan.cpp @@ -27,15 +27,16 @@ static char THIS_FILE[] = __FILE__; // Static types (ie, types only used locally) /** * @brief directory or file info for one row in diff result + * @note times are seconds since January 1, 1970. */ struct fentry { CString name; // storing __time_t if MSVC6 (__MSC_VER<1300) // storing __time64_t if MSVC7 (VC.NET) - __int64 mtime; - __int64 ctime; - _int64 size; + __int64 mtime; /**< Last modify time */ + __int64 ctime; /**< Creation modify time */ + __int64 size; int attrs; }; typedef CArray fentryArray; @@ -183,7 +184,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, nDiffCode |= DIFFCODE::SKIPPED; StoreDiffResult(subdir, &leftFiles[i], 0, nDiffCode, pCtxt); } - else if (pCtxt->m_nCompMethod != 1) + else if (pCtxt->m_nCompMethod != CMP_DATE) { // Compare file to itself to detect encoding CString filepath = sLeftDir + backslash + leftFiles[i].name; @@ -211,7 +212,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, nDiffCode |= DIFFCODE::SKIPPED; StoreDiffResult(subdir, 0, &rightFiles[j], nDiffCode, pCtxt); } - else if (pCtxt->m_nCompMethod != 1) + else if (pCtxt->m_nCompMethod != CMP_DATE) { // Compare file to itself to detect encoding CString filepath = sRightDir + backslash + rightFiles[j].name; @@ -251,7 +252,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, gLog.Write(_T("Comparing: n0=%s, n1=%s, d0=%s, d1=%s"), leftname, rightname, (LPCTSTR)sLeftDir, (LPCTSTR)sRightDir); - if (pCtxt->m_nCompMethod == 1) + if (pCtxt->m_nCompMethod == CMP_DATE) { // Compare only by modified date if (leftFiles[i].mtime == rightFiles[j].mtime) @@ -310,6 +311,7 @@ void LoadFiles(const CString & sDir, fentryArray * dirs, fentryArray * files) if (dwIsDirectory && StrStr(_T(".."), ff.cFileName)) continue; fentry ent; + // Save filetimes as seconds since January 1, 1970 ent.ctime = CTime(ff.ftCreationTime).GetTime(); ent.mtime = CTime(ff.ftLastWriteTime).GetTime(); if (!dwIsDirectory) diff --git a/Src/readme.txt b/Src/readme.txt index 9ab96128e..64a4fb828 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2005-04-14 Kimmo + PATCH: [ 1182416 ] Fix Compare by date hang + Src: DiffContext.cpp DiffContext.h DiffWrapper.cpp DiffWrapper.h DirScan.cpp + 2005-04-13 Perry BUG: [ 1181906 ] Comment in LoadFromDirectory maybe wrong? (cosmetic)