From 50ef1d336978cd281ccee69030614dabe3a3991a Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 27 Jul 2021 18:56:42 +0000 Subject: [PATCH] Minor optimizations git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7286 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/Makensisw/makensisw.cpp | 7 +++++-- Contrib/Makensisw/utils.cpp | 5 ++--- Source/util.cpp | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Contrib/Makensisw/makensisw.cpp b/Contrib/Makensisw/makensisw.cpp index 6aa4344e..8a1c2354 100644 --- a/Contrib/Makensisw/makensisw.cpp +++ b/Contrib/Makensisw/makensisw.cpp @@ -57,8 +57,10 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int // Try to register the SysLink class DWORD iccestruct[2] = { 8, 0x8000 }; // ICC_LINK_CLASS (ComCtl32v6) - FARPROC icce = SupportsW95() ? GetSysProcAddr("COMCTL32", "InitCommonControlsEx") : (FARPROC) InitCommonControlsEx; - BOOL succ = ((BOOL(WINAPI*)(const void*))icce)(iccestruct); + BOOL suppw95 = SupportsW95(); + FARPROC icce = suppw95 ? GetSysProcAddr("COMCTL32", "InitCommonControlsEx") : (FARPROC) InitCommonControlsEx; + BOOL succ = (!suppw95 || icce) && ((BOOL(WINAPI*)(const void*))icce)(iccestruct); + #if (!defined(_MSC_VER) && !defined(_WIN64)) || (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_IA64))) // x86 or Itanium if (!succ && (sizeof(void*) > 4 || LOBYTE(GetVersion()) >= 5)) // Must check the version because older shell32 versions have a incompatible function at the same ordinal { FARPROC lwrc = GetSysProcAddr("SHELL32", (LPCSTR) 258); // LinkWindow_RegisterClass @@ -70,6 +72,7 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int RegisterClass(&wc); // Superclass the old link window class if SysLink is not available } } + #endif memset(&g_sdata,0,sizeof(NSCRIPTDATA)); memset(&g_resize,0,sizeof(NRESIZEDATA)); diff --git a/Contrib/Makensisw/utils.cpp b/Contrib/Makensisw/utils.cpp index 366d56d2..be31fcce 100644 --- a/Contrib/Makensisw/utils.cpp +++ b/Contrib/Makensisw/utils.cpp @@ -164,8 +164,7 @@ int SetArgv(const TCHAR *cmdLine, TCHAR ***argv) { void SetTitle(HWND hwnd,const TCHAR *substr) { TCHAR title[64]; - if (substr==NULL) wsprintf(title,_T("MakeNSISW")); - else wsprintf(title,_T("MakeNSISW - %s"),substr); + wsprintf(title,substr ? _T("MakeNSISW - %s") : _T("MakeNSISW"),substr); SetWindowText(hwnd,title); } @@ -183,7 +182,7 @@ void PlayAppSoundAsync(LPCSTR SoundName, int MBFallback) { PLAYAPPSOUNDDATA *p = (PLAYAPPSOUNDDATA*) MemAlloc(sizeof(PLAYAPPSOUNDDATA)); if (p) { p->SoundName = SoundName, p->MBFallback = MBFallback; // Note: The string must be valid until the sound has started because we don't copy it - HANDLE hThread = CreateThread(NULL, 0, PlayAppSoundProc, p, 0, &tid); + HANDLE hThread = CreateThread(NULL, 0, PlayAppSoundProc, p, 0, SupportsW9X() ? &tid : (tid, NULL)); if (hThread) CloseHandle(hThread); else PlayAppSoundProc(p); } } diff --git a/Source/util.cpp b/Source/util.cpp index 96a873c8..d9f7555a 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -196,9 +196,9 @@ TCHAR *CharPrev(const TCHAR *s, const TCHAR *p) { } char *CharNextA(const char *s) { - int l = 0; + int l = 0, mbl; if (s && *s) - l = max(1, mblen(s, MB_CUR_MAX)); + mbl = mblen(s, MB_CUR_MAX), l = max(1, mbl); return const_cast(s + l); }