Fix build...

This commit is contained in:
kaetemi 2019-04-30 12:25:11 +08:00
parent 2eac83a339
commit d2fc5d200e
3 changed files with 31 additions and 20 deletions

View file

@ -312,12 +312,14 @@ inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(
#ifdef _UNICODE #ifdef _UNICODE
#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8()) #define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8())
#define utf8ToTStr(str) ((const wchar_t *)ucstring::makeFromUtf8(str).c_str()) #define utf8ToTStr(str) ((const wchar_t *)ucstring::makeFromUtf8(str).c_str())
#define tstring wstring
#else #else
// FIXME: This is not accurate, it should be a conversion between local charset and utf8 // FIXME: This is not accurate, it should be a conversion between local charset and utf8
#define tStrToUtf8(str) (std::string((LPCSTR)str)) #define tStrToUtf8(str) (std::string((LPCSTR)str))
inline const char *nlutf8ToTStr(const char *str) { return str; } inline const char *nlutf8ToTStr(const char *str) { return str; }
inline const char *nlutf8ToTStr(const std::string &str) { return str.c_str(); } inline const char *nlutf8ToTStr(const std::string &str) { return str.c_str(); }
#define utf8ToTStr(str) NLMISC::nlutf8ToTStr(str) #define utf8ToTStr(str) NLMISC::nlutf8ToTStr(str)
#define tstring string
#endif #endif
#if (NL_COMP_VC_VERSION <= 90) #if (NL_COMP_VC_VERSION <= 90)

View file

@ -220,6 +220,7 @@
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10) # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk # pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
# endif // NL_COMP_VC8 || NL_COMP_VC9 # endif // NL_COMP_VC8 || NL_COMP_VC9
# pragma warning (disable : 26495) // Variable is uninitialized. Always initialize a member variable. (On purpose for performance.)
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS

View file

@ -208,13 +208,13 @@ int CDirDialog::DoBrowse()
} }
BROWSEINFO bInfo; BROWSEINFO bInfo;
LPITEMIDLIST pidl;
ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO)); ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO));
if (!m_strInitDir.IsEmpty()) if (!m_strInitDir.IsEmpty())
{ {
OLECHAR olePath[MAX_PATH]; OLECHAR olePath[MAX_PATH];
ULONG chEaten; ULONG dwAttributes = 0;
ULONG dwAttributes;
HRESULT hr; HRESULT hr;
LPSHELLFOLDER pDesktopFolder; LPSHELLFOLDER pDesktopFolder;
// // Get a pointer to the Desktop's IShellFolder interface. // // // Get a pointer to the Desktop's IShellFolder interface. //
@ -236,7 +236,7 @@ int CDirDialog::DoBrowse()
hr = pDesktopFolder->ParseDisplayName(NULL, hr = pDesktopFolder->ParseDisplayName(NULL,
NULL, NULL,
olePath, olePath,
&chEaten, NULL,
&pidl, &pidl,
&dwAttributes); &dwAttributes);
@ -248,7 +248,6 @@ int CDirDialog::DoBrowse()
} }
bInfo.pidlRoot = pidl; bInfo.pidlRoot = pidl;
} }
} }
@ -257,8 +256,10 @@ int CDirDialog::DoBrowse()
bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle; bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle;
bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
PIDLIST_ABSOLUTE pidl = ::SHBrowseForFolder(&bInfo); if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL)
if (!pidl) return 0; {
return 0;
}
m_strPath.ReleaseBuffer(); m_strPath.ReleaseBuffer();
m_iImageIndex = bInfo.iImage; m_iImageIndex = bInfo.iImage;
@ -288,19 +289,26 @@ BOOL SendTextToClipboard(CString source)
if (OpenClipboard(NULL)) if (OpenClipboard(NULL))
{ {
HGLOBAL clipbuffer; HGLOBAL clipbuffer;
char* buffer; TCHAR* buffer;
EmptyClipboard(); // Empty whatever's already there EmptyClipboard(); // Empty whatever's already there
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength() + 1); clipbuffer = GlobalAlloc(GMEM_DDESHARE, ((SIZE_T)source.GetLength() + 1) * sizeof(TCHAR));
buffer = (char*)GlobalLock(clipbuffer); if (clipbuffer)
strcpy(buffer, LPCSTR(source)); {
GlobalUnlock(clipbuffer); buffer = (TCHAR*)GlobalLock(clipbuffer);
if (buffer)
{
_tcscpy(buffer, LPCTSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT, clipbuffer); // Send the data SetClipboardData(CF_TEXT, clipbuffer); // Send the data
CloseClipboard(); // VERY IMPORTANT
return TRUE;
}
}
CloseClipboard(); // VERY IMPORTANT CloseClipboard(); // VERY IMPORTANT
return TRUE;
} }
return FALSE; return FALSE;
} }
@ -326,11 +334,11 @@ void CBranch_patcherDlg::OnButtonPatch()
CString text; CString text;
text.Format(_T("Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), m_SrcDir, diffCmdLine); text.Format(_T("Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), m_SrcDir, diffCmdLine);
int result; int result;
if ((result = ::MessageBox(m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) if ((result = ::MessageBox(m_hWnd, text, _T("Confirmation"), MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES)
{ {
if (_chdir(m_SrcDir) == 0) if (_tchdir(m_SrcDir) == 0)
{ {
system(diffCmdLine); _tsystem(diffCmdLine);
displayFile(TEMP_DIFF_FILE); displayFile(TEMP_DIFF_FILE);
SaveDiff = true; SaveDiff = true;
colorizeDiff(); colorizeDiff();
@ -461,11 +469,11 @@ void CBranch_patcherDlg::OnDoPatch()
int result; int result;
if ((result = ::MessageBox(m_hWnd, text, _T("Confirmation"), MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) if ((result = ::MessageBox(m_hWnd, text, _T("Confirmation"), MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES)
{ {
if (_chdir(m_DestDir) == 0) if (_tchdir(m_DestDir) == 0)
{ {
system(patchCmdLine); _tsystem(patchCmdLine);
system(concatOutput); _tsystem(concatOutput);
system(delPatchErrors); _tsystem(delPatchErrors);
displayFile(PATCH_RESULT); displayFile(PATCH_RESULT);
SaveDiff = false; SaveDiff = false;
m_Display->LineScroll(0); m_Display->LineScroll(0);