switches = _T(" ");
break;
case DIFF_OUTPUT_CONTEXT:
- switches = _T(" C");
+ switches = (m_options.m_contextLines > 0) ? _T(" -C ") : _T(" -c");
break;
case DIFF_OUTPUT_UNIFIED:
- switches = _T(" U");
+ switches = (m_options.m_contextLines > 0) ? _T(" -U ") : _T(" -u");
break;
#if 0
case DIFF_OUTPUT_ED:
#endif
}
- if (m_options.m_contextLines > 0)
+ if ((m_options.m_outputStyle == DIFF_OUTPUT_CONTEXT || m_options.m_outputStyle == DIFF_OUTPUT_UNIFIED) &&
+ m_options.m_contextLines > 0)
{
TCHAR tmpNum[5] = {0};
_itot_s(m_options.m_contextLines, tmpNum, 10);
}
if (ignore_all_space_flag > 0)
- switches += _T("w");
+ switches += _T(" -w");
if (ignore_blank_lines_flag > 0)
- switches += _T("B");
+ switches += _T(" -B");
if (ignore_case_flag > 0)
- switches += _T("i");
+ switches += _T(" -i");
if (ignore_space_change_flag > 0)
- switches += _T("b");
+ switches += _T(" -b");
return switches;
}
if (strcmp(inf[0].name, "NUL") == 0)
{
- free((void *)inf[0].name);
- inf[0].name = _strdup("/dev/null");
+ free((void *)inf_patch[0].name);
+ inf_patch[0].name = _strdup("/dev/null");
}
if (strcmp(inf[1].name, "NUL") == 0)
{
- free((void *)inf[1].name);
- inf[1].name = _strdup("/dev/null");
+ free((void *)inf_patch[1].name);
+ inf_patch[1].name = _strdup("/dev/null");
}
// Output patchfile
#include "DiffWrapper.h"
#include "PathContext.h"
#include "PatchDlg.h"
-#include "TFile.h"
-#include "TempFile.h"
#include "paths.h"
#include "Merge.h"
m_diffWrapper.WritePatchFileHeader(dlgPatch.m_outputStyle, dlgPatch.m_appendFile);
m_diffWrapper.SetAppendFiles(true);
- TempFile emptyFile;
- emptyFile.Create();
- TFile file(emptyFile.GetPath());
- file.setLastModified(Poco::Timestamp::fromEpochTime(0));
-
for (size_t index = 0; index < fileCount; index++)
{
const PATCHFILES& tFiles = dlgPatch.GetItemAt(index);
- String filename1 = tFiles.lfile.length() == 0 ? emptyFile.GetPath() : tFiles.lfile;
- String filename2 = tFiles.rfile.length() == 0 ? emptyFile.GetPath() : tFiles.rfile;
+ String filename1 = tFiles.lfile.length() == 0 ? _T("NUL") : tFiles.lfile;
+ String filename2 = tFiles.rfile.length() == 0 ? _T("NUL") : tFiles.rfile;
// Set up DiffWrapper
m_diffWrapper.SetPaths(PathContext(filename1, filename2), false);
appears_binary |= sip (&filevec[1], skip_test | appears_binary);
}
- // Are both files Open and Regular (no Pipes, Directories, Devices (e.g. NUL))
+ // Are both files Open and Regular (no Pipes, Directories, Devices (except NUL))
if (filevec[0].desc < 0 || filevec[1].desc < 0 ||
- !(S_ISREG (filevec[0].stat.st_mode)) || !(S_ISREG (filevec[1].stat.st_mode)) )
- {
- assert(!S_ISCHR(filevec[0].stat.st_mode) || strcmp(filevec[0].name, "NUL")==0);
- assert(!S_ISCHR(filevec[1].stat.st_mode) || strcmp(filevec[1].name, "NUL")==0);
+ (!(S_ISREG (filevec[0].stat.st_mode)) && strcmp(filevec[0].name, "NUL") != 0) ||
+ (!(S_ISREG (filevec[1].stat.st_mode)) && strcmp(filevec[1].name, "NUL") != 0))
+ {
+ assert(!S_ISCHR(filevec[0].stat.st_mode));
+ assert(!S_ISCHR(filevec[1].stat.st_mode));
return appears_binary;
- }
+ }
if (appears_binary)
{
\r
inline time_t filetime_to_time_t(const FILETIME& ft)\r
{\r
- return ((static_cast<time_t>(ft.dwHighDateTime) << 32) + ft.dwLowDateTime) / 10000000ULL - 11644473600ULL;\r
+ if (ft.dwHighDateTime == 0 && ft.dwLowDateTime == 0)\r
+ return 0;\r
+ else\r
+ return ((static_cast<time_t>(ft.dwHighDateTime) << 32) + ft.dwLowDateTime) / 10000000ULL - 11644473600ULL;\r
}\r
\r
template<typename FileInfo>\r