From: Perry Rapp Date: Thu, 29 Dec 2005 18:13:43 +0000 (+0000) Subject: PATCH: [ 1392729 ] Cleanup variables in RunFileDiff X-Git-Tag: 2.16.5~5446 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=cb2166743ad54b902f7ae5ef2f4659333c81e3a6;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 1392729 ] Cleanup variables in RunFileDiff Src: DiffWrapper.cpp --- diff --git a/Src/Changes.txt b/Src/Changes.txt index db5e235c7..2757f8ad6 100644 --- a/Src/Changes.txt +++ b/Src/Changes.txt @@ -6,6 +6,8 @@ SyntaxColors.h codepage.h PATCH: [ 1392650 ] Fix locals of CDiffWrapper::RunFileDiff Src: DiffWrapper.cpp DiffWrapper.h MergeDoc.cpp PatchTool.cpp + PATCH: [ 1392729 ] Cleanup variables in RunFileDiff + Src: DiffWrapper.cpp 2005-12-28 Perry PATCH: [ 1391732 ] Do not offer to unify codepages in UNICODE build diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index 7341c78ea..e797898a7 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -226,11 +226,6 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP if (m_bUseDiffList) m_nDiffs = m_pDiffList->GetSize(); - // perform rescan - CString sdir0, sdir1, sname0, sname1, sext0, sext1; - struct change *e, *p; - struct change *script = NULL; - // Are our working files overwritable (temp)? BOOL bMayOverwrite = (areTempFiles == YESTEMPFILES); @@ -275,17 +270,15 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP FileTransform_UCS2ToUTF8(strFile2Temp, bMayOverwrite); DiffFileData diffdata; - // This opens & fstats both files (if it succeeds) if (!diffdata.OpenFiles(strFile1Temp, strFile2Temp)) { return FALSE; } - file_data * inf = diffdata.m_inf; - /* Compare the files, if no error was found. */ int bin_flag = 0; + struct change *script = NULL; bRet = Diff2Files(&script, &diffdata, &bin_flag); // We don't anymore create diff-files for every rescan. @@ -326,6 +319,7 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP m_status.bIdentical = (script == 0); m_status.bBinaries = FALSE; } + file_data * inf = diffdata.m_inf; m_status.bLeftMissingNL = inf[0].missing_newline; m_status.bRightMissingNL = inf[1].missing_newline; @@ -394,9 +388,7 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP if (!m_status.bBinaries && m_bUseDiffList) { struct change *next = script; - int trans_a0, trans_b0, trans_a1, trans_b1; - int first0, last0, first1, last1, deletes, inserts, op; - struct change *thisob, *end; + struct change *thisob=0, *end=0; while (next) { @@ -416,7 +408,9 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP //(*printfun) (thisob); { /* Determine range of line numbers involved in each file. */ + int first0=0, last0=0, first1=0, last1=0, deletes=0, inserts=0; analyze_hunk (thisob, &first0, &last0, &first1, &last1, &deletes, &inserts); + int op=0; if (deletes || inserts || thisob->trivial) { if (deletes && inserts) @@ -429,8 +423,9 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP op = OP_TRIVIAL; /* Print the lines that the first file has. */ - translate_range (&inf[0], first0, last0, &trans_a0, &trans_b0); - translate_range (&inf[1], first1, last1, &trans_a1, &trans_b1); + int trans_a0=0, trans_b0=0, trans_a1=0, trans_b1=0; + translate_range(&inf[0], first0, last0, &trans_a0, &trans_b0); + translate_range(&inf[1], first1, last1, &trans_a1, &trans_b1); // Store information about these blocks in moved line info if (thisob->match0>=0) @@ -465,11 +460,15 @@ BOOL CDiffWrapper::RunFileDiff(CString & filepath1, CString & filepath2, ARETEMP } } - // cleanup the script - for (e = script; e; e = p) + if (script) { - p = e->link; - free (e); + struct change *e=0, *p=0; + // cleanup the script + for (e = script; e; e = p) + { + p = e->link; + free(e); + } }