Major POSIX overhaul
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6416 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1e55e30ff4
commit
be6c7e6a1d
35 changed files with 1718 additions and 1412 deletions
|
@ -13,15 +13,15 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <cderr.h>
|
#include <cderr.h>
|
||||||
|
#include <shellapi.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "shellapi.h"
|
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
|
||||||
#ifdef _countof
|
|
||||||
#define COUNTOF _countof
|
|
||||||
#else
|
|
||||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||||
|
#ifndef min
|
||||||
|
#include <algorithm>
|
||||||
|
#define min std::min // mingw64?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use for functions only called from one place to possibly reduce some code
|
// Use for functions only called from one place to possibly reduce some code
|
||||||
|
|
|
@ -27,11 +27,7 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
|
|
||||||
#ifdef _countof
|
|
||||||
#define COUNTOF _countof
|
|
||||||
#else
|
|
||||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MRU_LIST_SIZE 5
|
#define MRU_LIST_SIZE 5
|
||||||
#define MRU_DISPLAY_LENGTH 40
|
#define MRU_DISPLAY_LENGTH 40
|
||||||
|
|
|
@ -108,6 +108,12 @@
|
||||||
|
|
||||||
\b NSIS 3 patron saint
|
\b NSIS 3 patron saint
|
||||||
|
|
||||||
|
\H{testers} Testers
|
||||||
|
|
||||||
|
\e{Jason Ross aka JasonFriday13}
|
||||||
|
|
||||||
|
\b NSIS 3 POSIX support
|
||||||
|
|
||||||
\H{designers} Designers
|
\H{designers} Designers
|
||||||
|
|
||||||
\e{Nikos Adamamas}
|
\e{Nikos Adamamas}
|
||||||
|
|
|
@ -24,6 +24,8 @@ Released on ?
|
||||||
|
|
||||||
\b Unicode stubs create WCHAR richedit controls (\W{http://sf.net/p/nsis/bugs/1080/}{bug #1080})
|
\b Unicode stubs create WCHAR richedit controls (\W{http://sf.net/p/nsis/bugs/1080/}{bug #1080})
|
||||||
|
|
||||||
|
\b Fixed !macroundef
|
||||||
|
|
||||||
\b Fixed MakeNSISW default pushbutton and tab order
|
\b Fixed MakeNSISW default pushbutton and tab order
|
||||||
|
|
||||||
\H{v3.0a1} 3.0 Alpha 1
|
\H{v3.0a1} 3.0 Alpha 1
|
||||||
|
|
|
@ -31,11 +31,14 @@ if msvs_version >= 8.0:
|
||||||
defenv['EXCEPTION_FLAG'] = '/EHsc'
|
defenv['EXCEPTION_FLAG'] = '/EHsc'
|
||||||
defenv.Append(CCFLAGS = ['/GS-'])
|
defenv.Append(CCFLAGS = ['/GS-'])
|
||||||
defenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS', '_CRT_NONSTDC_NO_WARNINGS', '_CRT_SECURE_NO_DEPRECATE', '_CRT_NON_CONFORMING_SWPRINTFS'])
|
defenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS', '_CRT_NONSTDC_NO_WARNINGS', '_CRT_SECURE_NO_DEPRECATE', '_CRT_NON_CONFORMING_SWPRINTFS'])
|
||||||
|
defenv['MSVCRT_FLAG'] = '/MT' # Avoid msvcr?0.dll dependency
|
||||||
else:
|
else:
|
||||||
defenv['EXCEPTION_FLAG'] = '/GX'
|
defenv['EXCEPTION_FLAG'] = '/GX'
|
||||||
if msvs_version < 10.0:
|
if msvs_version < 10.0:
|
||||||
# not even /ALIGN:512 works for vc10... fails to load process
|
# not even /ALIGN:512 works for vc10... fails to load process
|
||||||
defenv.Append(LINKFLAGS = ['/opt:nowin98'])
|
defenv.Append(LINKFLAGS = ['/opt:nowin98'])
|
||||||
|
if defenv['MSTOOLKIT']:
|
||||||
|
defenv['MSVCRT_FLAG'] = '/ML' # TK2003 does not have all libs
|
||||||
|
|
||||||
### defines
|
### defines
|
||||||
|
|
||||||
|
@ -51,6 +54,7 @@ if defenv['DEBUG']:
|
||||||
defenv.Append(CCFLAGS = ['/Zi'])
|
defenv.Append(CCFLAGS = ['/Zi'])
|
||||||
defenv.Append(CCFLAGS = ['/Fd${TARGET.dir}\\${TARGET.dir.file}.pdb'])
|
defenv.Append(CCFLAGS = ['/Fd${TARGET.dir}\\${TARGET.dir.file}.pdb'])
|
||||||
defenv.Append(LINKFLAGS = ['/debug'])
|
defenv.Append(LINKFLAGS = ['/debug'])
|
||||||
|
defenv['MSVCRT_FLAG'] = defenv['MSVCRT_FLAG'] + 'd'
|
||||||
|
|
||||||
### workarounds
|
### workarounds
|
||||||
|
|
||||||
|
@ -109,7 +113,7 @@ stub_env = defenv.Clone()
|
||||||
stub_env.Append(CPPPATH = ['#$BUILD_CONFIG'])
|
stub_env.Append(CPPPATH = ['#$BUILD_CONFIG'])
|
||||||
|
|
||||||
if not defenv['DEBUG']:
|
if not defenv['DEBUG']:
|
||||||
stub_env.Append(CCFLAGS = ['/O1']) # optimize for size
|
stub_env.Append(CCFLAGS = ['/O1']) # optimize for size
|
||||||
stub_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
stub_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
||||||
stub_env.Append(CCFLAGS = ['/FAcs']) # full listing files
|
stub_env.Append(CCFLAGS = ['/FAcs']) # full listing files
|
||||||
stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
|
stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
|
||||||
|
@ -132,6 +136,7 @@ makensis_env.Append(CCFLAGS = ['$EXCEPTION_FLAG']) # enable exceptions
|
||||||
makensis_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
makensis_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
||||||
makensis_env.Append(CCFLAGS = ['/FAcs']) # full listing files
|
makensis_env.Append(CCFLAGS = ['/FAcs']) # full listing files
|
||||||
makensis_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
|
makensis_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
|
||||||
|
makensis_env.Append(CCFLAGS = [defenv['MSVCRT_FLAG']])
|
||||||
|
|
||||||
makensis_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
makensis_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
||||||
if defenv['UNICODE']:
|
if defenv['UNICODE']:
|
||||||
|
@ -157,6 +162,7 @@ util_env = tdefenv.Clone()
|
||||||
if not defenv['DEBUG']:
|
if not defenv['DEBUG']:
|
||||||
util_env.Append(CCFLAGS = ['/O1']) # optimize for speed
|
util_env.Append(CCFLAGS = ['/O1']) # optimize for speed
|
||||||
util_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
util_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
||||||
|
util_env.Append(CCFLAGS = [defenv['MSVCRT_FLAG']])
|
||||||
|
|
||||||
util_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
util_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
||||||
|
|
||||||
|
|
18
SConstruct
18
SConstruct
|
@ -209,15 +209,15 @@ if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']:
|
||||||
# Need this early for the config header files to be placed in
|
# Need this early for the config header files to be placed in
|
||||||
|
|
||||||
if defenv['UNICODE']:
|
if defenv['UNICODE']:
|
||||||
if defenv['DEBUG']:
|
if defenv['DEBUG']:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/udebug')
|
defenv.Replace(BUILD_PREFIX = 'build/udebug')
|
||||||
else:
|
else:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/urelease')
|
defenv.Replace(BUILD_PREFIX = 'build/urelease')
|
||||||
else:
|
else:
|
||||||
if defenv['DEBUG']:
|
if defenv['DEBUG']:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/debug')
|
defenv.Replace(BUILD_PREFIX = 'build/debug')
|
||||||
else:
|
else:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/release')
|
defenv.Replace(BUILD_PREFIX = 'build/release')
|
||||||
|
|
||||||
defenv.Replace(BUILD_CONFIG = defenv.subst('$BUILD_PREFIX/config'))
|
defenv.Replace(BUILD_CONFIG = defenv.subst('$BUILD_PREFIX/config'))
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ defines_h.close()
|
||||||
# write version into version.h
|
# write version into version.h
|
||||||
f = open(defenv.File('#$BUILD_CONFIG/nsis-version.h').abspath, 'w')
|
f = open(defenv.File('#$BUILD_CONFIG/nsis-version.h').abspath, 'w')
|
||||||
f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n')
|
f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n')
|
||||||
f.write('#include "tchar.h"\n')
|
f.write('#include "%s"\n' % File('#/Source/tchar.h').abspath)
|
||||||
|
|
||||||
if (not defenv.has_key('VER_PACKED')) and defenv.has_key('VER_MAJOR') and defenv.has_key('VER_MINOR'):
|
if (not defenv.has_key('VER_PACKED')) and defenv.has_key('VER_MAJOR') and defenv.has_key('VER_MINOR'):
|
||||||
packed_r = packed_b = 0
|
packed_r = packed_b = 0
|
||||||
|
|
|
@ -46,7 +46,7 @@ static inline short ConvertEndianness(short s) {
|
||||||
#define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn
|
#define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn
|
||||||
|
|
||||||
// Reads a variant length array from seeker into readInto and advances seeker
|
// Reads a variant length array from seeker into readInto and advances seeker
|
||||||
void ReadVarLenArr(LPBYTE &seeker, WCHAR* &readInto, unsigned int uCodePage) {
|
void ReadVarLenArr(LPBYTE &seeker, WINWCHAR* &readInto, unsigned int uCodePage) {
|
||||||
WORD* arr = (WORD*)seeker;
|
WORD* arr = (WORD*)seeker;
|
||||||
switch (ConvertEndianness(arr[0])) {
|
switch (ConvertEndianness(arr[0])) {
|
||||||
case 0x0000:
|
case 0x0000:
|
||||||
|
@ -54,13 +54,13 @@ void ReadVarLenArr(LPBYTE &seeker, WCHAR* &readInto, unsigned int uCodePage) {
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
break;
|
break;
|
||||||
case 0xFFFF:
|
case 0xFFFF:
|
||||||
readInto = MAKEINTRESOURCEW(ConvertEndianness(arr[1]));
|
readInto = MAKEINTRESOURCEWINW(ConvertEndianness(arr[1]));
|
||||||
seeker += 2*sizeof(WORD);
|
seeker += 2*sizeof(WORD);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
readInto = wcsdup((WCHAR *) arr);
|
readInto = WinWStrDupFromWinWStr((WINWCHAR*) arr);
|
||||||
PWCHAR wseeker = PWCHAR(seeker);
|
WINWCHAR *wseeker = (WINWCHAR*) seeker;
|
||||||
while (*wseeker++);
|
while (*wseeker++);
|
||||||
seeker = LPBYTE(wseeker);
|
seeker = LPBYTE(wseeker);
|
||||||
}
|
}
|
||||||
|
@ -78,14 +78,14 @@ void ReadVarLenArr(LPBYTE &seeker, WCHAR* &readInto, unsigned int uCodePage) {
|
||||||
seeker += sizeof(WORD); \
|
seeker += sizeof(WORD); \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
wcscpy((WCHAR *) seeker, x); \
|
WinWStrCpy((WINWCHAR *) seeker, x); \
|
||||||
seeker += wcslen((WCHAR *) seeker) * sizeof(WCHAR) + sizeof(WCHAR); \
|
seeker += WinWStrLen((WINWCHAR *) seeker) * sizeof(WINWCHAR) + sizeof(WINWCHAR); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
|
|
||||||
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
||||||
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (wcslen(x) + 1) * sizeof(WCHAR)) : sizeof(WORD)
|
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (WinWStrLen(x) + 1) * sizeof(WINWCHAR)) : sizeof(WORD)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
|
@ -220,23 +220,22 @@ CDialogTemplate::CDialogTemplate(BYTE* pbData, bool build_unicode, unsigned int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_template_string(WINWCHAR*s)
|
||||||
|
{
|
||||||
|
if (!IS_INTRESOURCE(s)) free(s);
|
||||||
|
}
|
||||||
|
|
||||||
CDialogTemplate::~CDialogTemplate() {
|
CDialogTemplate::~CDialogTemplate() {
|
||||||
if (m_szMenu && !IS_INTRESOURCE(m_szMenu))
|
free_template_string(m_szMenu);
|
||||||
delete [] m_szMenu;
|
free_template_string(m_szClass);
|
||||||
if (m_szClass && !IS_INTRESOURCE(m_szClass))
|
free(m_szTitle);
|
||||||
delete [] m_szClass;
|
free(m_szFont);
|
||||||
if (m_szTitle)
|
|
||||||
delete [] m_szTitle;
|
|
||||||
if (m_szFont)
|
|
||||||
free(m_szFont);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||||
if (m_vItems[i]->szClass && !IS_INTRESOURCE(m_vItems[i]->szClass))
|
free_template_string(m_vItems[i]->szClass);
|
||||||
delete [] m_vItems[i]->szClass;
|
free_template_string(m_vItems[i]->szTitle);
|
||||||
if (m_vItems[i]->szTitle && !IS_INTRESOURCE(m_vItems[i]->szTitle))
|
if (m_vItems[i]->szCreationData) delete [] m_vItems[i]->szCreationData;
|
||||||
delete [] m_vItems[i]->szTitle;
|
delete m_vItems[i];
|
||||||
if (m_vItems[i]->szCreationData)
|
|
||||||
delete [] m_vItems[i]->szCreationData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +292,7 @@ void CDialogTemplate::SetFont(TCHAR* szFaceName, WORD wFontSize) {
|
||||||
m_bCharset = DEFAULT_CHARSET;
|
m_bCharset = DEFAULT_CHARSET;
|
||||||
m_dwStyle |= DS_SETFONT;
|
m_dwStyle |= DS_SETFONT;
|
||||||
if (m_szFont) free(m_szFont);
|
if (m_szFont) free(m_szFont);
|
||||||
m_szFont = wcsdup_fromTchar(szFaceName, m_uCodePage);
|
m_szFont = WinWStrDupFromTChar(szFaceName, m_uCodePage);
|
||||||
m_sFontSize = wFontSize;
|
m_sFontSize = wFontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,10 +302,10 @@ void CDialogTemplate::AddItem(DialogItemTemplate item) {
|
||||||
CopyMemory(newItem, &item, sizeof(DialogItemTemplate));
|
CopyMemory(newItem, &item, sizeof(DialogItemTemplate));
|
||||||
|
|
||||||
if (item.szClass && !IS_INTRESOURCE(item.szClass)) {
|
if (item.szClass && !IS_INTRESOURCE(item.szClass)) {
|
||||||
newItem->szClass = _wcsdup(item.szClass);
|
newItem->szClass = WinWStrDupFromWinWStr(item.szClass);
|
||||||
}
|
}
|
||||||
if (item.szTitle && !IS_INTRESOURCE(item.szTitle)) {
|
if (item.szTitle && !IS_INTRESOURCE(item.szTitle)) {
|
||||||
newItem->szTitle = _wcsdup(item.szTitle);
|
newItem->szTitle = WinWStrDupFromWinWStr(item.szTitle);
|
||||||
}
|
}
|
||||||
if (item.wCreateDataSize) {
|
if (item.wCreateDataSize) {
|
||||||
newItem->szCreationData = new char[item.wCreateDataSize];
|
newItem->szCreationData = new char[item.wCreateDataSize];
|
||||||
|
@ -475,18 +474,18 @@ void CDialogTemplate::ConvertToRTL() {
|
||||||
m_vItems[i]->dwStyle |= SS_CENTERIMAGE;
|
m_vItems[i]->dwStyle |= SS_CENTERIMAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsnicmp(m_vItems[i]->szClass, L"RichEdit20", 10)) {
|
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !WinWStrNICmpASCII(m_vItems[i]->szClass, "RichEdit20", 10)) {
|
||||||
if ((m_vItems[i]->dwStyle & ES_CENTER) == 0) {
|
if ((m_vItems[i]->dwStyle & ES_CENTER) == 0) {
|
||||||
m_vItems[i]->dwStyle ^= ES_RIGHT;
|
m_vItems[i]->dwStyle ^= ES_RIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsicmp(m_vItems[i]->szClass, L"SysTreeView32")) {
|
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !WinWStrICmpASCII(m_vItems[i]->szClass, "SysTreeView32")) {
|
||||||
m_vItems[i]->dwStyle |= TVS_RTLREADING;
|
m_vItems[i]->dwStyle |= TVS_RTLREADING;
|
||||||
m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL;
|
m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL;
|
||||||
addExStyle = true;
|
addExStyle = true;
|
||||||
addExLeftScrollbar = false;
|
addExLeftScrollbar = false;
|
||||||
}
|
}
|
||||||
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsicmp(m_vItems[i]->szClass, L"SysListView32")) {
|
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !WinWStrICmpASCII(m_vItems[i]->szClass, "SysListView32")) {
|
||||||
m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL;
|
m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL;
|
||||||
addExLeftScrollbar = false;
|
addExLeftScrollbar = false;
|
||||||
}
|
}
|
||||||
|
@ -603,12 +602,14 @@ BYTE* CDialogTemplate::Save(DWORD& dwSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write class variant length array
|
// Write class variant length array
|
||||||
const WCHAR *szClass = m_vItems[i]->szClass;
|
const WINWCHAR *szClass = m_vItems[i]->szClass;
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
|
static const WINWCHAR clsRE20W[] = {'R','i','c','h','E','d','i','t','2','0','W',0};
|
||||||
|
static const WINWCHAR clsRE20A[] = {'R','i','c','h','E','d','i','t','2','0','A',0};
|
||||||
if (!IS_INTRESOURCE(szClass)) {
|
if (!IS_INTRESOURCE(szClass)) {
|
||||||
// transmute RichEdit20A/W control into RichEdit20T that matches the target
|
// transmute RichEdit20A/W control into RichEdit20T that matches the target
|
||||||
if (m_build_unicode && !_wcsicmp(szClass, L"RichEdit20A")) szClass = L"RichEdit20W";
|
if (m_build_unicode && !WinWStrICmpASCII(szClass, "RichEdit20A")) szClass = clsRE20W;
|
||||||
if (!m_build_unicode && !_wcsicmp(szClass, L"RichEdit20W")) szClass = L"RichEdit20A";
|
if (!m_build_unicode && !WinWStrICmpASCII(szClass, "RichEdit20W")) szClass = clsRE20A;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
WriteStringOrId(szClass);
|
WriteStringOrId(szClass);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include "winchar.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -45,8 +46,8 @@ struct DialogItemTemplate {
|
||||||
DWORD dwStyle;
|
DWORD dwStyle;
|
||||||
WORD wId;
|
WORD wId;
|
||||||
|
|
||||||
WCHAR *szClass;
|
WINWCHAR *szClass;
|
||||||
WCHAR *szTitle;
|
WINWCHAR *szTitle;
|
||||||
char *szCreationData;
|
char *szCreationData;
|
||||||
|
|
||||||
WORD wCreateDataSize;
|
WORD wCreateDataSize;
|
||||||
|
@ -148,16 +149,16 @@ private:
|
||||||
DWORD m_dwExtStyle;
|
DWORD m_dwExtStyle;
|
||||||
DWORD m_dwStyle;
|
DWORD m_dwStyle;
|
||||||
|
|
||||||
WCHAR *m_szMenu;
|
WINWCHAR *m_szMenu;
|
||||||
WCHAR *m_szClass;
|
WINWCHAR *m_szClass;
|
||||||
WCHAR *m_szTitle;
|
WINWCHAR *m_szTitle;
|
||||||
|
|
||||||
// Only if DS_FONT style is set
|
// Only if DS_FONT style is set
|
||||||
short m_sFontSize;
|
short m_sFontSize;
|
||||||
short m_sFontWeight; // Extended only
|
short m_sFontWeight; // Extended only
|
||||||
BYTE m_bItalic; // Extended only
|
BYTE m_bItalic; // Extended only
|
||||||
BYTE m_bCharset; // Extended only
|
BYTE m_bCharset; // Extended only
|
||||||
WCHAR *m_szFont;
|
WINWCHAR *m_szFont;
|
||||||
|
|
||||||
// For (en/de)coding Unicode
|
// For (en/de)coding Unicode
|
||||||
unsigned int m_uCodePage;
|
unsigned int m_uCodePage;
|
||||||
|
|
|
@ -21,6 +21,15 @@
|
||||||
|
|
||||||
// some definitions for non Win32 platforms were taken from MinGW's free Win32 library
|
// some definitions for non Win32 platforms were taken from MinGW's free Win32 library
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && defined(MAKENSIS)
|
||||||
|
template<class T> class NSISCHARTYPE{ T _c; public: NSISCHARTYPE(){} NSISCHARTYPE(T c):_c(c){} operator T()const{ return _c; } };
|
||||||
|
typedef NSISCHARTYPE<unsigned short> WINWCHAR; // WINWCHAR is always UTF16LE and should not be passed to wcs* functions
|
||||||
|
#else
|
||||||
|
typedef unsigned short WINWCHAR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
|
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
|
@ -50,6 +59,14 @@ typedef long LONG;
|
||||||
typedef unsigned long ULONG;
|
typedef unsigned long ULONG;
|
||||||
typedef long long INT64, LARGE_INTEGER;
|
typedef long long INT64, LARGE_INTEGER;
|
||||||
typedef unsigned long long UINT64, ULARGE_INTEGER;
|
typedef unsigned long long UINT64, ULARGE_INTEGER;
|
||||||
|
#include <stdint.h>
|
||||||
|
#ifdef INTPTR_MAX
|
||||||
|
typedef intptr_t INT_PTR;
|
||||||
|
typedef uintptr_t UINT_PTR;
|
||||||
|
#else
|
||||||
|
typedef int INT_PTR;
|
||||||
|
typedef unsigned int UINT_PTR;
|
||||||
|
#endif
|
||||||
typedef int BOOL, *LPBOOL;
|
typedef int BOOL, *LPBOOL;
|
||||||
typedef short VARIANT_BOOL;
|
typedef short VARIANT_BOOL;
|
||||||
typedef void VOID;
|
typedef void VOID;
|
||||||
|
@ -64,8 +81,6 @@ typedef const unsigned short *LPCWCH, *PCWCH, *LPCWSTR, *PCWSTR, *LPCOLESTR;
|
||||||
#else
|
#else
|
||||||
#define _tctime ctime
|
#define _tctime ctime
|
||||||
#endif
|
#endif
|
||||||
typedef int INT_PTR;
|
|
||||||
typedef unsigned int UINT_PTR;
|
|
||||||
// basic stuff
|
// basic stuff
|
||||||
typedef void * HANDLE;
|
typedef void * HANDLE;
|
||||||
typedef HANDLE HWND;
|
typedef HANDLE HWND;
|
||||||
|
@ -221,6 +236,13 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
# ifndef RGB
|
# ifndef RGB
|
||||||
# define RGB(r,g,b) ((DWORD)(((BYTE)(r)|((WORD)(g)<<8))|(((DWORD)(BYTE)(b))<<16)))
|
# define RGB(r,g,b) ((DWORD)(((BYTE)(r)|((WORD)(g)<<8))|(((DWORD)(BYTE)(b))<<16)))
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef LOBYTE
|
||||||
|
# define LOBYTE(w) ((BYTE)(w))
|
||||||
|
# define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF))
|
||||||
|
# endif
|
||||||
|
# ifndef MAKEWORD
|
||||||
|
# define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
|
||||||
|
# endif
|
||||||
# ifndef MAKELONG
|
# ifndef MAKELONG
|
||||||
# define MAKELONG(a,b) ((DWORD)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
|
# define MAKELONG(a,b) ((DWORD)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
|
||||||
# endif
|
# endif
|
||||||
|
@ -237,7 +259,10 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
|
|
||||||
// Anders: MSVC's swprintf is non standard, use _snwprintf when you really mean swprintf
|
// Anders: MSVC's swprintf is non standard, use _snwprintf when you really mean swprintf
|
||||||
#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_snwprintf)
|
#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_snwprintf)
|
||||||
#define _snwprintf swprintf
|
# define _snwprintf swprintf // (wchar_t*,size_t,const wchar_t*,...)
|
||||||
|
#endif
|
||||||
|
#ifndef _WIN32
|
||||||
|
# define _vsnwprintf vswprintf // (wchar_t*,size_t,const wchar_t*,va_list)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Jim Park: These str functions will probably never be encountered with all my
|
// Jim Park: These str functions will probably never be encountered with all my
|
||||||
|
@ -467,6 +492,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
|
|
||||||
#ifndef CP_ACP
|
#ifndef CP_ACP
|
||||||
# define CP_ACP 0
|
# define CP_ACP 0
|
||||||
|
# define CP_OEMCP 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef CP_UTF8
|
#ifndef CP_UTF8
|
||||||
# define CP_UTF8 65001
|
# define CP_UTF8 65001
|
||||||
|
@ -628,6 +654,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
# define SW_SHOWMINIMIZED 2
|
# define SW_SHOWMINIMIZED 2
|
||||||
# define SW_SHOWMAXIMIZED 3
|
# define SW_SHOWMAXIMIZED 3
|
||||||
# define SW_SHOWNOACTIVATE 4
|
# define SW_SHOWNOACTIVATE 4
|
||||||
|
# define SW_SHOW 5
|
||||||
# define SW_SHOWMINNOACTIVE 7
|
# define SW_SHOWMINNOACTIVE 7
|
||||||
# define SW_SHOWNA 8
|
# define SW_SHOWNA 8
|
||||||
# define SW_RESTORE 9
|
# define SW_RESTORE 9
|
||||||
|
@ -972,4 +999,33 @@ typedef struct tagVS_FIXEDFILEINFO {
|
||||||
|
|
||||||
#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications
|
#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications
|
||||||
|
|
||||||
|
/*
|
||||||
|
_tprintf on Windows/MSVCRT treats %s as TCHAR* and on POSIX %s is always char*!
|
||||||
|
Always use our NPRI* (NsisPRInt[Narrow|Wide]*) defines in format strings when calling
|
||||||
|
functions from tchar.h (Similar to the way <inttypes.h> works)
|
||||||
|
|
||||||
|
Example: _tprintf(_T("Hello %") NPRIs _T("\n"), _T("World"));
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define NPRIs _T("s")
|
||||||
|
# define NPRINs _T("hs")
|
||||||
|
# define NPRIWs _T("ls") // ws also works, not sure which is most compatible
|
||||||
|
# ifndef _WIN64
|
||||||
|
# define NPRIp _T(".8x")
|
||||||
|
# define NPRINp ".8x"
|
||||||
|
# endif
|
||||||
|
#else // !_WIN32
|
||||||
|
# define NPRINs _T("s")
|
||||||
|
# define NPRIWs _T("ls")
|
||||||
|
# ifdef _UNICODE
|
||||||
|
# define NPRIs _T("ls")
|
||||||
|
# else // !_UNICODE
|
||||||
|
# define NPRIs _T("s")
|
||||||
|
# endif // ~_UNICODE
|
||||||
|
#endif // ~_WIN32
|
||||||
|
#ifndef NPRIp
|
||||||
|
# define NPRIp _T("p")
|
||||||
|
# define NPRINp "p"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // EOF
|
||||||
|
|
|
@ -82,7 +82,7 @@ static inline tstring GetDllName(const tstring&command)
|
||||||
|
|
||||||
static inline void PrintCommandSig(const tstring sig)
|
static inline void PrintCommandSig(const tstring sig)
|
||||||
{
|
{
|
||||||
_ftprintf(g_output, _T(" + %s\n"), sig.c_str());
|
_ftprintf(g_output, _T(" + %") NPRIs _T("\n"), sig.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugins::AddPluginsDir(const tstring &path, bool displayInfo)
|
void Plugins::AddPluginsDir(const tstring &path, bool displayInfo)
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
#include "winchar.h"
|
#include "winchar.h"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
|
#include "utf.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Utilities
|
// Utilities
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define WCHARPTR2WINWCHARPTR(s) ( (WINWCHAR*) (s) ) // Only for WinSDK structs like IMAGE_RESOURCE_DIR_STRING_U where we cannot change the WCHAR type!
|
||||||
#define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn
|
#define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn
|
||||||
#define RALIGN(dwToAlign, dwAlignOn) ((dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn)
|
#define RALIGN(dwToAlign, dwAlignOn) ((dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn)
|
||||||
|
|
||||||
|
@ -144,10 +146,7 @@ CResourceEditor::CResourceEditor(BYTE* pbPE, int iSize, bool bKeepData /*=true*/
|
||||||
}
|
}
|
||||||
|
|
||||||
CResourceEditor::~CResourceEditor() {
|
CResourceEditor::~CResourceEditor() {
|
||||||
if (m_cResDir) {
|
delete m_cResDir;
|
||||||
m_cResDir->Destroy();
|
|
||||||
delete m_cResDir;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -156,7 +155,7 @@ CResourceEditor::~CResourceEditor() {
|
||||||
|
|
||||||
// Adds/Replaces/Removes a resource.
|
// Adds/Replaces/Removes a resource.
|
||||||
// If lpData is 0 UpdateResource removes the resource.
|
// If lpData is 0 UpdateResource removes the resource.
|
||||||
bool CResourceEditor::UpdateResourceW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
bool CResourceEditor::UpdateResourceW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||||
CResourceDirectory* nameDir = 0;
|
CResourceDirectory* nameDir = 0;
|
||||||
CResourceDirectory* langDir = 0;
|
CResourceDirectory* langDir = 0;
|
||||||
CResourceDataEntry* data = 0;
|
CResourceDataEntry* data = 0;
|
||||||
|
@ -186,17 +185,20 @@ bool CResourceEditor::UpdateResourceW(const WCHAR* szType, WCHAR* szName, LANGID
|
||||||
if (!nameDir) {
|
if (!nameDir) {
|
||||||
// Type doesn't yet exist
|
// Type doesn't yet exist
|
||||||
nameDir = new CResourceDirectory(&rd);
|
nameDir = new CResourceDirectory(&rd);
|
||||||
m_cResDir->AddEntry(new CResourceDirectoryEntry(szType, nameDir));
|
CResourceDirectoryEntry *pRDE = new CResourceDirectoryEntry(szType, nameDir);
|
||||||
|
if (!m_cResDir->AddEntry(pRDE)) delete pRDE;
|
||||||
}
|
}
|
||||||
if (!langDir) {
|
if (!langDir) {
|
||||||
// Name doesn't yet exist
|
// Name doesn't yet exist
|
||||||
langDir = new CResourceDirectory(&rd);
|
langDir = new CResourceDirectory(&rd);
|
||||||
nameDir->AddEntry(new CResourceDirectoryEntry(szName, langDir));
|
CResourceDirectoryEntry *pRDE = new CResourceDirectoryEntry(szName, langDir);
|
||||||
|
if (!nameDir->AddEntry(pRDE)) delete pRDE;
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
// Language doesn't yet exist, hence data nither
|
// Language doesn't yet exist, hence data nither
|
||||||
data = new CResourceDataEntry(lpData, dwSize);
|
data = new CResourceDataEntry(lpData, dwSize);
|
||||||
langDir->AddEntry(new CResourceDirectoryEntry(MAKEINTRESOURCEW(wLanguage), data));
|
CResourceDirectoryEntry *pRDE = new CResourceDirectoryEntry(MAKEINTRESOURCEWINW(wLanguage), data);
|
||||||
|
if (!langDir->AddEntry(pRDE)) delete pRDE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data) {
|
else if (data) {
|
||||||
|
@ -218,25 +220,37 @@ bool CResourceEditor::UpdateResourceW(const WCHAR* szType, WCHAR* szName, LANGID
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _UNICODE
|
#ifndef _UNICODE
|
||||||
static WCHAR* ResStringToUnicode(const char *szString) {
|
static WINWCHAR* ResStringToUnicode(const char *szString) {
|
||||||
if (IS_INTRESOURCE(szString))
|
if (IS_INTRESOURCE(szString)) return MAKEINTRESOURCEWINW((ULONG_PTR)szString);
|
||||||
return MAKEINTRESOURCEW((ULONG_PTR)szString);
|
WINWCHAR *s = WinWStrDupFromTChar(szString, CP_ACP);
|
||||||
else
|
if (!s) throw std::bad_alloc();
|
||||||
return wcsdup_fromTchar(szString, CP_ACP);
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeUnicodeResString(WCHAR* szwString) {
|
static void FreeUnicodeResString(WINWCHAR* szwString) {
|
||||||
if (!IS_INTRESOURCE(szwString))
|
if (!IS_INTRESOURCE(szwString)) free(szwString);
|
||||||
free(szwString);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool CResourceEditor::UpdateResource(const TCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
|
||||||
#ifdef _UNICODE
|
|
||||||
return UpdateResourceW(szType, MAKEINTRESOURCEW(szName), wLanguage, lpData, dwSize);
|
|
||||||
#else
|
#else
|
||||||
WCHAR* szwType = ResStringToUnicode(szType);
|
#ifndef _WIN32
|
||||||
bool result = UpdateResourceW(szwType, MAKEINTRESOURCEW(szName), wLanguage, lpData, dwSize);
|
static WINWCHAR* ResStringToUnicode(const TCHAR *s) {
|
||||||
|
if (IS_INTRESOURCE(s)) return MAKEINTRESOURCEWINW((ULONG_PTR)s);
|
||||||
|
WCToUTF16LEHlpr cnv;
|
||||||
|
if (!cnv.Create(s)) throw std::runtime_error("Unicode conversion failed");
|
||||||
|
return (WINWCHAR*) cnv.Detach();
|
||||||
|
}
|
||||||
|
static void FreeUnicodeResString(WINWCHAR* s) {
|
||||||
|
if (!IS_INTRESOURCE(s)) free(s);
|
||||||
|
}
|
||||||
|
#endif // ~_WIN32
|
||||||
|
#endif // ~_UNICODE
|
||||||
|
|
||||||
|
|
||||||
|
bool CResourceEditor::UpdateResourceT(const TCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||||
|
#if defined(_WIN32) && defined(_UNICODE)
|
||||||
|
return UpdateResourceW((WINWCHAR*)szType, MAKEINTRESOURCEWINW(szName), wLanguage, lpData, dwSize);
|
||||||
|
#else
|
||||||
|
WINWCHAR* szwType = ResStringToUnicode(szType);
|
||||||
|
bool result = UpdateResourceW(szwType, MAKEINTRESOURCEWINW(szName), wLanguage, lpData, dwSize);
|
||||||
FreeUnicodeResString(szwType);
|
FreeUnicodeResString(szwType);
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
@ -244,7 +258,7 @@ bool CResourceEditor::UpdateResource(const TCHAR* szType, WORD szName, LANGID wL
|
||||||
|
|
||||||
// Returns a copy of the requested resource
|
// Returns a copy of the requested resource
|
||||||
// Returns 0 if the requested resource can't be found
|
// Returns 0 if the requested resource can't be found
|
||||||
BYTE* CResourceEditor::GetResourceW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage) {
|
BYTE* CResourceEditor::GetResourceW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage) {
|
||||||
if (!m_bKeepData)
|
if (!m_bKeepData)
|
||||||
throw runtime_error("Can't GetResource() when bKeepData is false");
|
throw runtime_error("Can't GetResource() when bKeepData is false");
|
||||||
|
|
||||||
|
@ -276,12 +290,12 @@ BYTE* CResourceEditor::GetResourceW(const WCHAR* szType, WCHAR* szName, LANGID w
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* CResourceEditor::GetResource(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
BYTE* CResourceEditor::GetResourceT(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
||||||
#ifdef _UNICODE
|
#if defined(_WIN32) && defined(_UNICODE)
|
||||||
return GetResourceW(szType, MAKEINTRESOURCEW(szName), wLanguage);
|
return GetResourceW((WINWCHAR*)szType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
#else
|
#else
|
||||||
WCHAR* szwType = ResStringToUnicode(szType);
|
WINWCHAR* szwType = ResStringToUnicode(szType);
|
||||||
BYTE* result = GetResourceW(szwType, MAKEINTRESOURCEW(szName), wLanguage);
|
BYTE* result = GetResourceW(szwType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
FreeUnicodeResString(szwType);
|
FreeUnicodeResString(szwType);
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,7 +303,7 @@ BYTE* CResourceEditor::GetResource(const TCHAR* szType, WORD szName, LANGID wLan
|
||||||
|
|
||||||
// Returns the size of the requested resource
|
// Returns the size of the requested resource
|
||||||
// Returns -1 if the requested resource can't be found
|
// Returns -1 if the requested resource can't be found
|
||||||
int CResourceEditor::GetResourceSizeW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage) {
|
int CResourceEditor::GetResourceSizeW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage) {
|
||||||
CResourceDirectory* nameDir = 0;
|
CResourceDirectory* nameDir = 0;
|
||||||
CResourceDirectory* langDir = 0;
|
CResourceDirectory* langDir = 0;
|
||||||
CResourceDataEntry* data = 0;
|
CResourceDataEntry* data = 0;
|
||||||
|
@ -315,12 +329,12 @@ int CResourceEditor::GetResourceSizeW(const WCHAR* szType, WCHAR* szName, LANGID
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CResourceEditor::GetResourceSize(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
int CResourceEditor::GetResourceSizeT(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
||||||
#ifdef _UNICODE
|
#if defined(_WIN32) && defined(_UNICODE)
|
||||||
return GetResourceSizeW(szType, MAKEINTRESOURCEW(szName), wLanguage);
|
return GetResourceSizeW((WINWCHAR*)szType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
#else
|
#else
|
||||||
WCHAR* szwType = ResStringToUnicode(szType);
|
WINWCHAR* szwType = ResStringToUnicode(szType);
|
||||||
int result = GetResourceSizeW(szwType, MAKEINTRESOURCEW(szName), wLanguage);
|
int result = GetResourceSizeW(szwType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
FreeUnicodeResString(szwType);
|
FreeUnicodeResString(szwType);
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
@ -328,7 +342,7 @@ int CResourceEditor::GetResourceSize(const TCHAR* szType, WORD szName, LANGID wL
|
||||||
|
|
||||||
// Returns the offset of the requested resource in the original PE
|
// Returns the offset of the requested resource in the original PE
|
||||||
// Returns -1 if the requested resource can't be found
|
// Returns -1 if the requested resource can't be found
|
||||||
DWORD CResourceEditor::GetResourceOffsetW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage) {
|
DWORD CResourceEditor::GetResourceOffsetW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage) {
|
||||||
CResourceDirectory* nameDir = 0;
|
CResourceDirectory* nameDir = 0;
|
||||||
CResourceDirectory* langDir = 0;
|
CResourceDirectory* langDir = 0;
|
||||||
CResourceDataEntry* data = 0;
|
CResourceDataEntry* data = 0;
|
||||||
|
@ -354,12 +368,12 @@ DWORD CResourceEditor::GetResourceOffsetW(const WCHAR* szType, WCHAR* szName, LA
|
||||||
return DWORD(-1);
|
return DWORD(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD CResourceEditor::GetResourceOffset(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
DWORD CResourceEditor::GetResourceOffsetT(const TCHAR* szType, WORD szName, LANGID wLanguage) {
|
||||||
#ifdef _UNICODE
|
#if defined(_WIN32) && defined(_UNICODE)
|
||||||
return GetResourceOffsetW(szType, MAKEINTRESOURCEW(szName), wLanguage);
|
return GetResourceOffsetW((WINWCHAR*)szType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
#else
|
#else
|
||||||
WCHAR* szwType = ResStringToUnicode(szType);
|
WINWCHAR* szwType = ResStringToUnicode(szType);
|
||||||
DWORD result = GetResourceOffsetW(szwType, MAKEINTRESOURCEW(szName), wLanguage);
|
DWORD result = GetResourceOffsetW(szwType, MAKEINTRESOURCEWINW(szName), wLanguage);
|
||||||
FreeUnicodeResString(szwType);
|
FreeUnicodeResString(szwType);
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
@ -557,7 +571,7 @@ bool CResourceEditor::SetPESectionVirtualSize(const char* pszSectionName, DWORD
|
||||||
CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan) {
|
CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan) {
|
||||||
// Create CResourceDirectory from rdToScan
|
// Create CResourceDirectory from rdToScan
|
||||||
CResourceDirectory* rdc = new CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY(rdToScan));
|
CResourceDirectory* rdc = new CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY(rdToScan));
|
||||||
WCHAR* szName;
|
WINWCHAR* szName;
|
||||||
PIMAGE_RESOURCE_DATA_ENTRY rde = NULL;
|
PIMAGE_RESOURCE_DATA_ENTRY rde = NULL;
|
||||||
|
|
||||||
// Go through all entries of this resource directory
|
// Go through all entries of this resource directory
|
||||||
|
@ -578,25 +592,24 @@ CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, P
|
||||||
PIMAGE_RESOURCE_DIR_STRING_U rds = PIMAGE_RESOURCE_DIR_STRING_U(rd.UName.NameString.NameOffset + (char*)rdRoot);
|
PIMAGE_RESOURCE_DIR_STRING_U rds = PIMAGE_RESOURCE_DIR_STRING_U(rd.UName.NameString.NameOffset + (char*)rdRoot);
|
||||||
|
|
||||||
size_t nameSize = ConvertEndianness(rds->Length);
|
size_t nameSize = ConvertEndianness(rds->Length);
|
||||||
szName = new WCHAR[nameSize+1];
|
szName = new WINWCHAR[nameSize+1];
|
||||||
wcsncpy(szName, rds->NameString, nameSize);
|
WinWStrNCpy(szName, WCHARPTR2WINWCHARPTR(rds->NameString), nameSize);
|
||||||
szName[nameSize] = 0;
|
szName[nameSize] = 0;
|
||||||
}
|
}
|
||||||
// Else, set the name to this entry's id
|
// Else, set the name to this entry's id
|
||||||
else
|
else
|
||||||
szName = MAKEINTRESOURCEW(ConvertEndianness(rdToScan->Entries[i].UName.Id));
|
szName = MAKEINTRESOURCEWINW(ConvertEndianness(rdToScan->Entries[i].UName.Id));
|
||||||
|
|
||||||
if (rd.UOffset.DirectoryOffset.DataIsDirectory)
|
if (rd.UOffset.DirectoryOffset.DataIsDirectory)
|
||||||
{
|
{
|
||||||
rdc->AddEntry(
|
CResourceDirectoryEntry *pRDE = new CResourceDirectoryEntry(
|
||||||
new CResourceDirectoryEntry(
|
szName,
|
||||||
szName,
|
ScanDirectory(
|
||||||
ScanDirectory(
|
rdRoot,
|
||||||
rdRoot,
|
PRESOURCE_DIRECTORY(rd.UOffset.DirectoryOffset.OffsetToDirectory + (LPBYTE)rdRoot)
|
||||||
PRESOURCE_DIRECTORY(rd.UOffset.DirectoryOffset.OffsetToDirectory + (LPBYTE)rdRoot)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!rdc->AddEntry(pRDE)) delete pRDE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -614,18 +627,16 @@ CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, P
|
||||||
{
|
{
|
||||||
pbData = m_pbPE; // dummy pointer to "nothing"
|
pbData = m_pbPE; // dummy pointer to "nothing"
|
||||||
}
|
}
|
||||||
|
CResourceDirectoryEntry *pRDE = new CResourceDirectoryEntry(
|
||||||
rdc->AddEntry(
|
szName,
|
||||||
new CResourceDirectoryEntry(
|
new CResourceDataEntry(
|
||||||
szName,
|
pbData,
|
||||||
new CResourceDataEntry(
|
ConvertEndianness(rde->Size),
|
||||||
pbData,
|
ConvertEndianness(rde->CodePage),
|
||||||
ConvertEndianness(rde->Size),
|
dwOffset
|
||||||
ConvertEndianness(rde->CodePage),
|
|
||||||
dwOffset
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!rdc->AddEntry(pRDE)) delete pRDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the dynamicly allocated name if it is a name and not an id
|
// Delete the dynamicly allocated name if it is a name and not an id
|
||||||
|
@ -707,15 +718,15 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
||||||
|
|
||||||
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_ulWrittenAt)->UName.NameString.NameOffset = ConvertEndianness((DWORD) (seeker - pbRsrcSec));
|
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_ulWrittenAt)->UName.NameString.NameOffset = ConvertEndianness((DWORD) (seeker - pbRsrcSec));
|
||||||
|
|
||||||
WCHAR* szName = cRDirE->GetName();
|
WINWCHAR* szName = cRDirE->GetName();
|
||||||
WORD iLen = wcslen(szName) + 1;
|
WORD iLen = WinWStrLen(szName) + 1;
|
||||||
|
|
||||||
*(WORD*)seeker = ConvertEndianness(iLen);
|
*(WORD*)seeker = ConvertEndianness(iLen);
|
||||||
CopyMemory(seeker + sizeof(WORD), szName, iLen*sizeof(WCHAR));
|
CopyMemory(seeker + sizeof(WORD), szName, iLen*sizeof(WINWCHAR));
|
||||||
|
|
||||||
seeker += RALIGN(iLen * sizeof(WCHAR) + sizeof(WORD), 4);
|
seeker += RALIGN(iLen * sizeof(WINWCHAR) + sizeof(WORD), 4);
|
||||||
|
|
||||||
delete [] szName;
|
free(szName);
|
||||||
|
|
||||||
qStrings.pop();
|
qStrings.pop();
|
||||||
}
|
}
|
||||||
|
@ -793,6 +804,7 @@ CResourceDirectory::CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY prd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CResourceDirectory::~CResourceDirectory() {
|
CResourceDirectory::~CResourceDirectory() {
|
||||||
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -811,34 +823,33 @@ CResourceDirectoryEntry* CResourceDirectory::GetEntry(unsigned int i) {
|
||||||
|
|
||||||
// This function inserts a new directory entry
|
// This function inserts a new directory entry
|
||||||
// It also keeps the directory entries sorted
|
// It also keeps the directory entries sorted
|
||||||
void CResourceDirectory::AddEntry(CResourceDirectoryEntry* entry) {
|
bool CResourceDirectory::AddEntry(CResourceDirectoryEntry* entry) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (entry->HasName()) {
|
if (entry->HasName()) {
|
||||||
WCHAR* szEntName = entry->GetName();
|
WINWCHAR* szEntName = entry->GetName();
|
||||||
for (i = 0; i < m_rdDir.NumberOfNamedEntries; i++) {
|
for (i = 0; i < m_rdDir.NumberOfNamedEntries; i++) {
|
||||||
WCHAR* szName = m_vEntries[i]->GetName();
|
WINWCHAR* szName = m_vEntries[i]->GetName();
|
||||||
int cmp = wcscmp(szName, szEntName);
|
int cmp = WinWStrCmp(szName, szEntName);
|
||||||
delete [] szName;
|
free(szName);
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
delete [] szEntName;
|
free(szEntName);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete [] szEntName;
|
free(szEntName);
|
||||||
m_rdDir.NumberOfNamedEntries++;
|
m_rdDir.NumberOfNamedEntries++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = m_rdDir.NumberOfNamedEntries; i < m_rdDir.NumberOfNamedEntries+m_rdDir.NumberOfIdEntries; i++) {
|
for (i = m_rdDir.NumberOfNamedEntries; i < m_rdDir.NumberOfNamedEntries+m_rdDir.NumberOfIdEntries; i++) {
|
||||||
if (m_vEntries[i]->GetId() == entry->GetId())
|
if (m_vEntries[i]->GetId() == entry->GetId()) return false;
|
||||||
return;
|
if (m_vEntries[i]->GetId() > entry->GetId()) break;
|
||||||
if (m_vEntries[i]->GetId() > entry->GetId())
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
m_rdDir.NumberOfIdEntries++;
|
m_rdDir.NumberOfIdEntries++;
|
||||||
}
|
}
|
||||||
m_vEntries.insert(m_vEntries.begin() + i, entry);
|
m_vEntries.insert(m_vEntries.begin() + i, entry);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceDirectory::RemoveEntry(int i) {
|
void CResourceDirectory::RemoveEntry(int i) {
|
||||||
|
@ -857,25 +868,24 @@ int CResourceDirectory::CountEntries() {
|
||||||
// Returns the index of a directory entry with the specified name
|
// Returns the index of a directory entry with the specified name
|
||||||
// Name can be a string or an id
|
// Name can be a string or an id
|
||||||
// Returns -1 if can not be found
|
// Returns -1 if can not be found
|
||||||
int CResourceDirectory::Find(const WCHAR* szName) {
|
int CResourceDirectory::Find(const WINWCHAR* szName) {
|
||||||
if (IS_INTRESOURCE(szName))
|
if (IS_INTRESOURCE(szName))
|
||||||
return Find((WORD) (ULONG_PTR) szName);
|
return Find((WORD) (ULONG_PTR) szName);
|
||||||
else
|
else
|
||||||
if (szName[0] == L'#')
|
if (szName[0] == L'#')
|
||||||
return Find(WORD(_wtoi(szName + 1)));
|
return Find(WORD(WinWStrToInt(szName + 1)));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
||||||
if (!m_vEntries[i]->HasName())
|
if (!m_vEntries[i]->HasName())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
WCHAR* szEntName = m_vEntries[i]->GetName();
|
WINWCHAR* szEntName = m_vEntries[i]->GetName();
|
||||||
int cmp = wcscmp(szName, szEntName);
|
int cmp = WinWStrCmp(szName, szEntName);
|
||||||
delete [] szEntName;
|
free(szEntName);
|
||||||
|
|
||||||
if (!cmp)
|
if (!cmp)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,13 +893,9 @@ int CResourceDirectory::Find(const WCHAR* szName) {
|
||||||
// Returns -1 if can not be found
|
// Returns -1 if can not be found
|
||||||
int CResourceDirectory::Find(WORD wId) {
|
int CResourceDirectory::Find(WORD wId) {
|
||||||
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
||||||
if (m_vEntries[i]->HasName())
|
if (m_vEntries[i]->HasName()) continue;
|
||||||
continue;
|
if (wId == m_vEntries[i]->GetId()) return i;
|
||||||
|
|
||||||
if (wId == m_vEntries[i]->GetId())
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,7 +905,7 @@ DWORD CResourceDirectory::GetSize() {
|
||||||
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
||||||
dwSize += sizeof(MY_IMAGE_RESOURCE_DIRECTORY_ENTRY);
|
dwSize += sizeof(MY_IMAGE_RESOURCE_DIRECTORY_ENTRY);
|
||||||
if (m_vEntries[i]->HasName())
|
if (m_vEntries[i]->HasName())
|
||||||
dwSize += sizeof(IMAGE_RESOURCE_DIR_STRING_U) + (m_vEntries[i]->GetNameLength()+1)*sizeof(WCHAR);
|
dwSize += sizeof(IMAGE_RESOURCE_DIR_STRING_U) + (m_vEntries[i]->GetNameLength()+1)*sizeof(WINWCHAR);
|
||||||
if (m_vEntries[i]->IsDataDirectory())
|
if (m_vEntries[i]->IsDataDirectory())
|
||||||
dwSize += m_vEntries[i]->GetSubDirectory()->GetSize();
|
dwSize += m_vEntries[i]->GetSubDirectory()->GetSize();
|
||||||
else {
|
else {
|
||||||
|
@ -920,7 +926,9 @@ void CResourceDirectory::Destroy() {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
delete m_vEntries[i]->GetDataEntry();
|
delete m_vEntries[i]->GetDataEntry();
|
||||||
|
delete m_vEntries[i];
|
||||||
}
|
}
|
||||||
|
m_vEntries.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -933,7 +941,7 @@ void CResourceDirectory::Destroy() {
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CResourceDirectoryEntry::CResourceDirectoryEntry(const WCHAR* szName, CResourceDirectory* rdSubDir) {
|
CResourceDirectoryEntry::CResourceDirectoryEntry(const WINWCHAR* szName, CResourceDirectory* rdSubDir) {
|
||||||
if (IS_INTRESOURCE(szName)) {
|
if (IS_INTRESOURCE(szName)) {
|
||||||
m_bHasName = false;
|
m_bHasName = false;
|
||||||
m_szName = 0;
|
m_szName = 0;
|
||||||
|
@ -941,13 +949,13 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(const WCHAR* szName, CResourceD
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_bHasName = true;
|
m_bHasName = true;
|
||||||
m_szName = _wcsdup(szName);
|
m_szName = WinWStrDupFromWinWStr(szName);
|
||||||
}
|
}
|
||||||
m_bIsDataDirectory = true;
|
m_bIsDataDirectory = true;
|
||||||
m_rdSubDir = rdSubDir;
|
m_rdSubDir = rdSubDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
CResourceDirectoryEntry::CResourceDirectoryEntry(const WCHAR* szName, CResourceDataEntry* rdeData) {
|
CResourceDirectoryEntry::CResourceDirectoryEntry(const WINWCHAR* szName, CResourceDataEntry* rdeData) {
|
||||||
if (IS_INTRESOURCE(szName)) {
|
if (IS_INTRESOURCE(szName)) {
|
||||||
m_bHasName = false;
|
m_bHasName = false;
|
||||||
m_szName = 0;
|
m_szName = 0;
|
||||||
|
@ -955,7 +963,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(const WCHAR* szName, CResourceD
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_bHasName = true;
|
m_bHasName = true;
|
||||||
m_szName = _wcsdup(szName);
|
m_szName = WinWStrDupFromWinWStr(szName);
|
||||||
}
|
}
|
||||||
m_bIsDataDirectory = false;
|
m_bIsDataDirectory = false;
|
||||||
m_rdeData = rdeData;
|
m_rdeData = rdeData;
|
||||||
|
@ -963,7 +971,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(const WCHAR* szName, CResourceD
|
||||||
|
|
||||||
CResourceDirectoryEntry::~CResourceDirectoryEntry() {
|
CResourceDirectoryEntry::~CResourceDirectoryEntry() {
|
||||||
if (m_szName && m_bHasName)
|
if (m_szName && m_bHasName)
|
||||||
delete [] m_szName;
|
free(m_szName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -975,20 +983,16 @@ bool CResourceDirectoryEntry::HasName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't forget to free the memory used by the string after usage!
|
// Don't forget to free the memory used by the string after usage!
|
||||||
WCHAR* CResourceDirectoryEntry::GetName() {
|
WINWCHAR* CResourceDirectoryEntry::GetName() {
|
||||||
if (!m_bHasName)
|
return m_bHasName ? WinWStrDupFromWinWStr(m_szName) : 0;
|
||||||
return 0;
|
|
||||||
return _wcsdup(m_szName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CResourceDirectoryEntry::GetNameLength() {
|
int CResourceDirectoryEntry::GetNameLength() {
|
||||||
return wcslen(m_szName);
|
return WinWStrLen(m_szName);
|
||||||
}
|
}
|
||||||
|
|
||||||
WORD CResourceDirectoryEntry::GetId() {
|
WORD CResourceDirectoryEntry::GetId() {
|
||||||
if (m_bHasName)
|
return m_bHasName ? 0 : m_wId;
|
||||||
return 0;
|
|
||||||
return m_wId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CResourceDirectoryEntry::IsDataDirectory() {
|
bool CResourceDirectoryEntry::IsDataDirectory() {
|
||||||
|
|
|
@ -24,10 +24,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include "winchar.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#else
|
#else
|
||||||
|
@ -114,10 +115,50 @@ public:
|
||||||
CResourceEditor(BYTE* pbPE, int iSize, bool bKeepData = true);
|
CResourceEditor(BYTE* pbPE, int iSize, bool bKeepData = true);
|
||||||
virtual ~CResourceEditor();
|
virtual ~CResourceEditor();
|
||||||
|
|
||||||
bool UpdateResource (const TCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
// On POSIX+Unicode GetResource(RT_VERSION,..) is not TCHAR nor WINWCHAR, it is WCHAR/UINT16.
|
||||||
BYTE* GetResource (const TCHAR* szType, WORD szName, LANGID wLanguage);
|
// If it passes IS_INTRESOURCE we must allow it.
|
||||||
int GetResourceSize (const TCHAR* szType, WORD szName, LANGID wLanguage);
|
// Use TCHAR* for real strings. If you need to pass in a WINWCHAR*, make GetResourceW public...
|
||||||
DWORD GetResourceOffset(const TCHAR* szType, WORD szName, LANGID wLanguage);
|
template<class T> bool UpdateResource(const T*Type, WORD Name, LANGID Lang, BYTE*Data, DWORD Size)
|
||||||
|
{
|
||||||
|
if (sizeof(T) != sizeof(TCHAR) && !IS_INTRESOURCE(Type))
|
||||||
|
{
|
||||||
|
assert(IS_INTRESOURCE(Type));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return UpdateResourceT((const TCHAR*) Type, Name, Lang, Data, Size);
|
||||||
|
}
|
||||||
|
template<class T> BYTE* GetResource(const T*Type, WORD Name, LANGID Lang)
|
||||||
|
{
|
||||||
|
if (sizeof(T) != sizeof(TCHAR) && !IS_INTRESOURCE(Type))
|
||||||
|
{
|
||||||
|
assert(IS_INTRESOURCE(Type));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return GetResourceT((const TCHAR*) Type, Name, Lang);
|
||||||
|
}
|
||||||
|
template<class T> int GetResourceSize(const T*Type, WORD Name, LANGID Lang)
|
||||||
|
{
|
||||||
|
if (sizeof(T) != sizeof(TCHAR) && !IS_INTRESOURCE(Type))
|
||||||
|
{
|
||||||
|
assert(IS_INTRESOURCE(Type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return GetResourceSizeT((const TCHAR*) Type, Name, Lang);
|
||||||
|
}
|
||||||
|
template<class T> DWORD GetResourceOffset(const T*Type, WORD Name, LANGID Lang)
|
||||||
|
{
|
||||||
|
if (sizeof(T) != sizeof(TCHAR) && !IS_INTRESOURCE(Type))
|
||||||
|
{
|
||||||
|
assert(IS_INTRESOURCE(Type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return GetResourceOffsetT((const TCHAR*) Type, Name, Lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateResourceT (const TCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
|
BYTE* GetResourceT (const TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
|
int GetResourceSizeT (const TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
|
DWORD GetResourceOffsetT(const TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
void FreeResource(BYTE* pbResource);
|
void FreeResource(BYTE* pbResource);
|
||||||
|
|
||||||
// The section name must be in ASCII.
|
// The section name must be in ASCII.
|
||||||
|
@ -135,10 +176,10 @@ public:
|
||||||
DWORD *pdwSectionIndex = NULL
|
DWORD *pdwSectionIndex = NULL
|
||||||
);
|
);
|
||||||
private:
|
private:
|
||||||
bool UpdateResourceW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResourceW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
BYTE* GetResourceW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
BYTE* GetResourceW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage);
|
||||||
int GetResourceSizeW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
int GetResourceSizeW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage);
|
||||||
DWORD GetResourceOffsetW(const WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
DWORD GetResourceOffsetW(const WINWCHAR* szType, WINWCHAR* szName, LANGID wLanguage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BYTE* m_pbPE;
|
BYTE* m_pbPE;
|
||||||
|
@ -169,10 +210,10 @@ public:
|
||||||
IMAGE_RESOURCE_DIRECTORY GetInfo();
|
IMAGE_RESOURCE_DIRECTORY GetInfo();
|
||||||
|
|
||||||
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
||||||
void AddEntry(CResourceDirectoryEntry* entry);
|
bool AddEntry(CResourceDirectoryEntry* entry);
|
||||||
void RemoveEntry(int i);
|
void RemoveEntry(int i);
|
||||||
int CountEntries();
|
int CountEntries();
|
||||||
int Find(const WCHAR* szName);
|
int Find(const WINWCHAR* szName);
|
||||||
int Find(WORD wId);
|
int Find(WORD wId);
|
||||||
|
|
||||||
DWORD GetSize();
|
DWORD GetSize();
|
||||||
|
@ -188,12 +229,12 @@ private:
|
||||||
|
|
||||||
class CResourceDirectoryEntry {
|
class CResourceDirectoryEntry {
|
||||||
public:
|
public:
|
||||||
CResourceDirectoryEntry(const WCHAR* szName, CResourceDirectory* rdSubDir);
|
CResourceDirectoryEntry(const WINWCHAR* szName, CResourceDirectory* rdSubDir);
|
||||||
CResourceDirectoryEntry(const WCHAR* szName, CResourceDataEntry* rdeData);
|
CResourceDirectoryEntry(const WINWCHAR* szName, CResourceDataEntry* rdeData);
|
||||||
virtual ~CResourceDirectoryEntry();
|
virtual ~CResourceDirectoryEntry();
|
||||||
|
|
||||||
bool HasName();
|
bool HasName();
|
||||||
WCHAR* GetName();
|
WINWCHAR* GetName();
|
||||||
int GetNameLength();
|
int GetNameLength();
|
||||||
|
|
||||||
WORD GetId();
|
WORD GetId();
|
||||||
|
@ -207,7 +248,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bHasName;
|
bool m_bHasName;
|
||||||
WCHAR* m_szName;
|
WINWCHAR* m_szName;
|
||||||
WORD m_wId;
|
WORD m_wId;
|
||||||
|
|
||||||
bool m_bIsDataDirectory;
|
bool m_bIsDataDirectory;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "winchar.h"
|
#include "winchar.h"
|
||||||
|
#include "utf.h"
|
||||||
|
|
||||||
#ifdef NSIS_SUPPORT_VERSION_INFO
|
#ifdef NSIS_SUPPORT_VERSION_INFO
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ void CResourceVersionInfo::SetProductVersion(int HighPart, int LowPart)
|
||||||
// Jim Park: Not sure where this is used.
|
// Jim Park: Not sure where this is used.
|
||||||
int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
|
int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
|
||||||
{
|
{
|
||||||
WCHAR *szKey;
|
WINWCHAR *szKey;
|
||||||
char * baseP;
|
char * baseP;
|
||||||
|
|
||||||
baseP = p;
|
baseP = p;
|
||||||
|
@ -139,11 +140,11 @@ int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
|
||||||
p += sizeof(WORD);
|
p += sizeof(WORD);
|
||||||
wType = *(WORD*)p;
|
wType = *(WORD*)p;
|
||||||
p += sizeof(WORD);
|
p += sizeof(WORD);
|
||||||
szKey = (WCHAR*)p;
|
szKey = (WINWCHAR*)p;
|
||||||
p += (wcslen(szKey) + 1) * sizeof (WCHAR);
|
p += (WinWStrLen(szKey) + 1) * sizeof (WINWCHAR);
|
||||||
while ( ((ULONG_PTR)p % 4) != 0 )
|
while ( ((ULONG_PTR)p % 4) != 0 )
|
||||||
p++;
|
p++;
|
||||||
return p - baseP;
|
return p - baseP;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZEROS = 0;
|
DWORD ZEROS = 0;
|
||||||
|
@ -162,16 +163,16 @@ void PadStream (GrowBuf &strm)
|
||||||
// @param wType If type is 1, it's a wchar_t string, so save value length appropriately.
|
// @param wType If type is 1, it's a wchar_t string, so save value length appropriately.
|
||||||
// @param key The string key
|
// @param key The string key
|
||||||
// @param value The value mapped to string key.
|
// @param value The value mapped to string key.
|
||||||
void SaveVersionHeader (GrowBuf &strm, WORD wLength, WORD wValueLength, WORD wType, const WCHAR *key, void *value)
|
static void SaveVersionHeaderUTF16LE(GrowBuf &strm, WORD wLength, WORD wValueLength, WORD wType, const unsigned short *key, void *value)
|
||||||
{
|
{
|
||||||
WORD valueLen;
|
WORD valueLen;
|
||||||
WORD keyLen;
|
WORD keyLen;
|
||||||
|
|
||||||
strm.add (&wLength, sizeof (wLength));
|
strm.add (&wLength, sizeof(wLength));
|
||||||
|
|
||||||
strm.add (&wValueLength, sizeof (wValueLength));
|
strm.add (&wValueLength, sizeof(wValueLength));
|
||||||
strm.add (&wType, sizeof (wType));
|
strm.add (&wType, sizeof (wType));
|
||||||
keyLen = WORD((wcslen(key) + 1) * sizeof (WCHAR));
|
keyLen = WORD((StrLenUTF16(key) + 1) * sizeof(WINWCHAR));
|
||||||
strm.add ((void*)key, keyLen);
|
strm.add ((void*)key, keyLen);
|
||||||
|
|
||||||
PadStream(strm);
|
PadStream(strm);
|
||||||
|
@ -180,20 +181,26 @@ void SaveVersionHeader (GrowBuf &strm, WORD wLength, WORD wValueLength, WORD wTy
|
||||||
{
|
{
|
||||||
valueLen = wValueLength;
|
valueLen = wValueLength;
|
||||||
if ( wType == 1 )
|
if ( wType == 1 )
|
||||||
valueLen = valueLen * WORD(sizeof (WCHAR));
|
valueLen = valueLen * WORD(sizeof(WINWCHAR));
|
||||||
strm.add (value, valueLen);
|
strm.add (value, valueLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void SaveVersionHeader(GrowBuf &strm, WORD wLength, WORD wValueLength, WORD wType, const wchar_t *key, void *value)
|
||||||
|
{
|
||||||
|
WCToUTF16LEHlpr cnv;
|
||||||
|
if (!cnv.Create(key)) throw std::runtime_error("Unicode conversion failed");
|
||||||
|
SaveVersionHeaderUTF16LE(strm, wLength, wValueLength, wType, cnv.Get(), value);
|
||||||
|
cnv.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
||||||
{
|
{
|
||||||
DWORD v;
|
DWORD v;
|
||||||
WORD wSize;
|
WORD wSize;
|
||||||
int p, p1;
|
int p, p1;
|
||||||
WCHAR *KeyName, *KeyValue;
|
|
||||||
|
|
||||||
strm.resize(0);
|
strm.resize(0);
|
||||||
SaveVersionHeader (strm, 0, sizeof (VS_FIXEDFILEINFO), 0, L"VS_VERSION_INFO", &m_FixedInfo);
|
SaveVersionHeader(strm, 0, sizeof (VS_FIXEDFILEINFO), 0, L"VS_VERSION_INFO", &m_FixedInfo);
|
||||||
|
|
||||||
DefineList *pChildStrings = m_ChildStringLists.get_strings(Index);
|
DefineList *pChildStrings = m_ChildStringLists.get_strings(Index);
|
||||||
if ( pChildStrings->getnum() > 0 )
|
if ( pChildStrings->getnum() > 0 )
|
||||||
|
@ -201,20 +208,19 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
||||||
GrowBuf stringInfoStream;
|
GrowBuf stringInfoStream;
|
||||||
int codepage = m_ChildStringLists.get_codepage(Index);
|
int codepage = m_ChildStringLists.get_codepage(Index);
|
||||||
LANGID langid = m_ChildStringLists.get_lang(Index);
|
LANGID langid = m_ChildStringLists.get_lang(Index);
|
||||||
WCHAR Buff[16];
|
wchar_t Buff[16];
|
||||||
_snwprintf(Buff, COUNTOF(Buff), L"%04x%04x", langid, codepage);
|
_snwprintf(Buff, COUNTOF(Buff), L"%04x%04x", langid, codepage);
|
||||||
SaveVersionHeader (stringInfoStream, 0, 0, 0, Buff, &ZEROS);
|
SaveVersionHeader(stringInfoStream, 0, 0, 0, Buff, &ZEROS);
|
||||||
|
|
||||||
for ( int i = 0; i < pChildStrings->getnum(); i++ )
|
for ( int i = 0; i < pChildStrings->getnum(); i++ )
|
||||||
{
|
{
|
||||||
PadStream (stringInfoStream);
|
PadStream (stringInfoStream);
|
||||||
|
WCToUTF16LEHlpr cnvName, cnvValue;
|
||||||
|
if (!cnvName.Create(pChildStrings->getname(i), codepage)) throw std::runtime_error("Unicode conversion failed");
|
||||||
|
if (!cnvValue.Create(pChildStrings->getvalue(i), codepage)) throw std::runtime_error("Unicode conversion failed");
|
||||||
p = stringInfoStream.getlen();
|
p = stringInfoStream.getlen();
|
||||||
KeyName = wcsdup_fromTchar(pChildStrings->getname(i), codepage);
|
SaveVersionHeaderUTF16LE(stringInfoStream, 0, WORD(StrLenUTF16(cnvValue.Get()) + 1), 1, cnvName.Get(), (void*)cnvValue.Get());
|
||||||
KeyValue = wcsdup_fromTchar(pChildStrings->getvalue(i), codepage);
|
cnvName.Destroy(), cnvValue.Destroy();
|
||||||
SaveVersionHeader (stringInfoStream, 0, WORD(wcslen(KeyValue) + 1), 1, KeyName, (void*)KeyValue);
|
|
||||||
free(KeyName);
|
|
||||||
free(KeyValue);
|
|
||||||
wSize = WORD(stringInfoStream.getlen() - p);
|
wSize = WORD(stringInfoStream.getlen() - p);
|
||||||
|
|
||||||
*(WORD*)((PBYTE)stringInfoStream.get()+p)=wSize;
|
*(WORD*)((PBYTE)stringInfoStream.get()+p)=wSize;
|
||||||
|
@ -225,7 +231,7 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
||||||
|
|
||||||
PadStream (strm);
|
PadStream (strm);
|
||||||
p = strm.getlen();
|
p = strm.getlen();
|
||||||
SaveVersionHeader (strm, 0, 0, 0, L"StringFileInfo", &ZEROS);
|
SaveVersionHeader(strm, 0, 0, 0, L"StringFileInfo", &ZEROS);
|
||||||
strm.add (stringInfoStream.get(), stringInfoStream.getlen());
|
strm.add (stringInfoStream.get(), stringInfoStream.getlen());
|
||||||
wSize = WORD(strm.getlen() - p);
|
wSize = WORD(strm.getlen() - p);
|
||||||
|
|
||||||
|
@ -237,11 +243,11 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
||||||
{
|
{
|
||||||
PadStream (strm);
|
PadStream (strm);
|
||||||
p = strm.getlen();
|
p = strm.getlen();
|
||||||
SaveVersionHeader (strm, 0, 0, 0, L"VarFileInfo", &ZEROS);
|
SaveVersionHeader(strm, 0, 0, 0, L"VarFileInfo", &ZEROS);
|
||||||
PadStream (strm);
|
PadStream (strm);
|
||||||
|
|
||||||
p1 = strm.getlen();
|
p1 = strm.getlen();
|
||||||
SaveVersionHeader (strm, 0, 0, 0, L"Translation", &ZEROS);
|
SaveVersionHeader(strm, 0, 0, 0, L"Translation", &ZEROS);
|
||||||
|
|
||||||
// First add selected code language translation
|
// First add selected code language translation
|
||||||
v = MAKELONG(m_ChildStringLists.get_lang(Index), m_ChildStringLists.get_codepage(Index));
|
v = MAKELONG(m_ChildStringLists.get_lang(Index), m_ChildStringLists.get_codepage(Index));
|
||||||
|
|
188
Source/build.cpp
188
Source/build.cpp
|
@ -391,7 +391,7 @@ void CEXEBuild::initialize(const TCHAR *makensis_path)
|
||||||
#ifndef NSIS_CONFIG_CONST_DATA_PATH
|
#ifndef NSIS_CONFIG_CONST_DATA_PATH
|
||||||
nsis_dir = get_dir_name(get_executable_dir(makensis_path));
|
nsis_dir = get_dir_name(get_executable_dir(makensis_path));
|
||||||
#else
|
#else
|
||||||
nsis_dir = PREFIX_DATA;
|
nsis_dir = PosixBug_CtoTString(PREFIX_DATA);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
definedlist.add(_T("NSISDIR"), nsis_dir.c_str());
|
definedlist.add(_T("NSISDIR"), nsis_dir.c_str());
|
||||||
|
@ -419,9 +419,10 @@ int CEXEBuild::getcurdbsize() { return cur_datablock->getlen(); }
|
||||||
void CEXEBuild::init_shellconstantvalues()
|
void CEXEBuild::init_shellconstantvalues()
|
||||||
{
|
{
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
if (done) return ;
|
if (done) return ; else done = true;
|
||||||
done = true;
|
|
||||||
|
|
||||||
|
const int orgunmode = uninstall_mode;
|
||||||
|
set_uninstall_mode(0);
|
||||||
// Note: The order matters because some of the strings are preprocessed and cf must be <= 0x40
|
// Note: The order matters because some of the strings are preprocessed and cf must be <= 0x40
|
||||||
unsigned int pf = add_asciistring(_T("ProgramFilesDir"), 0);
|
unsigned int pf = add_asciistring(_T("ProgramFilesDir"), 0);
|
||||||
unsigned int cf = add_asciistring(_T("CommonFilesDir"), 0);
|
unsigned int cf = add_asciistring(_T("CommonFilesDir"), 0);
|
||||||
|
@ -445,7 +446,6 @@ void CEXEBuild::init_shellconstantvalues()
|
||||||
throw out_of_range("Internal compiler error: too many strings added to strings block before adding shell constants!");
|
throw out_of_range("Internal compiler error: too many strings added to strings block before adding shell constants!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const int orgunmode = uninstall_mode;
|
|
||||||
set_uninstall_mode(1);
|
set_uninstall_mode(1);
|
||||||
unsigned int unpf = add_asciistring(_T("ProgramFilesDir"), 0);
|
unsigned int unpf = add_asciistring(_T("ProgramFilesDir"), 0);
|
||||||
unsigned int uncf = add_asciistring(_T("CommonFilesDir"), 0);
|
unsigned int uncf = add_asciistring(_T("CommonFilesDir"), 0);
|
||||||
|
@ -473,7 +473,7 @@ int CEXEBuild::add_string(const TCHAR *string, int process/*=1*/, UINT codepage/
|
||||||
if (!string || !*string) return 0;
|
if (!string || !*string) return 0;
|
||||||
build_lockedunicodetarget = true;
|
build_lockedunicodetarget = true;
|
||||||
init_shellconstantvalues();
|
init_shellconstantvalues();
|
||||||
if ((unsigned)-2 == codepage)
|
if ((UINT)-2 == codepage)
|
||||||
{
|
{
|
||||||
codepage = curlinereader ? curlinereader->StreamEncoding().GetCodepage() : CP_UTF8;
|
codepage = curlinereader ? curlinereader->StreamEncoding().GetCodepage() : CP_UTF8;
|
||||||
// If the current source file is Unicode we have to pick a real codepage for ANSI!
|
// If the current source file is Unicode we have to pick a real codepage for ANSI!
|
||||||
|
@ -500,7 +500,7 @@ int CEXEBuild::add_string(const TCHAR *string, int process/*=1*/, UINT codepage/
|
||||||
ExpandoString<TCHAR, NSIS_MAX_STRLEN*4> buf;
|
ExpandoString<TCHAR, NSIS_MAX_STRLEN*4> buf;
|
||||||
// NOTE: It is impossible to know how much preprocessing will increase the size, we have to guess
|
// NOTE: It is impossible to know how much preprocessing will increase the size, we have to guess
|
||||||
buf.Reserve(_tcsclen(string) * 2);
|
buf.Reserve(_tcsclen(string) * 2);
|
||||||
preprocess_string(buf, string, codepage);
|
preprocess_string(buf, string, codepage); // BUGBUG: This could overflow buf
|
||||||
i = cur_strlist->add(buf, (WORD)codepage, true);
|
i = cur_strlist->add(buf, (WORD)codepage, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -624,8 +624,8 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
|
||||||
//m_UserVarNames.inc_reference(idxUserVar);
|
//m_UserVarNames.inc_reference(idxUserVar);
|
||||||
*out++ = (TCHAR) NS_VAR_CODE; // Named user variable;
|
*out++ = (TCHAR) NS_VAR_CODE; // Named user variable;
|
||||||
WORD w = FIX_ENDIAN_INT16(CODE_SHORT(idxUserVar));
|
WORD w = FIX_ENDIAN_INT16(CODE_SHORT(idxUserVar));
|
||||||
memcpy(out, &w, sizeof(WORD));
|
unsigned int w4 = sizeof(TCHAR) > 2 ? FIX_ENDIAN_INT32(CODE_SHORT(idxUserVar)) : w; // Maybe this is too much endian fixing?
|
||||||
out += sizeof(WORD)/sizeof(TCHAR);
|
if (sizeof(TCHAR) < 2) *((WORD*)out) = w, out += 2; else *out = (TCHAR) w4, out++;
|
||||||
p += pUserVarName-p; // zip past the user var string.
|
p += pUserVarName-p; // zip past the user var string.
|
||||||
bProceced = true;
|
bProceced = true;
|
||||||
break;
|
break;
|
||||||
|
@ -680,8 +680,8 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
|
||||||
{
|
{
|
||||||
*out++ = (TCHAR)NS_LANG_CODE; // Next word is lang-string Identifier
|
*out++ = (TCHAR)NS_LANG_CODE; // Next word is lang-string Identifier
|
||||||
WORD w = FIX_ENDIAN_INT16(CODE_SHORT(-idx-1));
|
WORD w = FIX_ENDIAN_INT16(CODE_SHORT(-idx-1));
|
||||||
memcpy(out, &w, sizeof(WORD));
|
unsigned int w4 = sizeof(TCHAR) > 2 ? FIX_ENDIAN_INT32(CODE_SHORT(-idx-1)) : w; // Maybe this is too much endian fixing?
|
||||||
out += sizeof(WORD)/sizeof(TCHAR);
|
if (sizeof(TCHAR) < 2) *((WORD*)out) = w, out += 2; else *out = (TCHAR) w4, out++;
|
||||||
p += _tcslen(cp) + 2;
|
p += _tcslen(cp) + 2;
|
||||||
bProceced = true;
|
bProceced = true;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
|
||||||
if (_tcsstr(tbuf,_T(" "))) _tcsstr(tbuf,_T(" "))[0]=0;
|
if (_tcsstr(tbuf,_T(" "))) _tcsstr(tbuf,_T(" "))[0]=0;
|
||||||
}
|
}
|
||||||
if ( bDoWarning )
|
if ( bDoWarning )
|
||||||
warning_fl(_T("unknown variable/constant \"%s\" detected, ignoring"),tbuf);
|
warning_fl(_T("unknown variable/constant \"%") NPRIs _T("\" detected, ignoring"),tbuf);
|
||||||
i = _T('$'); // redundant since i is already '$' and has
|
i = _T('$'); // redundant since i is already '$' and has
|
||||||
// not changed.
|
// not changed.
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ int CEXEBuild::add_db_data(IMMap *mmap) // returns offset
|
||||||
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
||||||
if (n != C_OK)
|
if (n != C_OK)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%s [%d]).\n"), compressor->GetErrStr(n), n);
|
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%") NPRIs _T(" [%d]).\n"), compressor->GetErrStr(n), n);
|
||||||
extern void quit(); quit();
|
extern void quit(); quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ int CEXEBuild::add_db_data(IMMap *mmap) // returns offset
|
||||||
compressor->SetNextOut((char*) db->get(st + sizeof(int) + bufferlen - avail_out, out_len), out_len);
|
compressor->SetNextOut((char*) db->get(st + sizeof(int) + bufferlen - avail_out, out_len), out_len);
|
||||||
if ((ret = compressor->Compress(0)) < 0)
|
if ((ret = compressor->Compress(0)) < 0)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: add_db_data() - compress() failed(%s [%d])\n"), compressor->GetErrStr(ret), ret);
|
ERROR_MSG(_T("Error: add_db_data() - compress() failed(%") NPRIs _T(" [%d])\n"), compressor->GetErrStr(ret), ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mmap->release();
|
mmap->release();
|
||||||
|
@ -884,7 +884,7 @@ int CEXEBuild::add_db_data(IMMap *mmap) // returns offset
|
||||||
compressor->SetNextOut(out, out_len);
|
compressor->SetNextOut(out, out_len);
|
||||||
if ((ret = compressor->Compress(C_FINISH)) < 0)
|
if ((ret = compressor->Compress(C_FINISH)) < 0)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: add_db_data() - compress() failed(%s [%d])\n"), compressor->GetErrStr(ret), ret);
|
ERROR_MSG(_T("Error: add_db_data() - compress() failed(%") NPRIs _T(" [%d])\n"), compressor->GetErrStr(ret), ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -976,7 +976,7 @@ int CEXEBuild::add_data(const char *data, int length, IGrowBuf *dblock) // retur
|
||||||
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
||||||
if (n != C_OK)
|
if (n != C_OK)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%s [%d]).\n"), compressor->GetErrStr(n), n);
|
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%") NPRIs _T(" [%d]).\n"), compressor->GetErrStr(n), n);
|
||||||
extern void quit(); quit();
|
extern void quit(); quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,13 +1043,13 @@ int CEXEBuild::add_label(const TCHAR *name)
|
||||||
if ((*name == _T('.') || (t->code >= cs && t->code <= ce)) &&
|
if ((*name == _T('.') || (t->code >= cs && t->code <= ce)) &&
|
||||||
t->name_ptr==offs)
|
t->name_ptr==offs)
|
||||||
{
|
{
|
||||||
if (*name == _T('.')) ERROR_MSG(_T("Error: global label \"%s\" already declared\n"),name);
|
if (*name == _T('.')) ERROR_MSG(_T("Error: global label \"%") NPRIs _T("\" already declared\n"),name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TCHAR *szType = _T("section");
|
const TCHAR *szType = _T("section");
|
||||||
if (build_cursection_isfunc)
|
if (build_cursection_isfunc)
|
||||||
szType = _T("function");
|
szType = _T("function");
|
||||||
ERROR_MSG(_T("Error: label \"%s\" already declared in %s\n"),name,szType);
|
ERROR_MSG(_T("Error: label \"%") NPRIs _T("\" already declared in %") NPRIs _T("\n"),name,szType);
|
||||||
}
|
}
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1099,7 @@ int CEXEBuild::add_function(const TCHAR *funname)
|
||||||
{
|
{
|
||||||
if (tmp[x].name_ptr == addr)
|
if (tmp[x].name_ptr == addr)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: Function named \"%s\" already exists.\n"),funname);
|
ERROR_MSG(_T("Error: Function named \"%") NPRIs _T("\" already exists.\n"),funname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1267,7 +1267,7 @@ int CEXEBuild::add_section(const TCHAR *secname, const TCHAR *defname, int expan
|
||||||
{
|
{
|
||||||
if (uninstall_mode != old_uninstall_mode)
|
if (uninstall_mode != old_uninstall_mode)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: Can't create %s section in %s section group (use SectionGroupEnd first)\n"), uninstall_mode ? _T("uninstaller") : _T("installer"), old_uninstall_mode ? _T("uninstaller") : _T("installer"));
|
ERROR_MSG(_T("Error: Can't create %") NPRIs _T(" section in %") NPRIs _T(" section group (use SectionGroupEnd first)\n"), uninstall_mode ? _T("uninstaller") : _T("installer"), old_uninstall_mode ? _T("uninstaller") : _T("installer"));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1287,7 @@ int CEXEBuild::add_section(const TCHAR *secname, const TCHAR *defname, int expan
|
||||||
wsprintf(buf, _T("%d"), cur_header->blocks[NB_SECTIONS].num);
|
wsprintf(buf, _T("%d"), cur_header->blocks[NB_SECTIONS].num);
|
||||||
if (definedlist.add(defname, buf))
|
if (definedlist.add(defname, buf))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: \"%s\" already defined, can't assign section index!\n"), defname);
|
ERROR_MSG(_T("Error: \"%") NPRIs _T("\" already defined, can't assign section index!\n"), defname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1417,7 @@ int CEXEBuild::resolve_jump_int(const TCHAR *fn, int *a, int offs, int start, in
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_MSG(_T("Error: could not resolve label \"%s\" in %s\n"),lname,fn);
|
ERROR_MSG(_T("Error: could not resolve label \"%") NPRIs _T("\" in %") NPRIs _T("\n"),lname,fn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1443,7 +1443,7 @@ int CEXEBuild::resolve_call_int(const TCHAR *fn, const TCHAR *str, int fptr, int
|
||||||
}
|
}
|
||||||
sec++;
|
sec++;
|
||||||
}
|
}
|
||||||
ERROR_MSG(_T("Error: resolving %s function \"%s\" in %s\n"),str,(TCHAR*)ns_func.get()+fptr,fn);
|
ERROR_MSG(_T("Error: resolving %") NPRIs _T(" function \"%") NPRIs _T("\" in %") NPRIs _T("\n"),str,(TCHAR*)ns_func.get()+fptr,fn);
|
||||||
ERROR_MSG(_T("Note: uninstall functions must begin with \"un.\", and install functions must not\n"));
|
ERROR_MSG(_T("Note: uninstall functions must begin with \"un.\", and install functions must not\n"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
for (x = sec->code; x < sec->code+sec->code_size; x ++)
|
for (x = sec->code; x < sec->code+sec->code_size; x ++)
|
||||||
{
|
{
|
||||||
TCHAR fname[1024];
|
TCHAR fname[1024];
|
||||||
wsprintf(fname,_T("function \"%s\""),ns_func.get()+sec->name_ptr);
|
wsprintf(fname,_T("function \"%") NPRIs _T("\""),ns_func.get()+sec->name_ptr);
|
||||||
if (resolve_instruction(fname,str,w+x,x,sec->code,sec->code+sec->code_size)) return 1;
|
if (resolve_instruction(fname,str,w+x,x,sec->code,sec->code+sec->code_size)) return 1;
|
||||||
}
|
}
|
||||||
sec++;
|
sec++;
|
||||||
|
@ -1570,8 +1570,8 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
// normal string
|
// normal string
|
||||||
cur_strlist->get(x,section_name);
|
cur_strlist->get(x,section_name);
|
||||||
}
|
}
|
||||||
if (x) wsprintf(fname,_T("%s section \"%s\" (%d)"),str,section_name.c_str(),cnt);
|
if (x) wsprintf(fname,_T("%") NPRIs _T(" section \"%") NPRIs _T("\" (%d)"),str,section_name.c_str(),cnt);
|
||||||
else wsprintf(fname,_T("unnamed %s section (%d)"),str,cnt);
|
else wsprintf(fname,_T("unnamed %") NPRIs _T(" section (%d)"),str,cnt);
|
||||||
for (x = sec->code; x < sec->code+sec->code_size; x ++)
|
for (x = sec->code; x < sec->code+sec->code_size; x ++)
|
||||||
{
|
{
|
||||||
if (resolve_instruction(fname,str,w+x,x,sec->code,sec->code+sec->code_size))
|
if (resolve_instruction(fname,str,w+x,x,sec->code,sec->code+sec->code_size))
|
||||||
|
@ -1587,7 +1587,7 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < cur_header->blocks[NB_PAGES].num) {
|
while (i < cur_header->blocks[NB_PAGES].num) {
|
||||||
TCHAR pagestr[1024];
|
TCHAR pagestr[1024];
|
||||||
wsprintf(pagestr, _T("%s pages"), str);
|
wsprintf(pagestr, _T("%") NPRIs _T(" pages"), str);
|
||||||
if (resolve_call_int(pagestr,p->dlg_id?_T("pre-page"):_T("create-page"),p->prefunc,&p->prefunc)) return 1;
|
if (resolve_call_int(pagestr,p->dlg_id?_T("pre-page"):_T("create-page"),p->prefunc,&p->prefunc)) return 1;
|
||||||
if (resolve_call_int(pagestr,_T("show-page"),p->showfunc,&p->showfunc)) return 1;
|
if (resolve_call_int(pagestr,_T("show-page"),p->showfunc,&p->showfunc)) return 1;
|
||||||
if (resolve_call_int(pagestr,_T("leave-page"),p->leavefunc,&p->leavefunc)) return 1;
|
if (resolve_call_int(pagestr,_T("leave-page"),p->leavefunc,&p->leavefunc)) return 1;
|
||||||
|
@ -1606,21 +1606,21 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
const TCHAR *name;
|
const TCHAR *name;
|
||||||
int *p;
|
int *p;
|
||||||
} callbacks[] = {
|
} callbacks[] = {
|
||||||
{_T("%s.onInit"), &cur_header->code_onInit},
|
{_T("%") NPRIs _T(".onInit"), &cur_header->code_onInit},
|
||||||
{_T("%s.on%sInstSuccess"), &cur_header->code_onInstSuccess},
|
{_T("%") NPRIs _T(".on%") NPRIs _T("InstSuccess"), &cur_header->code_onInstSuccess},
|
||||||
{_T("%s.on%sInstFailed"), &cur_header->code_onInstFailed},
|
{_T("%") NPRIs _T(".on%") NPRIs _T("InstFailed"), &cur_header->code_onInstFailed},
|
||||||
{_T("%s.onUserAbort"), &cur_header->code_onUserAbort},
|
{_T("%") NPRIs _T(".onUserAbort"), &cur_header->code_onUserAbort},
|
||||||
{_T("%s.onVerifyInstDir"), &cur_header->code_onVerifyInstDir},
|
{_T("%") NPRIs _T(".onVerifyInstDir"), &cur_header->code_onVerifyInstDir},
|
||||||
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||||
{_T("%s.onGUIInit"), &cur_header->code_onGUIInit},
|
{_T("%") NPRIs _T(".onGUIInit"), &cur_header->code_onGUIInit},
|
||||||
{_T("%s.onGUIEnd"), &cur_header->code_onGUIEnd},
|
{_T("%") NPRIs _T(".onGUIEnd"), &cur_header->code_onGUIEnd},
|
||||||
{_T("%s.onMouseOverSection"), &cur_header->code_onMouseOverSection},
|
{_T("%") NPRIs _T(".onMouseOverSection"), &cur_header->code_onMouseOverSection},
|
||||||
#endif//NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
#endif//NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||||
{_T("%s.onSelChange"), &cur_header->code_onSelChange},
|
{_T("%") NPRIs _T(".onSelChange"), &cur_header->code_onSelChange},
|
||||||
#endif//NSIS_CONFIG_COMPONENTPAGE
|
#endif//NSIS_CONFIG_COMPONENTPAGE
|
||||||
#ifdef NSIS_SUPPORT_REBOOT
|
#ifdef NSIS_SUPPORT_REBOOT
|
||||||
{_T("%s.onRebootFailed"), &cur_header->code_onRebootFailed},
|
{_T("%") NPRIs _T(".onRebootFailed"), &cur_header->code_onRebootFailed},
|
||||||
#endif//NSIS_SUPPORT_REBOOT
|
#endif//NSIS_SUPPORT_REBOOT
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
@ -1630,9 +1630,9 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
TCHAR fname[1024];
|
TCHAR fname[1024];
|
||||||
wsprintf(fname, callbacks[i].name, un, un);
|
wsprintf(fname, callbacks[i].name, un, un);
|
||||||
TCHAR cbstr[1024];
|
TCHAR cbstr[1024];
|
||||||
wsprintf(cbstr, _T("%s callback"), str);
|
wsprintf(cbstr, _T("%") NPRIs _T(" callback"), str);
|
||||||
TCHAR cbstr2[1024];
|
TCHAR cbstr2[1024];
|
||||||
wsprintf(cbstr2, _T("%s.callbacks"), un);
|
wsprintf(cbstr2, _T("%") NPRIs _T(".callbacks"), un);
|
||||||
|
|
||||||
if (resolve_call_int(cbstr,cbstr2,ns_func.find(fname,0),callbacks[i].p))
|
if (resolve_call_int(cbstr,cbstr2,ns_func.find(fname,0),callbacks[i].p))
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
@ -1653,7 +1653,7 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
{
|
{
|
||||||
if (sec->code_size>0)
|
if (sec->code_size>0)
|
||||||
{
|
{
|
||||||
warning(_T("%s function \"%s\" not referenced - zeroing code (%d-%d) out\n"),str,
|
warning(_T("%") NPRIs _T(" function \"%") NPRIs _T("\" not referenced - zeroing code (%d-%d) out\n"),str,
|
||||||
ns_func.get()+sec->name_ptr,
|
ns_func.get()+sec->name_ptr,
|
||||||
sec->code,sec->code+sec->code_size);
|
sec->code,sec->code+sec->code_size);
|
||||||
memset(w+sec->code,0,sec->code_size*sizeof(entry));
|
memset(w+sec->code,0,sec->code_size*sizeof(entry));
|
||||||
|
@ -1673,8 +1673,8 @@ int CEXEBuild::resolve_coderefs(const TCHAR *str)
|
||||||
if (!t->flags)
|
if (!t->flags)
|
||||||
{
|
{
|
||||||
TCHAR *n=(TCHAR*)ns_label.get()+t->name_ptr;
|
TCHAR *n=(TCHAR*)ns_label.get()+t->name_ptr;
|
||||||
if (*n == _T('.')) warning(_T("global label \"%s\" not used"),n);
|
if (*n == _T('.')) warning(_T("global label \"%") NPRIs _T("\" not used"),n);
|
||||||
else warning(_T("label \"%s\" not used"),n);
|
else warning(_T("label \"%") NPRIs _T("\" not used"),n);
|
||||||
}
|
}
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1751,6 @@ int CEXEBuild::add_page(int type)
|
||||||
cur_pages->add(&pg,sizeof(page));
|
cur_pages->add(&pg,sizeof(page));
|
||||||
|
|
||||||
cur_page = (page *)cur_pages->get() + cur_header->blocks[NB_PAGES].num++;
|
cur_page = (page *)cur_pages->get() + cur_header->blocks[NB_PAGES].num++;
|
||||||
|
|
||||||
cur_page_type = type;
|
cur_page_type = type;
|
||||||
|
|
||||||
set_code_type_predefines(ids[type].name);
|
set_code_type_predefines(ids[type].name);
|
||||||
|
@ -1786,7 +1785,7 @@ int CEXEBuild::AddVersionInfo()
|
||||||
if ( !(2 & version_fixedflags) )
|
if ( !(2 & version_fixedflags) )
|
||||||
{
|
{
|
||||||
// This error string should match the one used by the TOK_VI_SETFILEVERSION handler
|
// This error string should match the one used by the TOK_VI_SETFILEVERSION handler
|
||||||
ERROR_MSG(_T("Error: invalid %s format, should be X.X.X.X\n"),_T("VIProductVersion"));
|
ERROR_MSG(_T("Error: invalid %") NPRIs _T(" format, should be X.X.X.X\n"),_T("VIProductVersion"));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1808,7 +1807,7 @@ int CEXEBuild::AddVersionInfo()
|
||||||
{
|
{
|
||||||
if ( !*recverkeys ) break;
|
if ( !*recverkeys ) break;
|
||||||
if ( !rVersionInfo.FindKey(lang_id, code_page, recverkeys) )
|
if ( !rVersionInfo.FindKey(lang_id, code_page, recverkeys) )
|
||||||
warning(_T("Generating version information for language \"%04d-%s\" without standard key \"%s\""), lang_id, lang_name, recverkeys);
|
warning(_T("Generating version information for language \"%04d-%") NPRIs _T("\" without standard key \"%") NPRIs _T("\""), lang_id, lang_name, recverkeys);
|
||||||
recverkeys += _tcsclen(recverkeys) + 1;
|
recverkeys += _tcsclen(recverkeys) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1817,7 +1816,7 @@ int CEXEBuild::AddVersionInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("Error adding version information: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("Error adding version information: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2134,7 +2133,7 @@ again:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instlog_used) {
|
if (!instlog_used) {
|
||||||
warning(_T("%sage instfiles not used, no sections will be executed!"), uninstall_mode ? _T("Uninstall p") : _T("P"));
|
warning(_T("%") NPRIs _T("age instfiles not used, no sections will be executed!"), uninstall_mode ? _T("Uninstall p") : _T("P"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2223,7 +2222,7 @@ again:
|
||||||
SCRIPT_MSG(_T("Done!\n"));
|
SCRIPT_MSG(_T("Done!\n"));
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("\nError: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("\nError: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2335,12 +2334,12 @@ int CEXEBuild::SetVarsSection()
|
||||||
int stringSize = NSIS_MAX_STRLEN*(build_unicode?sizeof(TCHAR):sizeof(char));
|
int stringSize = NSIS_MAX_STRLEN*(build_unicode?sizeof(TCHAR):sizeof(char));
|
||||||
if (!res_editor->SetPESectionVirtualSize(NSIS_VARS_SECTION, MaxUserVars * stringSize))
|
if (!res_editor->SetPESectionVirtualSize(NSIS_VARS_SECTION, MaxUserVars * stringSize))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Internal compiler error #12346: invalid exehead cannot find section \"%s\"!\n"), _T(NSIS_VARS_SECTION));
|
ERROR_MSG(_T("Internal compiler error #12346: invalid exehead cannot find section \"%") NPRIs _T("\"!\n"), _T(NSIS_VARS_SECTION));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("\nError: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("\nError: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2361,7 +2360,7 @@ int CEXEBuild::SetManifest()
|
||||||
res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("Error setting manifest: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("Error setting manifest: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2378,7 +2377,7 @@ int CEXEBuild::UpdatePEHeader()
|
||||||
// terminal services aware
|
// terminal services aware
|
||||||
headers->OptionalHeader.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE;
|
headers->OptionalHeader.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE;
|
||||||
} catch (std::runtime_error& err) {
|
} catch (std::runtime_error& err) {
|
||||||
ERROR_MSG(_T("Error updating PE headers: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("Error updating PE headers: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2495,7 +2494,7 @@ int CEXEBuild::pack_exe_header()
|
||||||
FILE *tmpfile=FOPEN(build_packname,("wb"));
|
FILE *tmpfile=FOPEN(build_packname,("wb"));
|
||||||
if (!tmpfile)
|
if (!tmpfile)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: writing temporary file \"%s\" for pack\n"),build_packname);
|
ERROR_MSG(_T("Error: writing temporary file \"%") NPRIs _T("\" for pack\n"),build_packname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
fwrite(m_exehead,1,m_exehead_size,tmpfile);
|
fwrite(m_exehead,1,m_exehead_size,tmpfile);
|
||||||
|
@ -2503,7 +2502,7 @@ int CEXEBuild::pack_exe_header()
|
||||||
if (sane_system(build_packcmd) == -1)
|
if (sane_system(build_packcmd) == -1)
|
||||||
{
|
{
|
||||||
_tremove(build_packname);
|
_tremove(build_packname);
|
||||||
ERROR_MSG(_T("Error: calling packer on \"%s\"\n"),build_packname);
|
ERROR_MSG(_T("Error: calling packer on \"%") NPRIs _T("\"\n"),build_packname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2512,7 +2511,7 @@ int CEXEBuild::pack_exe_header()
|
||||||
|
|
||||||
if (result != PS_OK)
|
if (result != PS_OK)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: reading temporary file \"%s\" after pack\n"),build_packname);
|
ERROR_MSG(_T("Error: reading temporary file \"%") NPRIs _T("\" after pack\n"),build_packname);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2579,7 +2578,7 @@ int CEXEBuild::write_output(void)
|
||||||
close_res_editor();
|
close_res_editor();
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("\nError: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("\nError: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2600,7 +2599,7 @@ int CEXEBuild::write_output(void)
|
||||||
{
|
{
|
||||||
tstring full_path = get_full_path(build_output_filename);
|
tstring full_path = get_full_path(build_output_filename);
|
||||||
notify(MakensisAPI::NOTIFY_OUTPUT, full_path.c_str());
|
notify(MakensisAPI::NOTIFY_OUTPUT, full_path.c_str());
|
||||||
INFO_MSG(_T("\nOutput: \"%s\"\n"), full_path.c_str());
|
INFO_MSG(_T("\nOutput: \"%") NPRIs _T("\"\n"), full_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fp = FOPEN(build_output_filename,("w+b"));
|
FILE *fp = FOPEN(build_output_filename,("w+b"));
|
||||||
|
@ -2649,7 +2648,7 @@ int CEXEBuild::write_output(void)
|
||||||
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
||||||
if (n != C_OK)
|
if (n != C_OK)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%s [%d]).\n"), compressor->GetErrStr(n), n);
|
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%") NPRIs _T(" [%d]).\n"), compressor->GetErrStr(n), n);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2717,7 +2716,7 @@ int CEXEBuild::write_output(void)
|
||||||
INFO_MSG(_T("Install: "));
|
INFO_MSG(_T("Install: "));
|
||||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||||
int np=build_header.blocks[NB_PAGES].num;
|
int np=build_header.blocks[NB_PAGES].num;
|
||||||
INFO_MSG(_T("%d page%s (%d bytes), "),np,np==1?_T(""):_T("s"),np*sizeof(page));
|
INFO_MSG(_T("%d page%") NPRIs _T(" (%d bytes), "),np,np==1?_T(""):_T("s"),np*sizeof(page));
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int ns=build_sections.getlen()/sizeof(section);
|
int ns=build_sections.getlen()/sizeof(section);
|
||||||
|
@ -2728,7 +2727,7 @@ int CEXEBuild::write_output(void)
|
||||||
{
|
{
|
||||||
if (!s[x].name_ptr || s[x].flags & SF_RO) req++;
|
if (!s[x].name_ptr || s[x].flags & SF_RO) req++;
|
||||||
}
|
}
|
||||||
INFO_MSG(_T("%d section%s"),ns,ns==1?_T(""):_T("s"));
|
INFO_MSG(_T("%d section%") NPRIs,ns,ns==1?_T(""):_T("s"));
|
||||||
if (req)
|
if (req)
|
||||||
{
|
{
|
||||||
INFO_MSG(_T(" (%u required)"),req);
|
INFO_MSG(_T(" (%u required)"),req);
|
||||||
|
@ -2736,17 +2735,17 @@ int CEXEBuild::write_output(void)
|
||||||
INFO_MSG(_T(" (%d bytes), "), build_sections.getlen());
|
INFO_MSG(_T(" (%d bytes), "), build_sections.getlen());
|
||||||
}
|
}
|
||||||
int ne=build_header.blocks[NB_ENTRIES].num;
|
int ne=build_header.blocks[NB_ENTRIES].num;
|
||||||
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ne*sizeof(entry));
|
INFO_MSG(_T("%d instruction%") NPRIs _T(" (%d bytes), "),ne,ne==1?_T(""):_T("s"),ne*sizeof(entry));
|
||||||
int ns=build_strlist.getnum();
|
int ns=build_strlist.getnum();
|
||||||
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),build_strlist.gettotalsize());
|
INFO_MSG(_T("%d string%") NPRIs _T(" (%d bytes), "),ns,ns==1?_T(""):_T("s"),build_strlist.gettotalsize());
|
||||||
int nlt=build_header.blocks[NB_LANGTABLES].num;
|
int nlt=build_header.blocks[NB_LANGTABLES].num;
|
||||||
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),build_langtables.getlen());
|
INFO_MSG(_T("%d language table%") NPRIs _T(" (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),build_langtables.getlen());
|
||||||
if (ubuild_entries.getlen())
|
if (ubuild_entries.getlen())
|
||||||
{
|
{
|
||||||
INFO_MSG(_T("Uninstall: "));
|
INFO_MSG(_T("Uninstall: "));
|
||||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||||
np=build_uninst.blocks[NB_PAGES].num;
|
np=build_uninst.blocks[NB_PAGES].num;
|
||||||
INFO_MSG(_T("%d page%s (%d bytes), \n"),np,np==1?_T(""):_T("s"),ubuild_pages.getlen());
|
INFO_MSG(_T("%d page%") NPRIs _T(" (%d bytes), "),np,np==1?_T(""):_T("s"),ubuild_pages.getlen());
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int ns=ubuild_sections.getlen()/sizeof(section);
|
int ns=ubuild_sections.getlen()/sizeof(section);
|
||||||
|
@ -2757,7 +2756,7 @@ int CEXEBuild::write_output(void)
|
||||||
{
|
{
|
||||||
if (!s[x].name_ptr || s[x].flags & SF_RO) req++;
|
if (!s[x].name_ptr || s[x].flags & SF_RO) req++;
|
||||||
}
|
}
|
||||||
INFO_MSG(_T("%d section%s"),ns,ns==1?_T(""):_T("s"));
|
INFO_MSG(_T("%d section%") NPRIs,ns,ns==1?_T(""):_T("s"));
|
||||||
if (req)
|
if (req)
|
||||||
{
|
{
|
||||||
INFO_MSG(_T(" (%u required)"),req);
|
INFO_MSG(_T(" (%u required)"),req);
|
||||||
|
@ -2765,11 +2764,11 @@ int CEXEBuild::write_output(void)
|
||||||
INFO_MSG(_T(" (%d bytes), "), ubuild_sections.getlen());
|
INFO_MSG(_T(" (%d bytes), "), ubuild_sections.getlen());
|
||||||
}
|
}
|
||||||
ne=build_uninst.blocks[NB_ENTRIES].num;
|
ne=build_uninst.blocks[NB_ENTRIES].num;
|
||||||
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ubuild_entries.getlen());
|
INFO_MSG(_T("%d instruction%") NPRIs _T(" (%d bytes), "),ne,ne==1?_T(""):_T("s"),ubuild_entries.getlen());
|
||||||
ns=ubuild_strlist.getnum();
|
ns=ubuild_strlist.getnum();
|
||||||
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),ubuild_strlist.gettotalsize());
|
INFO_MSG(_T("%d string%") NPRIs _T(" (%d bytes), "),ns,ns==1?_T(""):_T("s"),ubuild_strlist.gettotalsize());
|
||||||
nlt=build_uninst.blocks[NB_LANGTABLES].num;
|
nlt=build_uninst.blocks[NB_LANGTABLES].num;
|
||||||
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),ubuild_langtables.getlen());
|
INFO_MSG(_T("%d language table%") NPRIs _T(" (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),ubuild_langtables.getlen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2783,7 +2782,7 @@ int CEXEBuild::write_output(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||||
INFO_MSG(_T("\nUsing %s%s compression.\n\n"), compressor->GetName(), build_compress_whole?_T(" (compress whole)"):_T(""));
|
INFO_MSG(_T("\nUsing %") NPRIs _T("%") NPRIs _T(" compression.\n\n"), compressor->GetName(), build_compress_whole?_T(" (compress whole)"):_T(""));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int total_usize=m_exehead_original_size;
|
unsigned int total_usize=m_exehead_original_size;
|
||||||
|
@ -2944,12 +2943,12 @@ int CEXEBuild::write_output(void)
|
||||||
{
|
{
|
||||||
for (struct postbuild_cmd *cmd=postbuild_cmds; cmd; cmd = cmd->next)
|
for (struct postbuild_cmd *cmd=postbuild_cmds; cmd; cmd = cmd->next)
|
||||||
{
|
{
|
||||||
LPTSTR cmdstr = cmd->cmd, cmdstrbuf = NULL;
|
TCHAR *cmdstr = cmd->cmd, *cmdstrbuf = NULL;
|
||||||
LPTSTR arg = _tcsstr(cmdstr, _T("%1"));
|
TCHAR *arg = _tcsstr(cmdstr, _T("%1"));
|
||||||
if (arg) // if found, replace %1 by build_output_filename
|
if (arg) // if found, replace %1 by build_output_filename
|
||||||
{
|
{
|
||||||
const UINT cchbldoutfile = _tcslen(build_output_filename);
|
const UINT cchbldoutfile = _tcslen(build_output_filename);
|
||||||
cmdstrbuf = (LPTSTR) malloc( (_tcslen(cmdstr) + cchbldoutfile + 1)*sizeof(TCHAR) );
|
cmdstrbuf = (TCHAR*) malloc( (_tcslen(cmdstr) + cchbldoutfile + 1)*sizeof(TCHAR) );
|
||||||
if (!cmdstrbuf)
|
if (!cmdstrbuf)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: can't allocate memory for finalize command\n"));
|
ERROR_MSG(_T("Error: can't allocate memory for finalize command\n"));
|
||||||
|
@ -2960,17 +2959,12 @@ int CEXEBuild::write_output(void)
|
||||||
cmdstr = cmdstrbuf;
|
cmdstr = cmdstrbuf;
|
||||||
memmove(arg+cchbldoutfile, arg+2, (_tcslen(arg+2)+1)*sizeof(TCHAR));
|
memmove(arg+cchbldoutfile, arg+2, (_tcslen(arg+2)+1)*sizeof(TCHAR));
|
||||||
memmove(arg, build_output_filename, cchbldoutfile*sizeof(TCHAR));
|
memmove(arg, build_output_filename, cchbldoutfile*sizeof(TCHAR));
|
||||||
|
//BUGBUG: Should we call PathConvertWinToPosix on build_output_filename?
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_MSG(_T("\nFinalize command: %s\n"),cmdstr);
|
SCRIPT_MSG(_T("\nFinalize command: %") NPRIs _T("\n"),cmdstr);
|
||||||
#ifdef _WIN32
|
int ret = sane_system(cmdstr);
|
||||||
int ret=sane_system(cmdstr);
|
if (ret != 0) INFO_MSG(_T("Finalize command returned %d\n"),ret);
|
||||||
#else
|
|
||||||
PATH_CONVERT(cmdstr);
|
|
||||||
int ret=system(cmdstr);
|
|
||||||
#endif
|
|
||||||
if (ret != 0)
|
|
||||||
INFO_MSG(_T("Finalize command returned %d\n"),ret);
|
|
||||||
free(cmdstrbuf);
|
free(cmdstrbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2998,7 +2992,7 @@ int CEXEBuild::deflateToFile(FILE *fp, char *buf, int len) // len==0 to flush
|
||||||
int ret=compressor->Compress(flush);
|
int ret=compressor->Compress(flush);
|
||||||
if (ret<0 && (ret!=-1 || !flush))
|
if (ret<0 && (ret!=-1 || !flush))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: deflateToFile: deflate() failed(%s [%d])\n"), compressor->GetErrStr(ret), ret);
|
ERROR_MSG(_T("Error: deflateToFile: deflate() failed(%") NPRIs _T(" [%d])\n"), compressor->GetErrStr(ret), ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int l=compressor->GetNextOut()-obuf;
|
int l=compressor->GetNextOut()-obuf;
|
||||||
|
@ -3143,7 +3137,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
||||||
if (n != C_OK)
|
if (n != C_OK)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%s [%d]).\n"), compressor->GetErrStr(n), n);
|
ERROR_MSG(_T("Internal compiler error #12345: deflateInit() failed(%") NPRIs _T(" [%d]).\n"), compressor->GetErrStr(n), n);
|
||||||
extern void quit(); quit();
|
extern void quit(); quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3327,7 +3321,7 @@ void CEXEBuild::warning(const TCHAR *s, ...)
|
||||||
notify(MakensisAPI::NOTIFY_WARNING,buf.GetPtr());
|
notify(MakensisAPI::NOTIFY_WARNING,buf.GetPtr());
|
||||||
if (display_warnings)
|
if (display_warnings)
|
||||||
{
|
{
|
||||||
PrintColorFmtMsg_WARN(_T("warning: %s\n"),buf.GetPtr());
|
PrintColorFmtMsg_WARN(_T("warning: %") NPRIs _T("\n"),buf.GetPtr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3340,13 +3334,13 @@ void CEXEBuild::warning_fl(const TCHAR *s, ...)
|
||||||
va_end(val);
|
va_end(val);
|
||||||
|
|
||||||
buf.Reserve(cchMsg+2+_tcslen(curfilename)+50+1+1);
|
buf.Reserve(cchMsg+2+_tcslen(curfilename)+50+1+1);
|
||||||
_stprintf(&buf[cchMsg],_T(" (%s:%u)"),curfilename,linecnt);
|
_stprintf(&buf[cchMsg],_T(" (%") NPRIs _T(":%u)"),curfilename,linecnt);
|
||||||
|
|
||||||
m_warnings.add(buf,0);
|
m_warnings.add(buf,0);
|
||||||
notify(MakensisAPI::NOTIFY_WARNING,buf.GetPtr());
|
notify(MakensisAPI::NOTIFY_WARNING,buf.GetPtr());
|
||||||
if (display_warnings)
|
if (display_warnings)
|
||||||
{
|
{
|
||||||
PrintColorFmtMsg_WARN(_T("warning: %s\n"),buf.GetPtr());
|
PrintColorFmtMsg_WARN(_T("warning: %") NPRIs _T("\n"),buf.GetPtr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3363,7 +3357,7 @@ void CEXEBuild::ERROR_MSG(const TCHAR *s, ...) const
|
||||||
notify(MakensisAPI::NOTIFY_ERROR,buf.GetPtr());
|
notify(MakensisAPI::NOTIFY_ERROR,buf.GetPtr());
|
||||||
if (display_errors)
|
if (display_errors)
|
||||||
{
|
{
|
||||||
PrintColorFmtMsg_ERR(_T("%s"),buf.GetPtr());
|
PrintColorFmtMsg_ERR(_T("%") NPRIs ,buf.GetPtr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3399,10 +3393,10 @@ void CEXEBuild::print_warnings()
|
||||||
TCHAR *p=m_warnings.get();
|
TCHAR *p=m_warnings.get();
|
||||||
while (x>0) if (!p[--x]) nw++;
|
while (x>0) if (!p[--x]) nw++;
|
||||||
SetPrintColorWARN();
|
SetPrintColorWARN();
|
||||||
_ftprintf(g_output,_T("\n%d warning%s:\n"),nw,nw==1?_T(""):_T("s"));
|
_ftprintf(g_output,_T("\n%d warning%") NPRIs _T(":\n"),nw,nw==1?_T(""):_T("s"));
|
||||||
for (x = 0; x < nw; x ++)
|
for (x = 0; x < nw; x ++)
|
||||||
{
|
{
|
||||||
_ftprintf(g_output,_T(" %s\n"),p);
|
_ftprintf(g_output,_T(" %") NPRIs _T("\n"),p);
|
||||||
p+=_tcslen(p)+1;
|
p+=_tcslen(p)+1;
|
||||||
}
|
}
|
||||||
FlushOutputAndResetPrintColor();
|
FlushOutputAndResetPrintColor();
|
||||||
|
@ -3435,7 +3429,7 @@ int CEXEBuild::initialize_default_plugins(bool newtargetarc)
|
||||||
searchPath += PLATFORM_PATH_SEPARATOR_STR _T("Plugins") PLATFORM_PATH_SEPARATOR_STR;
|
searchPath += PLATFORM_PATH_SEPARATOR_STR _T("Plugins") PLATFORM_PATH_SEPARATOR_STR;
|
||||||
searchPath += get_target_suffix();
|
searchPath += get_target_suffix();
|
||||||
|
|
||||||
SCRIPT_MSG(_T("Processing default plugins: \"%s") PLATFORM_PATH_SEPARATOR_STR _T("*.dll\"\n"), searchPath.c_str());
|
SCRIPT_MSG(_T("Processing default plugins: \"%") NPRIs PLATFORM_PATH_SEPARATOR_STR _T("*.dll\"\n"), searchPath.c_str());
|
||||||
if (!m_pPlugins->Initialize(searchPath.c_str(), !!display_script))
|
if (!m_pPlugins->Initialize(searchPath.c_str(), !!display_script))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error initializing default plugins!\n"));
|
ERROR_MSG(_T("Error initializing default plugins!\n"));
|
||||||
|
@ -3562,14 +3556,14 @@ int CEXEBuild::DeclaredUserVar(const TCHAR *szVarName)
|
||||||
{
|
{
|
||||||
if (m_ShellConstants.get((TCHAR*)szVarName) >= 0)
|
if (m_ShellConstants.get((TCHAR*)szVarName) >= 0)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: name \"%s\" in use by constant\n"), szVarName);
|
ERROR_MSG(_T("Error: name \"%") NPRIs _T("\" in use by constant\n"), szVarName);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idxUserVar = m_UserVarNames.get((TCHAR*)szVarName);
|
int idxUserVar = m_UserVarNames.get((TCHAR*)szVarName);
|
||||||
if (idxUserVar >= 0)
|
if (idxUserVar >= 0)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: variable \"%s\" already declared\n"), szVarName);
|
ERROR_MSG(_T("Error: variable \"%") NPRIs _T("\" already declared\n"), szVarName);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
const TCHAR *pVarName = szVarName;
|
const TCHAR *pVarName = szVarName;
|
||||||
|
@ -3591,7 +3585,7 @@ int CEXEBuild::DeclaredUserVar(const TCHAR *szVarName)
|
||||||
{
|
{
|
||||||
if (!isSimpleChar(*pVarName))
|
if (!isSimpleChar(*pVarName))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: invalid characters in variable name \"%s\", use only characters [a-z][A-Z][0-9] and '_'\n"), szVarName);
|
ERROR_MSG(_T("Error: invalid characters in variable name \"%") NPRIs _T("\", use only characters [a-z][A-Z][0-9] and '_'\n"), szVarName);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
pVarName++;
|
pVarName++;
|
||||||
|
@ -3624,7 +3618,7 @@ int CEXEBuild::GetUserVarIndex(LineParser &line, int token)
|
||||||
int idxConst = m_ShellConstants.get((TCHAR *)p+1);
|
int idxConst = m_ShellConstants.get((TCHAR *)p+1);
|
||||||
if (idxConst >= 0)
|
if (idxConst >= 0)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: cannot change constants : %s\n"), p);
|
ERROR_MSG(_T("Error: cannot change constants : %") NPRIs _T("\n"), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3637,7 +3631,7 @@ void CEXEBuild::VerifyDeclaredUserVarRefs(UserVarsStringList *pVarsStringList)
|
||||||
{
|
{
|
||||||
if (!pVarsStringList->get_reference(i))
|
if (!pVarsStringList->get_reference(i))
|
||||||
{
|
{
|
||||||
warning(_T("Variable \"%s\" not referenced or never set, wasting memory!"), pVarsStringList->idx2name(i));
|
warning(_T("Variable \"%") NPRIs _T("\" not referenced or never set, wasting memory!"), pVarsStringList->idx2name(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3711,7 +3705,7 @@ const TCHAR* CEXEBuild::get_target_suffix(CEXEBuild::TARGETTYPE tt) const
|
||||||
{
|
{
|
||||||
case TARGET_X86ANSI :return _T("x86-ansi");
|
case TARGET_X86ANSI :return _T("x86-ansi");
|
||||||
case TARGET_X86UNICODE:return _T("x86-unicode");
|
case TARGET_X86UNICODE:return _T("x86-unicode");
|
||||||
#if !defined(_WIN32) || defined(_WIN64)
|
#if !defined(_WIN32) || defined(_WIN64) // BUGBUG: Need a better define for this
|
||||||
case TARGET_AMD64 :return _T("amd64-unicode");
|
case TARGET_AMD64 :return _T("amd64-unicode");
|
||||||
#endif
|
#endif
|
||||||
default:return _T("?");
|
default:return _T("?");
|
||||||
|
@ -3727,7 +3721,7 @@ int CEXEBuild::update_exehead(const tstring& file, size_t *size/*=NULL*/) {
|
||||||
FILE *tmpfile = FOPEN(file.c_str(), ("rb"));
|
FILE *tmpfile = FOPEN(file.c_str(), ("rb"));
|
||||||
if (!tmpfile)
|
if (!tmpfile)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: opening stub \"%s\"\n"), file.c_str());
|
ERROR_MSG(_T("Error: opening stub \"%") NPRIs _T("\"\n"), file.c_str());
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3738,7 +3732,7 @@ int CEXEBuild::update_exehead(const tstring& file, size_t *size/*=NULL*/) {
|
||||||
fseek(tmpfile, 0, SEEK_SET);
|
fseek(tmpfile, 0, SEEK_SET);
|
||||||
if (fread(exehead, 1, exehead_size, tmpfile) != exehead_size)
|
if (fread(exehead, 1, exehead_size, tmpfile) != exehead_size)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: reading stub \"%s\"\n"), file.c_str());
|
ERROR_MSG(_T("Error: reading stub \"%") NPRIs _T("\"\n"), file.c_str());
|
||||||
fclose(tmpfile);
|
fclose(tmpfile);
|
||||||
delete [] exehead;
|
delete [] exehead;
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
|
|
@ -143,7 +143,7 @@ class CEXEBuild {
|
||||||
|
|
||||||
DefineList definedlist; // List of identifiers marked as "defined" like
|
DefineList definedlist; // List of identifiers marked as "defined" like
|
||||||
// C++ macro definitions such as _UNICODE.
|
// C++ macro definitions such as _UNICODE.
|
||||||
void define(const TCHAR *p, const TCHAR *v=TEXT("")); // to add a defined thing.
|
void define(const TCHAR *p, const TCHAR *v=_T("")); // to add a defined thing.
|
||||||
|
|
||||||
int display_errors;
|
int display_errors;
|
||||||
int display_script;
|
int display_script;
|
||||||
|
|
|
@ -19,10 +19,14 @@
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "dirreader.h"
|
#include "dirreader.h"
|
||||||
#include "tstring.h"
|
#include "tstring.h"
|
||||||
|
#include "util.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <string.h> // for stricmp()
|
#include <string.h> // for stricmp()
|
||||||
#include <ctype.h> // for tolower()
|
#include <ctype.h> // for tolower()
|
||||||
|
#ifdef _UNICODE
|
||||||
|
# include <wctype.h> // towlower()
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -175,11 +179,10 @@ public:
|
||||||
HANDLE h = ::FindFirstFile(spec.c_str(), &fd);
|
HANDLE h = ::FindFirstFile(spec.c_str(), &fd);
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
do {
|
do {
|
||||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
dir_reader::add_dir(fd.cFileName);
|
dir_reader::add_dir(fd.cFileName);
|
||||||
} else {
|
else
|
||||||
dir_reader::add_file(fd.cFileName);
|
dir_reader::add_file(fd.cFileName);
|
||||||
}
|
|
||||||
} while (::FindNextFile(h, &fd));
|
} while (::FindNextFile(h, &fd));
|
||||||
::FindClose(h);
|
::FindClose(h);
|
||||||
}
|
}
|
||||||
|
@ -197,43 +200,33 @@ class posix_dir_reader : public dir_reader {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void read(const tstring& dir) {
|
virtual void read(const tstring& dir) {
|
||||||
//convert(dir);
|
|
||||||
|
|
||||||
DIR *dip = ::opendir(dir.c_str());
|
static const char platformpathsep[2] = {(char)PLATFORM_PATH_SEPARATOR_C, '\0'};
|
||||||
|
|
||||||
|
char *nativedir = NSISRT_ttombpath(dir.c_str());
|
||||||
|
if (!nativedir) return ;
|
||||||
|
|
||||||
|
DIR *dip = ::opendir(nativedir);
|
||||||
if (dip) {
|
if (dip) {
|
||||||
dirent *dit;
|
dirent *dit;
|
||||||
while ((dit = ::readdir(dip))) {
|
while ((dit = ::readdir(dip))) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
string file = dir + PLATFORM_PATH_SEPARATOR_STR + dit->d_name;
|
string file = nativedir;
|
||||||
|
file += platformpathsep, file += dit->d_name;
|
||||||
|
|
||||||
if (!stat(file.c_str(), &st)) {
|
if (!stat(file.c_str(), &st)) {
|
||||||
if (S_ISDIR(st.st_mode)) {
|
tstring name;
|
||||||
dir_reader::add_dir(dit->d_name);
|
name = PosixBug_CtoTString(dit->d_name);
|
||||||
} else {
|
if (S_ISDIR(st.st_mode))
|
||||||
dir_reader::add_file(dit->d_name);
|
dir_reader::add_dir(name);
|
||||||
}
|
else
|
||||||
|
dir_reader::add_file(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::closedir(dip);
|
::closedir(dip);
|
||||||
}
|
}
|
||||||
|
NSISRT_free(nativedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void convert(string& path) {
|
|
||||||
string::size_type pos = path.find(_T('\\'));
|
|
||||||
while (pos != string::npos) {
|
|
||||||
path[pos] = _T('/');
|
|
||||||
pos = path.find(_T('\\'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Replace drive letter X: by /x */
|
|
||||||
if (path[1] == _T(':')) {
|
|
||||||
path[1] = ::_totlower(path[0]);
|
|
||||||
path[0] = _T('/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -361,9 +361,10 @@ void NSISCALL CleanUp()
|
||||||
dbd_hFile = INVALID_HANDLE_VALUE;
|
dbd_hFile = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
// Notify plugins that we are about to unload
|
// Notify plugins that we are about to unload
|
||||||
Plugins_UnloadAll();
|
Plugins_UnloadAll();
|
||||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
|
||||||
// Clean up after plug-ins
|
// Clean up after plug-ins
|
||||||
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
|
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
|
||||||
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
|
|
@ -474,6 +474,9 @@ typedef struct {
|
||||||
COLORREF bkc;
|
COLORREF bkc;
|
||||||
UINT lbStyle;
|
UINT lbStyle;
|
||||||
HBRUSH bkb;
|
HBRUSH bkb;
|
||||||
|
#ifdef _WIN64
|
||||||
|
#error Should we swap lbStyle and bkb to get better alignment? If we are going to do it, now is our only chance before plugins in the wild start depending on the ctlcolors layout on x64
|
||||||
|
#endif
|
||||||
int bkmode;
|
int bkmode;
|
||||||
int flags;
|
int flags;
|
||||||
} ctlcolors;
|
} ctlcolors;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Unicode support and Doxygen comments by Jim Park -- 07/31/2007
|
* Unicode support and Doxygen comments by Jim Park -- 07/31/2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Platform.h"
|
||||||
#include "growbuf.h"
|
#include "growbuf.h"
|
||||||
|
|
||||||
#include <cstdlib> // for malloc/free
|
#include <cstdlib> // for malloc/free
|
||||||
|
@ -25,7 +26,6 @@
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include "Platform.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void GrowBuf::resize(int newlen)
|
||||||
memset((BYTE*)m_s + ou, 0, m_used - ou);
|
memset((BYTE*)m_s + ou, 0, m_used - ou);
|
||||||
|
|
||||||
if (!m_used && m_alloc > 2*m_bs) // only free if you resize to 0 and we're > 64k or
|
if (!m_used && m_alloc > 2*m_bs) // only free if you resize to 0 and we're > 64k or
|
||||||
// 2K in the case of TinyGrowBuf
|
// 2K in the case of TinyGrowBuf
|
||||||
{
|
{
|
||||||
m_alloc=0;
|
m_alloc=0;
|
||||||
free(m_s);
|
free(m_s);
|
||||||
|
|
|
@ -86,6 +86,7 @@ IconGroup load_icon_res(CResourceEditor* re, WORD id)
|
||||||
result.push_back(icon);
|
result.push_back(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
re->FreeResource(group);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +244,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define destroy_icon_group(p) ( delete [] (p) )
|
||||||
static LPBYTE generate_icon_group(IconGroup icon, IconPairs order, bool first)
|
static LPBYTE generate_icon_group(IconGroup icon, IconPairs order, bool first)
|
||||||
{
|
{
|
||||||
LPBYTE group = new BYTE[
|
LPBYTE group = new BYTE[
|
||||||
|
@ -284,6 +286,7 @@ void set_icon(CResourceEditor* re, WORD wIconId, IconGroup icon1, IconGroup icon
|
||||||
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
||||||
|
|
||||||
re->UpdateResource(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG, group1, group_size);
|
re->UpdateResource(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG, group1, group_size);
|
||||||
|
destroy_icon_group(group1);
|
||||||
|
|
||||||
// delete old icons
|
// delete old icons
|
||||||
unsigned i = 1;
|
unsigned i = 1;
|
||||||
|
@ -367,6 +370,7 @@ unsigned char* generate_uninstall_icon_data(IconGroup icon1, IconGroup icon2, si
|
||||||
*(LPDWORD) seeker = 0;
|
*(LPDWORD) seeker = 0;
|
||||||
|
|
||||||
// done
|
// done
|
||||||
|
destroy_icon_group(group);
|
||||||
return uninst_data;
|
return uninst_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +427,7 @@ int generate_unicons_offsets(LPBYTE exeHeader, size_t exeHeaderSize, LPBYTE unin
|
||||||
catch (const exception& e)
|
catch (const exception& e)
|
||||||
{
|
{
|
||||||
if (g_display_errors)
|
if (g_display_errors)
|
||||||
PrintColorFmtMsg_ERR(_T("\nError generating uninstaller icon: %s -- failing!\n"), CtoTStrParam(e.what()));
|
PrintColorFmtMsg_ERR(_T("\nError generating uninstaller icon: %") NPRIs _T(" -- failing!\n"), CtoTStrParam(e.what()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ int CEXEBuild::SetLangString(const TCHAR *name, LANGID lang, const TCHAR *str, B
|
||||||
int sn;
|
int sn;
|
||||||
|
|
||||||
if (!LicenseData && _tcsclen(str) > NSIS_MAX_STRLEN-1)
|
if (!LicenseData && _tcsclen(str) > NSIS_MAX_STRLEN-1)
|
||||||
warning_fl(_T("LangString \"%s\" longer than NSIS_MAX_STRLEN!"), name);
|
warning_fl(_T("LangString \"%") NPRIs _T("\" longer than NSIS_MAX_STRLEN!"), name);
|
||||||
|
|
||||||
int pos = build_langstrings.get(name, &sn);
|
int pos = build_langstrings.get(name, &sn);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
|
@ -589,16 +589,16 @@ int CEXEBuild::GenerateLangTable(LanguageTable *lt, int num_lang_tables) {
|
||||||
if (lsn[0] != _T('^'))
|
if (lsn[0] != _T('^'))
|
||||||
{
|
{
|
||||||
if (lt[i].nlf.m_bLoaded)
|
if (lt[i].nlf.m_bLoaded)
|
||||||
warning(_T("LangString \"%s\" is not set in language table of language %s"), lsn, lt[i].nlf.m_szName);
|
warning(_T("LangString \"%") NPRIs _T("\" is not set in language table of language %") NPRIs, lsn, lt[i].nlf.m_szName);
|
||||||
else
|
else
|
||||||
warning(_T("LangString \"%s\" is not set in language table of language %d"), lsn, lt[i].lang_id);
|
warning(_T("LangString \"%") NPRIs _T("\" is not set in language table of language %d"), lsn, lt[i].lang_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add the language string to the string data block
|
// Add the language string to the string data block
|
||||||
TCHAR fn[1024];
|
TCHAR fn[1024];
|
||||||
_stprintf(fn, _T("LangString %s"), lsn);
|
_stprintf(fn, _T("LangString %") NPRIs, lsn);
|
||||||
curfilename = fn;
|
curfilename = fn;
|
||||||
linecnt = lt[i].lang_id;
|
linecnt = lt[i].lang_id;
|
||||||
*ptr = add_string(str, lang_strings[j].process, (WORD) lt[i].nlf.m_uCodePage);
|
*ptr = add_string(str, lang_strings[j].process, (WORD) lt[i].nlf.m_uCodePage);
|
||||||
|
@ -644,7 +644,7 @@ int CEXEBuild::GenerateLangTable(LanguageTable *lt, int num_lang_tables) {
|
||||||
name = build_langstrings.offset2name(lang_strings[l].name);
|
name = build_langstrings.offset2name(lang_strings[l].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ERROR_MSG(_T("Error: LangString %s is recursive!\n"), name);
|
ERROR_MSG(_T("Error: LangString %") NPRIs _T(" is recursive!\n"), name);
|
||||||
delete [] string_ptrs;
|
delete [] string_ptrs;
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -718,7 +718,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||||
delete [] dlg; \
|
res_editor->FreeResource(dlg); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
#undef ADD_FONT
|
#undef ADD_FONT
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("\nError while applying font: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("\nError while applying font: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
// A Unicode-only language is never displayed correctly by ANSI exehead
|
// A Unicode-only language is never displayed correctly by ANSI exehead
|
||||||
if (!build_unicode && 1200 == lt[i].nlf.m_uCodePage)
|
if (!build_unicode && 1200 == lt[i].nlf.m_uCodePage)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("\nError: Unicode-only language %s cannot be used in ANSI installer!\n"), lt[i].nlf.m_szName);
|
ERROR_MSG(_T("\nError: Unicode-only language %") NPRIs _T(" cannot be used in ANSI installer!\n"), lt[i].nlf.m_szName);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResource(RT_DIALOG, id+cur_offset, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, id+cur_offset, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||||
delete [] dlg; \
|
res_editor->FreeResource(dlg); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
#undef ADD_FONT
|
#undef ADD_FONT
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("\nError while applying NLF font/RTL: %s\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("\nError while applying NLF font/RTL: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,6 +839,21 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CreatePlatformStrfmt(const TCHAR *templ, TCHAR *out) {
|
||||||
|
// NOTE: Only supports plain %s with no options
|
||||||
|
for ( ;; out++ )
|
||||||
|
{
|
||||||
|
*out = *templ++;
|
||||||
|
if (!*out) break;
|
||||||
|
if (*out == L'%' && *templ == L's')
|
||||||
|
{
|
||||||
|
out++, templ++;
|
||||||
|
unsigned int cch = my_strncpy(out, NPRIs, -1);
|
||||||
|
out += --cch; // --cch because for loop does out++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CEXEBuild::FillLanguageTable(LanguageTable *table) {
|
void CEXEBuild::FillLanguageTable(LanguageTable *table) {
|
||||||
for (int i = 0; i < NLF_STRINGS; i++) {
|
for (int i = 0; i < NLF_STRINGS; i++) {
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
@ -876,8 +891,9 @@ void CEXEBuild::FillLanguageTable(LanguageTable *table) {
|
||||||
if (!dstr)
|
if (!dstr)
|
||||||
continue;
|
continue;
|
||||||
if (i == NLF_BRANDING) {
|
if (i == NLF_BRANDING) {
|
||||||
TCHAR temp[NSIS_MAX_STRLEN + sizeof(NSIS_VERSION)];
|
TCHAR temp[NSIS_MAX_STRLEN + sizeof(NSIS_VERSION)], temp2[COUNTOF(temp)];
|
||||||
_stprintf(temp, dstr, NSIS_VERSION);
|
CreatePlatformStrfmt(dstr, temp2); // Change %s to %ls if required
|
||||||
|
_stprintf(temp, temp2, NSIS_VERSION);
|
||||||
table->lang_strings->set(sn, temp);
|
table->lang_strings->set(sn, temp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -931,7 +947,7 @@ LanguageTable * CEXEBuild::LoadLangFile(TCHAR *filename) {
|
||||||
NIStream strm;
|
NIStream strm;
|
||||||
strm.StreamEncoding().SetCodepage(NStreamEncoding::ACP);
|
strm.StreamEncoding().SetCodepage(NStreamEncoding::ACP);
|
||||||
if (!strm.OpenFileForReading(filename)) {
|
if (!strm.OpenFileForReading(filename)) {
|
||||||
ERROR_MSG(_T("Error: Can't open language file - \"%s\"!\n"),filename);
|
ERROR_MSG(_T("Error: Can't open language file - \"%") NPRIs _T("\"!\n"),filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NStreamLineReader lr(strm);
|
NStreamLineReader lr(strm);
|
||||||
|
@ -992,7 +1008,7 @@ l_readerr:
|
||||||
if (p) *p = t;
|
if (p) *p = t;
|
||||||
|
|
||||||
if (nlf_version != NLF_VERSION) {
|
if (nlf_version != NLF_VERSION) {
|
||||||
warning_fl(_T("%s language file version doesn't match. Using default English texts for missing strings."), nlf->m_szName);
|
warning_fl(_T("%") NPRIs _T(" language file version doesn't match. Using default English texts for missing strings."), nlf->m_szName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set ^Language
|
// set ^Language
|
||||||
|
@ -1035,7 +1051,7 @@ l_readerr:
|
||||||
}
|
}
|
||||||
if (CP_ACP != nlf->m_uCodePage && !isnlfdataucp && !IsValidCodePage(nlf->m_uCodePage))
|
if (CP_ACP != nlf->m_uCodePage && !isnlfdataucp && !IsValidCodePage(nlf->m_uCodePage))
|
||||||
{
|
{
|
||||||
warning_fl(_T("%s language file uses a codepage (%d) that is not supported on this system, using ACP!"), nlf->m_szName, nlf->m_uCodePage);
|
warning_fl(_T("%") NPRIs _T(" language file uses a codepage (%d) that is not supported on this system, using ACP!"), nlf->m_szName, nlf->m_uCodePage);
|
||||||
nlf->m_uCodePage = CP_ACP;
|
nlf->m_uCodePage = CP_ACP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1043,7 +1059,7 @@ l_readerr:
|
||||||
// SVN is not a big fan of UTF16 so we should always use UTF8SIG
|
// SVN is not a big fan of UTF16 so we should always use UTF8SIG
|
||||||
if (isnlfdataucp && !lr.StreamEncoding().IsUTF8())
|
if (isnlfdataucp && !lr.StreamEncoding().IsUTF8())
|
||||||
{
|
{
|
||||||
warning_fl(_T("%s Unicode language file is not UTF8SIG."), nlf->m_szName);
|
warning_fl(_T("%") NPRIs _T(" Unicode language file is not UTF8SIG."), nlf->m_szName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lr.IsUnicode())
|
if (!lr.IsUnicode())
|
||||||
|
@ -1119,7 +1135,7 @@ l_readerr:
|
||||||
|
|
||||||
errlr = GetNextNLFLine(lr, buf, NSIS_MAX_STRLEN);
|
errlr = GetNextNLFLine(lr, buf, NSIS_MAX_STRLEN);
|
||||||
if (_tcslen(buf) == NSIS_MAX_STRLEN-1) {
|
if (_tcslen(buf) == NSIS_MAX_STRLEN-1) {
|
||||||
ERROR_MSG(_T("Error: String too long (string #%d - \"%s\")\n"), i, NLFStrings[i].szLangStringName);
|
ERROR_MSG(_T("Error: String too long (string #%d - \"%") NPRIs _T("\")\n"), i, NLFStrings[i].szLangStringName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (NStream::OK != errlr) goto l_readerr;
|
if (NStream::OK != errlr) goto l_readerr;
|
||||||
|
|
|
@ -29,11 +29,9 @@
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utf.h"
|
#include "utf.h"
|
||||||
|
#include "winchar.h" // assert(sizeof(WINWCHAR)...)
|
||||||
|
|
||||||
#include <nsis-version.h>
|
#include <nsis-version.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <io.h>
|
|
||||||
|
|
||||||
#define NSIS_COPYYEARS _T("1999-2013")
|
#define NSIS_COPYYEARS _T("1999-2013")
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -125,7 +123,7 @@ static void init_signals(HWND notify_hwnd)
|
||||||
|
|
||||||
static void print_logo()
|
static void print_logo()
|
||||||
{
|
{
|
||||||
_ftprintf(g_output,_T("MakeNSIS %s - Copyright ") NSIS_COPYYEARS _T(" Contributors\n")
|
_ftprintf(g_output,_T("MakeNSIS %") NPRIs _T(" - Copyright ") NSIS_COPYYEARS _T(" Contributors\n")
|
||||||
_T("See the file COPYING for license details.\n")
|
_T("See the file COPYING for license details.\n")
|
||||||
_T("Credits can be found in the Users Manual.\n\n"), NSIS_VERSION);
|
_T("Credits can be found in the Users Manual.\n\n"), NSIS_VERSION);
|
||||||
fflush(g_output);
|
fflush(g_output);
|
||||||
|
@ -160,21 +158,25 @@ static void print_usage()
|
||||||
_T(" ") _T("makensis [ option | script.nsi | - ] [...]\n")
|
_T(" ") _T("makensis [ option | script.nsi | - ] [...]\n")
|
||||||
_T("\n")
|
_T("\n")
|
||||||
_T("Options:\n")
|
_T("Options:\n")
|
||||||
_T(" ") OPT_STR _T("CMDHELP item prints out help for 'item', or lists all commands\n")
|
_T(" ") OPT_STR _T("CMDHELP [item] prints out help for 'item', or lists all commands\n")
|
||||||
_T(" ") OPT_STR _T("HDRINFO prints information about what options makensis was compiled with\n")
|
_T(" ") OPT_STR _T("HDRINFO prints information about what options makensis was compiled with\n")
|
||||||
_T(" ") OPT_STR _T("LICENSE prints the makensis software license\n")
|
_T(" ") OPT_STR _T("LICENSE prints the makensis software license\n")
|
||||||
_T(" ") OPT_STR _T("VERSION prints the makensis version and exits\n")
|
_T(" ") OPT_STR _T("VERSION prints the makensis version and exits\n")
|
||||||
|
#ifdef _WIN32
|
||||||
_T(" ") OPT_STR _T("Px sets the compiler process priority, where x is 5=realtime,4=high,\n")
|
_T(" ") OPT_STR _T("Px sets the compiler process priority, where x is 5=realtime,4=high,\n")
|
||||||
_T(" ") _T(" 3=above normal,2=normal,1=below normal,0=idle\n")
|
_T(" ") _T(" 3=above normal,2=normal,1=below normal,0=idle\n")
|
||||||
|
#endif
|
||||||
_T(" ") OPT_STR _T("Vx verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none\n")
|
_T(" ") OPT_STR _T("Vx verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none\n")
|
||||||
_T(" ") OPT_STR _T("Ofile specifies a text file to log compiler output (default is stdout)\n")
|
_T(" ") OPT_STR _T("Ofile specifies a text file to log compiler output (default is stdout)\n")
|
||||||
_T(" ") OPT_STR _T("PAUSE pauses after execution\n")
|
_T(" ") OPT_STR _T("PAUSE pauses after execution\n")
|
||||||
_T(" ") OPT_STR _T("NOCONFIG disables inclusion of <path to makensis.exe>") PLATFORM_PATH_SEPARATOR_STR _T("nsisconf.nsh\n")
|
_T(" ") OPT_STR _T("NOCONFIG disables inclusion of <path to makensis.exe>") PLATFORM_PATH_SEPARATOR_STR _T("nsisconf.nsh\n")
|
||||||
_T(" ") OPT_STR _T("NOCD disabled the current directory change to that of the .nsi file\n")
|
_T(" ") OPT_STR _T("NOCD disabled the current directory change to that of the .nsi file\n")
|
||||||
_T(" ") OPT_STR _T("INPUTCHARSET <") TSTR_INPUTCHARSET _T(">\n")
|
_T(" ") OPT_STR _T("INPUTCHARSET <") TSTR_INPUTCHARSET _T(">\n")
|
||||||
|
#ifdef _WIN32
|
||||||
_T(" ") OPT_STR _T("OUTPUTCHARSET <") TSTR_OUTPUTCHARSET _T(">\n")
|
_T(" ") OPT_STR _T("OUTPUTCHARSET <") TSTR_OUTPUTCHARSET _T(">\n")
|
||||||
|
#endif
|
||||||
_T(" ") OPT_STR _T("Ddefine[=value] defines the symbol \"define\" for the script [to value]\n")
|
_T(" ") OPT_STR _T("Ddefine[=value] defines the symbol \"define\" for the script [to value]\n")
|
||||||
_T(" ") OPT_STR _T("Xscriptcmd executes scriptcmd in script (i.e. \"") OPT_STR _T("XOutFile poop.exe\")\n")
|
_T(" ") OPT_STR _T("Xscriptcmd executes scriptcmd in script (i.e. \"") OPT_STR _T("XOutFile inst.exe\")\n")
|
||||||
_T(" ") _T(" parameters are processed by order (") OPT_STR _T("Ddef ins.nsi != ins.nsi ") OPT_STR _T("Ddef)\n")
|
_T(" ") _T(" parameters are processed by order (") OPT_STR _T("Ddef ins.nsi != ins.nsi ") OPT_STR _T("Ddef)\n")
|
||||||
_T("\n")
|
_T("\n")
|
||||||
_T("For script file name, you can use - to read from the standard input\n")
|
_T("For script file name, you can use - to read from the standard input\n")
|
||||||
|
@ -198,9 +200,9 @@ static void print_stub_info(CEXEBuild& build)
|
||||||
_ftprintf(g_output,_T("\nDefined symbols: "));
|
_ftprintf(g_output,_T("\nDefined symbols: "));
|
||||||
for (int i=0; i<x; i++)
|
for (int i=0; i<x; i++)
|
||||||
{
|
{
|
||||||
_ftprintf(g_output,_T("%s"),build.definedlist.getname(i));
|
_ftprintf(g_output,_T("%")NPRIs,build.definedlist.getname(i));
|
||||||
TCHAR *p=build.definedlist.getvalue(i);
|
TCHAR *p=build.definedlist.getvalue(i);
|
||||||
if (*p) _ftprintf(g_output,_T("=%s"),p);
|
if (*p) _ftprintf(g_output,_T("=%")NPRIs,p);
|
||||||
if (i<x-1) _ftprintf(g_output,_T(","));
|
if (i<x-1) _ftprintf(g_output,_T(","));
|
||||||
}
|
}
|
||||||
if (!x) _ftprintf(g_output,_T("none"));
|
if (!x) _ftprintf(g_output,_T("none"));
|
||||||
|
@ -227,7 +229,7 @@ static int process_config(CEXEBuild& build, tstring& conf)
|
||||||
NIStream strm;
|
NIStream strm;
|
||||||
if (strm.OpenFileForReading(conf.c_str()))
|
if (strm.OpenFileForReading(conf.c_str()))
|
||||||
{
|
{
|
||||||
build.INFO_MSG(_T("Processing config: %s\n"),conf.c_str());
|
build.INFO_MSG(_T("Processing config: %") NPRIs _T("\n"),conf.c_str());
|
||||||
int ret=build.process_script(strm,conf.c_str());
|
int ret=build.process_script(strm,conf.c_str());
|
||||||
if (ret != PS_OK && ret != PS_EOF)
|
if (ret != PS_OK && ret != PS_EOF)
|
||||||
{
|
{
|
||||||
|
@ -244,10 +246,10 @@ static int change_to_script_dir(CEXEBuild& build, tstring& script)
|
||||||
tstring dir = get_dir_name(get_full_path(script));
|
tstring dir = get_dir_name(get_full_path(script));
|
||||||
if (!dir.empty())
|
if (!dir.empty())
|
||||||
{
|
{
|
||||||
build.SCRIPT_MSG(_T("Changing directory to: \"%s\"\n"),dir.c_str());
|
build.SCRIPT_MSG(_T("Changing directory to: \"%") NPRIs _T("\"\n"),dir.c_str());
|
||||||
if (_tchdir(dir.c_str()))
|
if (_tchdir(dir.c_str()))
|
||||||
{
|
{
|
||||||
build.ERROR_MSG(_T("Error changing directory to \"%s\"\n"),dir.c_str());
|
build.ERROR_MSG(_T("Error changing directory to \"%") NPRIs _T("\"\n"),dir.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
build.SCRIPT_MSG(_T("\n"));
|
build.SCRIPT_MSG(_T("\n"));
|
||||||
|
@ -269,14 +271,22 @@ static inline bool HasReqParam(TCHAR**argv,int argi,int argc,bool silent=false)
|
||||||
extern "C" void allow_unaligned_data_access();
|
extern "C" void allow_unaligned_data_access();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSIS_ENTRYPOINT_TMAIN
|
static inline int makensismain(int argc, TCHAR **argv)
|
||||||
int _tmain(int argc, TCHAR **argv)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef NSIS_HPUX_ALLOW_UNALIGNED_DATA_ACCESS
|
#ifdef NSIS_HPUX_ALLOW_UNALIGNED_DATA_ACCESS
|
||||||
allow_unaligned_data_access();
|
allow_unaligned_data_access();
|
||||||
#endif
|
#endif
|
||||||
assert(sizeof(wchar_t) > 1 && sizeof(wchar_t) <= 4 && sizeof(WORD) == 2);
|
assert(sizeof(UINT_PTR) == sizeof(void*));
|
||||||
|
assert(sizeof(wchar_t) > 1 && sizeof(wchar_t) <= 4);
|
||||||
|
assert(sizeof(WINWCHAR) == 2 && sizeof(WORD) == 2);
|
||||||
|
assert(sizeof(WINWCHAR) == sizeof(WCHAR)); // Not really required but if WCHAR changes we need to know
|
||||||
|
|
||||||
|
if (!NSISRT_Initialize())
|
||||||
|
{
|
||||||
|
_ftprintf(stdout,_T("NSISRT_Initialize failed!\n"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
HWND hostnotifyhandle=0;
|
HWND hostnotifyhandle=0;
|
||||||
const TCHAR*stdoutredirname=0;
|
const TCHAR*stdoutredirname=0;
|
||||||
|
@ -388,14 +398,14 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
}
|
}
|
||||||
catch (exception& err)
|
catch (exception& err)
|
||||||
{
|
{
|
||||||
PrintColorFmtMsg_ERR(_T("Error initalizing CEXEBuild: %s\n"), CtoTStrParam(err.what()));
|
PrintColorFmtMsg_ERR(_T("Error initalizing CEXEBuild: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
build.notify_hwnd=hostnotifyhandle;
|
build.notify_hwnd=hostnotifyhandle;
|
||||||
#else
|
#else
|
||||||
const TCHAR*const badnonwinswitchfmt=OPT_STR _T("%s is disabled for non Win32 platforms.");
|
const TCHAR*const badnonwinswitchfmt=OPT_STR _T("%") NPRIs _T(" is disabled for non Win32 platforms.");
|
||||||
if (hostnotifyhandle)
|
if (hostnotifyhandle)
|
||||||
build.warning(badnonwinswitchfmt,_T("NOTIFYHWND"));
|
build.warning(badnonwinswitchfmt,_T("NOTIFYHWND"));
|
||||||
if (NStreamEncoding::UNKNOWN==outputenc.GetCodepage())
|
if (NStreamEncoding::UNKNOWN==outputenc.GetCodepage())
|
||||||
|
@ -446,7 +456,7 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
if (NStreamEncoding::UNKNOWN == cp)
|
if (NStreamEncoding::UNKNOWN == cp)
|
||||||
{
|
{
|
||||||
if (_tcsicmp(argv[argpos], _T("AUTO")))
|
if (_tcsicmp(argv[argpos], _T("AUTO")))
|
||||||
build.warning(OPT_STR _T("INPUTCHARSET: Ignoring invalid charset %s"), argv[argpos]);
|
build.warning(OPT_STR _T("INPUTCHARSET: Ignoring invalid charset %") NPRIs , argv[argpos]);
|
||||||
cp = NStreamEncoding::AUTO;
|
cp = NStreamEncoding::AUTO;
|
||||||
}
|
}
|
||||||
inputenc.SafeSetCodepage(cp);
|
inputenc.SafeSetCodepage(cp);
|
||||||
|
@ -479,10 +489,8 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
{HIGH_PRIORITY_CLASS, HIGH_PRIORITY_CLASS},
|
{HIGH_PRIORITY_CLASS, HIGH_PRIORITY_CLASS},
|
||||||
{REALTIME_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS}
|
{REALTIME_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS}
|
||||||
};
|
};
|
||||||
if (SetPriorityClass(hProc, classes[p].priority) == FALSE)
|
if (!SetPriorityClass(hProc, classes[p].priority))
|
||||||
{
|
|
||||||
SetPriorityClass(hProc, classes[p].fallback);
|
SetPriorityClass(hProc, classes[p].fallback);
|
||||||
}
|
|
||||||
if (p == 5) build.warning(_T("makensis is running in REALTIME priority mode!"));
|
if (p == 5) build.warning(_T("makensis is running in REALTIME priority mode!"));
|
||||||
#else
|
#else
|
||||||
build.warning(badnonwinswitchfmt,_T("Px"));
|
build.warning(badnonwinswitchfmt,_T("Px"));
|
||||||
|
@ -496,7 +504,7 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
{
|
{
|
||||||
TCHAR *p=argv[argpos]+2;
|
TCHAR *p=argv[argpos]+2;
|
||||||
TCHAR *s=_tcsdup(p),*v;
|
TCHAR *s=_tcsdup(p),*v;
|
||||||
build.SCRIPT_MSG(_T("Command line defined: \"%s\"\n"),p);
|
build.SCRIPT_MSG(_T("Command line defined: \"%") NPRIs _T("\"\n"),p);
|
||||||
v=_tcsstr(s,_T("="));
|
v=_tcsstr(s,_T("="));
|
||||||
if (v) *v++=0;
|
if (v) *v++=0;
|
||||||
build.define(s,v?v:_T(""));
|
build.define(s,v?v:_T(""));
|
||||||
|
@ -532,7 +540,7 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
#ifndef NSIS_CONFIG_CONST_DATA_PATH
|
#ifndef NSIS_CONFIG_CONST_DATA_PATH
|
||||||
main_conf = get_dir_name(get_executable_dir(argv[0]));
|
main_conf = get_dir_name(get_executable_dir(argv[0]));
|
||||||
#else
|
#else
|
||||||
main_conf = PREFIX_CONF;
|
main_conf = PosixBug_CtoTString(PREFIX_CONF);
|
||||||
#endif
|
#endif
|
||||||
else main_conf = env_var;
|
else main_conf = env_var;
|
||||||
main_conf += PLATFORM_PATH_SEPARATOR_STR;
|
main_conf += PLATFORM_PATH_SEPARATOR_STR;
|
||||||
|
@ -571,7 +579,7 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
if (!strm.OpenFileForReading(nsifile.c_str(),inputenc))
|
if (!strm.OpenFileForReading(nsifile.c_str(),inputenc))
|
||||||
{
|
{
|
||||||
nsifile = argv[argpos];
|
nsifile = argv[argpos];
|
||||||
build.ERROR_MSG(_T("Can't open script \"%s\"\n"),nsifile.c_str());
|
build.ERROR_MSG(_T("Can't open script \"%") NPRIs _T("\"\n"),nsifile.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,12 +594,12 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
build.notify(MakensisAPI::NOTIFY_SCRIPT,nsifile.c_str());
|
build.notify(MakensisAPI::NOTIFY_SCRIPT,nsifile.c_str());
|
||||||
TCHAR bufcpdisp[20];
|
TCHAR bufcpdisp[20];
|
||||||
strm.StreamEncoding().GetCPDisplayName(bufcpdisp);
|
strm.StreamEncoding().GetCPDisplayName(bufcpdisp);
|
||||||
build.INFO_MSG(_T("Processing script file: \"%s\" (%s)\n"),nsifile.c_str(),bufcpdisp);
|
build.INFO_MSG(_T("Processing script file: \"%") NPRIs _T("\" (%") NPRIs _T(")\n"),nsifile.c_str(),bufcpdisp);
|
||||||
int ret=build.process_script(strm,nsifile.c_str());
|
int ret=build.process_script(strm,nsifile.c_str());
|
||||||
|
|
||||||
if (ret != PS_EOF && ret != PS_OK)
|
if (ret != PS_EOF && ret != PS_OK)
|
||||||
{
|
{
|
||||||
build.ERROR_MSG(_T("Error in script \"%s\" on line %d -- aborting creation process\n"),nsifile.c_str(),build.linecnt);
|
build.ERROR_MSG(_T("Error in script \"%") NPRIs _T("\" on line %d -- aborting creation process\n"),nsifile.c_str(),build.linecnt);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,9 +619,9 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
if (build.display_info)
|
if (build.display_info)
|
||||||
{
|
{
|
||||||
_ftprintf(g_output,_T("\nProcessed "));
|
_ftprintf(g_output,_T("\nProcessed "));
|
||||||
if (files_processed) _ftprintf(g_output,_T("%d file%s, "),files_processed,files_processed==1?_T(""):_T("s"));
|
if (files_processed) _ftprintf(g_output,_T("%d file%") NPRIs _T(", "),files_processed,files_processed==1?_T(""):_T("s"));
|
||||||
if (cmds_processed) _ftprintf(g_output,_T("%d command line command%s, "),cmds_processed,cmds_processed==1?_T(""):_T("s"));
|
if (cmds_processed) _ftprintf(g_output,_T("%d command line command%") NPRIs _T(", "),cmds_processed,cmds_processed==1?_T(""):_T("s"));
|
||||||
_ftprintf(g_output,_T("writing output (%s):\n"),build.get_target_suffix());
|
_ftprintf(g_output,_T("writing output (%") NPRIs _T("):\n"),build.get_target_suffix());
|
||||||
fflush(g_output);
|
fflush(g_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,3 +632,55 @@ int _tmain(int argc, TCHAR **argv)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# include <crtdbg.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSIS_ENTRYPOINT_TMAIN
|
||||||
|
int _tmain(int argc, TCHAR **argv)
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_CHECK_ALWAYS_DF);
|
||||||
|
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE), _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
|
||||||
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE), _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
|
||||||
|
//_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE), _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
int retval = makensismain(argc,argv);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_CrtDumpMemoryLeaks();
|
||||||
|
assert(_CrtCheckMemory());
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && defined(_UNICODE)
|
||||||
|
#include <errno.h>
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
int wargc = 0;
|
||||||
|
wchar_t term[1], *p, **wargv = (wchar_t **) malloc((argc+1) * sizeof(void*));
|
||||||
|
if (wargv)
|
||||||
|
for ( ; wargc < argc; ++wargc )
|
||||||
|
if ((p = NSISRT_mbtowc(argv[wargc]))) wargv[wargc] = p; else break;
|
||||||
|
if (wargc == argc)
|
||||||
|
*term = L'\0', wargv[wargc] = term, errno = _tmain(wargc,wargv);
|
||||||
|
else
|
||||||
|
wprintf(L"FATAL: main argv conversion failed!\n");
|
||||||
|
#ifndef NDEBUG // Normally we just leak
|
||||||
|
if (wargv) for ( int i = 0; i < wargc; ++i ) NSISRT_free(wargv[i]);
|
||||||
|
free(wargv);
|
||||||
|
#endif
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "manifest.h"
|
#include "manifest.h"
|
||||||
#include <nsis-version.h>
|
#include <nsis-version.h>
|
||||||
#include "tstring.h"
|
#include "tstring.h"
|
||||||
#include "utf.h"
|
#include "util.h" // RawTStrToASCII
|
||||||
|
|
||||||
// Jim Park: The manifest must stay UTF-8. Do not convert.
|
// Jim Park: The manifest must stay UTF-8. Do not convert.
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
111
Source/strlist.h
111
Source/strlist.h
|
@ -308,25 +308,25 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
SortedStringListND() { }
|
SortedStringListND() { }
|
||||||
virtual ~SortedStringListND() { }
|
virtual ~SortedStringListND() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds name into the list of sorted strings.
|
* Adds name into the list of sorted strings.
|
||||||
*
|
*
|
||||||
* @param name String to store.
|
* @param name String to store.
|
||||||
* @param case_sensitive Look for string case sensitively. Default is 0.
|
* @param case_sensitive Look for string case sensitively. Default is 0.
|
||||||
* @param alwaysreturnpos Always return the position regardless of whether
|
* @param alwaysreturnpos Always return the position regardless of whether
|
||||||
* name was inserted into the list or not. The default is 0.
|
* name was inserted into the list or not. The default is 0.
|
||||||
*
|
*
|
||||||
* @return Returns -1 when name already exists, otherwise the T offset
|
* @return Returns -1 when name already exists, otherwise the T offset
|
||||||
* into which the struct was stored in m_gr. If alwaysreturnpos
|
* into which the struct was stored in m_gr. If alwaysreturnpos
|
||||||
* is true, then it will return the byte offset regardless of whether
|
* is true, then it will return the byte offset regardless of whether
|
||||||
* the string was found.
|
* the string was found.
|
||||||
*/
|
*/
|
||||||
int add(const TCHAR *name, int case_sensitive=0, int alwaysreturnpos=0)
|
int add(const TCHAR *name, int case_sensitive=0, int alwaysreturnpos=0)
|
||||||
{
|
{
|
||||||
int where=0;
|
int where=0;
|
||||||
T newstruct={0,};
|
T newstruct={0,};
|
||||||
|
|
||||||
// Find the best position to insert.
|
// Find the best position to insert.
|
||||||
int pos=find(name,-1,case_sensitive,1,&where);
|
int pos=find(name,-1,case_sensitive,1,&where);
|
||||||
|
|
||||||
if (pos==-1) return alwaysreturnpos ? where : -1;
|
if (pos==-1) return alwaysreturnpos ? where : -1;
|
||||||
|
@ -342,46 +342,46 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function looks for the string str, in T.name in the buffer m_gr.
|
* This function looks for the string str, in T.name in the buffer m_gr.
|
||||||
* If it finds it, it returns the position found. Otherwise, it returns
|
* If it finds it, it returns the position found. Otherwise, it returns
|
||||||
* -1.
|
* -1.
|
||||||
*
|
*
|
||||||
* This behavior changes when returnbestpos == 1. In this case,
|
* This behavior changes when returnbestpos == 1. In this case,
|
||||||
* it will do the reverse. It will return -1 when it is found, noting
|
* it will do the reverse. It will return -1 when it is found, noting
|
||||||
* that there is no good place to put this duplicate string. If it
|
* that there is no good place to put this duplicate string. If it
|
||||||
* is <b>not</b> found, it returns the position where it ought to be
|
* is <b>not</b> found, it returns the position where it ought to be
|
||||||
* placed.
|
* placed.
|
||||||
*
|
*
|
||||||
* When case_sensitive == -1 and returnbestpos == 1, then when the string
|
* When case_sensitive == -1 and returnbestpos == 1, then when the string
|
||||||
* is found, it returns
|
* is found, it returns
|
||||||
* the position of the string so that one can overwrite it. Very strange
|
* the position of the string so that one can overwrite it. Very strange
|
||||||
* special case behavior that I'm not sure if anyone actually uses.
|
* special case behavior that I'm not sure if anyone actually uses.
|
||||||
*
|
*
|
||||||
* @param str The key string to search for.
|
* @param str The key string to search for.
|
||||||
*
|
*
|
||||||
* @param n_chars The number of characters to compare. Use -1 to match
|
* @param n_chars The number of characters to compare. Use -1 to match
|
||||||
* the entire string.
|
* the entire string.
|
||||||
*
|
*
|
||||||
* @param case_sensitive 1 = case sensitive, 0 = case insensitive,
|
* @param case_sensitive 1 = case sensitive, 0 = case insensitive,
|
||||||
* -1 is a special case where it is case sensitive and overrides the
|
* -1 is a special case where it is case sensitive and overrides the
|
||||||
* returnbestpos behavior when the string is found.
|
* returnbestpos behavior when the string is found.
|
||||||
*
|
*
|
||||||
* @param returnbestpos If 1, then look for the best position to add the
|
* @param returnbestpos If 1, then look for the best position to add the
|
||||||
* string. If found in the list, return -1.
|
* string. If found in the list, return -1.
|
||||||
*
|
*
|
||||||
* @param where When str is found, returns the position of the string.
|
* @param where When str is found, returns the position of the string.
|
||||||
*
|
*
|
||||||
* @return The position of T where T.name == str. If returnbestpos != 0
|
* @return The position of T where T.name == str. If returnbestpos != 0
|
||||||
* then return the best position to add T if not found, otherwise, -1.
|
* then return the best position to add T if not found, otherwise, -1.
|
||||||
*/
|
*/
|
||||||
int find
|
int find
|
||||||
(
|
(
|
||||||
const TCHAR* str, /* key to search for */
|
const TCHAR* str, /* key to search for */
|
||||||
int n_chars=-1, /* if -1, test the entire string, otherwise just n characters */
|
int n_chars=-1, /* if -1, test the entire string, otherwise just n characters */
|
||||||
int case_sensitive=0,
|
int case_sensitive=0,
|
||||||
int returnbestpos=0, /* if not found, return best pos */
|
int returnbestpos=0, /* if not found, return best pos */
|
||||||
int* where=0 /* */
|
int*where=0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T *data=(T *) m_gr.get();
|
T *data=(T *) m_gr.get();
|
||||||
|
@ -389,7 +389,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
int ll = 0;
|
int ll = 0;
|
||||||
int nextpos = (ul+ll)/2;
|
int nextpos = (ul+ll)/2;
|
||||||
|
|
||||||
// Do binary search on m_gr which is sorted. m_strings is NOT sorted.
|
// Do binary search on m_gr which is sorted. m_strings is NOT sorted.
|
||||||
while (ul > ll)
|
while (ul > ll)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@ -436,9 +436,8 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TinyGrowBuf m_gr; // Sorted array of Ts
|
TinyGrowBuf m_gr; // Sorted array of Ts
|
||||||
GrowBuf m_strings; // Unsorted array of TCHAR strings
|
GrowBuf m_strings; // Unsorted array of TCHAR strings (contains the .names)
|
||||||
// (contains the .names)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef unsigned short TCHAR, _TUCHAR;
|
||||||
// MSVC typedefs TCHAR inside #ifndef _TCHAR_DEFINED
|
// MSVC typedefs TCHAR inside #ifndef _TCHAR_DEFINED
|
||||||
// and _TCHAR and _T*CHAR inside #ifndef __TCHAR_DEFINED.
|
// and _TCHAR and _T*CHAR inside #ifndef __TCHAR_DEFINED.
|
||||||
// We don't want to break MSVCs _TSCHAR and _TXCHAR so we don't protect our typedef...
|
// We don't want to break MSVCs _TSCHAR and _TXCHAR so we don't protect our typedef...
|
||||||
#if (_MSC_VER>1 && (_MSC_VER<1400 || !defined(_NATIVE_WCHAR_T_DEFINED))) || !defined(_WCHAR_T_DEFINED)
|
#if defined(_WIN32) && ((_MSC_VER>1 && (_MSC_VER<1400 || !defined(_NATIVE_WCHAR_T_DEFINED))) || !defined(_WCHAR_T_DEFINED))
|
||||||
// VC6 knows about __wchar_t but does not support it. /Zc:wchar_t is on by default starting with VC8.
|
// VC6 knows about __wchar_t but does not support it. /Zc:wchar_t is on by default starting with VC8.
|
||||||
// VC7.1 supports __wchar_t but using it causes problems with conversions from WCHAR (unsigned short)?
|
// VC7.1 supports __wchar_t but using it causes problems with conversions from WCHAR (unsigned short)?
|
||||||
typedef unsigned short TCHAR, _TUCHAR;
|
typedef unsigned short TCHAR, _TUCHAR;
|
||||||
|
@ -98,7 +98,7 @@ typedef wchar_t TCHAR, _TUCHAR;
|
||||||
#define _tcstoi64 _wcstoi64
|
#define _tcstoi64 _wcstoi64
|
||||||
#define _tcstol wcstol
|
#define _tcstol wcstol
|
||||||
#define _tcstoul wcstoul
|
#define _tcstoul wcstoul
|
||||||
#if defined(_MSC_VER) && (_MSC_VER<=1200)
|
#if !defined(_WIN32) || (defined(_MSC_VER) && (_MSC_VER<=1200))
|
||||||
# define _tstof my_wtof
|
# define _tstof my_wtof
|
||||||
#else
|
#else
|
||||||
# define _tstof _wtof
|
# define _tstof _wtof
|
||||||
|
@ -120,6 +120,7 @@ typedef wchar_t TCHAR, _TUCHAR;
|
||||||
#define _topen _wopen
|
#define _topen _wopen
|
||||||
#define _tremove _wremove
|
#define _tremove _wremove
|
||||||
#define _tunlink _wunlink
|
#define _tunlink _wunlink
|
||||||
|
#define _tstat _wstat
|
||||||
|
|
||||||
// reading and writing to i/o
|
// reading and writing to i/o
|
||||||
#define _fgettc fgetwc
|
#define _fgettc fgetwc
|
||||||
|
@ -216,6 +217,7 @@ typedef unsigned char _TUCHAR;
|
||||||
#define _topen _open
|
#define _topen _open
|
||||||
#define _tremove remove
|
#define _tremove remove
|
||||||
#define _tunlink _unlink
|
#define _tunlink _unlink
|
||||||
|
#define _tstat stat // _stat on Windows?
|
||||||
|
|
||||||
// reading and writing to i/o
|
// reading and writing to i/o
|
||||||
#define _fgettc fgetc
|
#define _fgettc fgetc
|
||||||
|
|
|
@ -315,13 +315,13 @@ void CEXEBuild::print_help(const TCHAR *commandname)
|
||||||
{
|
{
|
||||||
if (!commandname || !_tcsicmp(tokenlist[x].name,commandname))
|
if (!commandname || !_tcsicmp(tokenlist[x].name,commandname))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("%s%s %s\n"),commandname?_T("Usage: "):_T(""),tokenlist[x].name,tokenlist[x].usage_str);
|
ERROR_MSG(_T("%") NPRIs _T("%") NPRIs _T(" %") NPRIs _T("\n"),commandname?_T("Usage: "):_T(""),tokenlist[x].name,tokenlist[x].usage_str);
|
||||||
if (commandname) break;
|
if (commandname) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x == TOK__LAST && commandname)
|
if (x == TOK__LAST && commandname)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Invalid command \"%s\"\n"),commandname);
|
ERROR_MSG(_T("Invalid command \"%") NPRIs _T("\"\n"),commandname);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -381,17 +381,17 @@ int CEXEBuild::IsTokenPlacedRight(int pos, TCHAR *tok)
|
||||||
else {
|
else {
|
||||||
TCHAR err[1024];
|
TCHAR err[1024];
|
||||||
if (cp == TP_SEC) {
|
if (cp == TP_SEC) {
|
||||||
_tcscpy(err, _T("Error: command %s not valid in Section\n"));
|
_tcscpy(err, _T("Error: command %") NPRIs _T(" not valid in Section\n"));
|
||||||
}
|
}
|
||||||
else if (cp == TP_FUNC) {
|
else if (cp == TP_FUNC) {
|
||||||
_tcscpy(err, _T("Error: command %s not valid in Function\n"));
|
_tcscpy(err, _T("Error: command %") NPRIs _T(" not valid in Function\n"));
|
||||||
}
|
}
|
||||||
else if (cp == TP_PAGEEX) {
|
else if (cp == TP_PAGEEX) {
|
||||||
_tcscpy(err, _T("Error: command %s not valid in PageEx\n"));
|
_tcscpy(err, _T("Error: command %") NPRIs _T(" not valid in PageEx\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tcscpy(err, _T("Error: command %s not valid outside "));
|
_tcscpy(err, _T("Error: command %") NPRIs _T(" not valid outside "));
|
||||||
if (tp & TP_SEC)
|
if (tp & TP_SEC)
|
||||||
_tcscat(err, _T("Section"));
|
_tcscat(err, _T("Section"));
|
||||||
if (tp & TP_FUNC)
|
if (tp & TP_FUNC)
|
||||||
|
|
|
@ -19,51 +19,41 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void CtoTString::Init(const char* str, UINT cp)
|
||||||
CtoTString::CtoTString(const char* str)
|
|
||||||
{
|
{
|
||||||
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
#if defined(_UNICODE) && !defined(_WIN32)
|
||||||
m_wStr = (wchar_t*) malloc(len*sizeof(wchar_t));
|
if (CP_ACP == cp)
|
||||||
MultiByteToWideChar(CP_ACP, 0, str, -1, m_wStr, len);
|
{
|
||||||
|
m_wStr = NSISRT_mbtowc(str); // Should be faster than iconv
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int len = MultiByteToWideChar(cp, 0, str, -1, NULL, 0);
|
||||||
|
m_wStr = (wchar_t*) malloc(len*sizeof(wchar_t));
|
||||||
|
if (m_wStr) MultiByteToWideChar(cp, 0, str, -1, m_wStr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
CtoTString::CtoTString(const char* str, UINT cp)
|
void CtoTString::Init(const char* str)
|
||||||
{
|
{
|
||||||
int len = MultiByteToWideChar(cp, 0, str, -1, NULL, 0);
|
Init(str, CP_ACP);
|
||||||
m_wStr = (wchar_t*) malloc(len*sizeof(wchar_t));
|
|
||||||
MultiByteToWideChar(cp, 0, str, -1, m_wStr, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
CtoTString::CtoTString(const std::string& str)
|
|
||||||
{
|
|
||||||
int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length()+1, NULL, 0);
|
|
||||||
m_wStr = (wchar_t*) malloc(len*sizeof(wchar_t));
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length()+1, m_wStr, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CtoTString::~CtoTString() { free(m_wStr); m_wStr = 0; }
|
CtoTString::~CtoTString() { free(m_wStr); m_wStr = 0; }
|
||||||
|
|
||||||
CtoTString::operator const wchar_t*() const { return GetTStr(); }
|
|
||||||
inline const wchar_t* CtoTString::GetTStr() const { return m_wStr; }
|
|
||||||
|
|
||||||
|
|
||||||
|
void TtoCString::Init(const wchar_t* str)
|
||||||
TtoCString::TtoCString(const wchar_t* wStr)
|
|
||||||
{
|
{
|
||||||
int len = WideCharToMultiByte(CP_ACP, 0, wStr, -1, NULL, 0, 0, 0);
|
#if defined(_UNICODE) && !defined(_WIN32)
|
||||||
m_cStr = (char*) malloc(len);
|
m_cStr = NSISRT_wctomb(str); // Should be faster than iconv
|
||||||
WideCharToMultiByte(CP_ACP, 0, wStr, -1, m_cStr, len, 0, 0);
|
return ;
|
||||||
}
|
#endif
|
||||||
|
int len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
|
||||||
TtoCString::TtoCString(const tstring& wStr)
|
m_cStr = (char*) malloc(len);
|
||||||
{
|
if (m_cStr) WideCharToMultiByte(CP_ACP, 0, str, -1, m_cStr, len, 0, 0);
|
||||||
int len = WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), wStr.length()+1, NULL, 0, 0, 0);
|
|
||||||
m_cStr = (char*) malloc(len);
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), wStr.length()+1, m_cStr, len, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TtoCString::~TtoCString() { free(m_cStr); m_cStr = 0; }
|
TtoCString::~TtoCString() { free(m_cStr); m_cStr = 0; }
|
||||||
|
|
||||||
TtoCString::operator const char*() const { return m_cStr; }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,18 +46,20 @@ typedef std::ifstream tifstream;
|
||||||
|
|
||||||
// This is a helpful little function for converting exceptions or
|
// This is a helpful little function for converting exceptions or
|
||||||
// other system type things that come back ANSI and must be
|
// other system type things that come back ANSI and must be
|
||||||
// utilized as either ANSI or WCHAR depending on _UNICODE.
|
// utilized as either ANSI or wchar_t depending on _UNICODE.
|
||||||
class CtoTString
|
class CtoTString
|
||||||
{
|
{
|
||||||
|
void Init(const char* str, UINT cp);
|
||||||
|
void Init(const char* str);
|
||||||
public:
|
public:
|
||||||
CtoTString(const char* str);
|
CtoTString(const char* str) { Init(str); }
|
||||||
CtoTString(const char* str, UINT cp);
|
CtoTString(const char* str, UINT cp) { Init(str, cp); }
|
||||||
CtoTString(const std::string& str);
|
CtoTString(const std::string& str) { Init(str.c_str()); }
|
||||||
|
|
||||||
~CtoTString();
|
~CtoTString();
|
||||||
|
|
||||||
operator const wchar_t*() const;
|
operator const wchar_t*() const { return m_wStr; }
|
||||||
inline const wchar_t*GetTStr() const;
|
inline const wchar_t*GetTStr() const { return m_wStr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wchar_t* m_wStr;
|
wchar_t* m_wStr;
|
||||||
|
@ -67,17 +69,21 @@ private:
|
||||||
// may actually have Unicode strings.
|
// may actually have Unicode strings.
|
||||||
class TtoCString
|
class TtoCString
|
||||||
{
|
{
|
||||||
|
void Init(const wchar_t* str);
|
||||||
public:
|
public:
|
||||||
TtoCString(const wchar_t* wStr);
|
TtoCString(const wchar_t* wStr) { Init(wStr); }
|
||||||
TtoCString(const tstring& wStr);
|
TtoCString(const tstring& wStr) { Init(wStr.c_str()); }
|
||||||
|
|
||||||
~TtoCString();
|
~TtoCString();
|
||||||
|
|
||||||
operator const char*() const;
|
operator const char*() const { return m_cStr; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* m_cStr;
|
char* m_cStr;
|
||||||
};
|
};
|
||||||
#endif // _UNICODE
|
#endif // _UNICODE
|
||||||
|
|
||||||
|
#define PosixBug_CtoTString CtoTString
|
||||||
|
#define PosixBug_TtoCString TtoCString
|
||||||
|
|
||||||
#endif // NSIS_TSTRING___H__
|
#endif // NSIS_TSTRING___H__
|
||||||
|
|
|
@ -20,13 +20,6 @@
|
||||||
|
|
||||||
#define FIX_ENDIAN_INT16LETOHOST_INPLACE FIX_ENDIAN_INT16_INPLACE
|
#define FIX_ENDIAN_INT16LETOHOST_INPLACE FIX_ENDIAN_INT16_INPLACE
|
||||||
|
|
||||||
void RawTStrToASCII(const TCHAR*in,char*out,UINT maxcch)
|
|
||||||
{
|
|
||||||
const bool empty = !maxcch;
|
|
||||||
for(; maxcch && *in; --maxcch) *out++ = (char) *in++;
|
|
||||||
if (!empty) *out = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT StrLenUTF16(const void*str)
|
UINT StrLenUTF16(const void*str)
|
||||||
{
|
{
|
||||||
unsigned short *p = (unsigned short *) str;
|
unsigned short *p = (unsigned short *) str;
|
||||||
|
@ -85,9 +78,9 @@ UINT WCFromCodePoint(wchar_t*Dest,UINT cchDest,UINT32 CodPt)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
iconvdescriptor iconvd;
|
iconvdescriptor iconvd;
|
||||||
if (!iconvd.Open("wchar_t",iconvd::GetHostEndianUCS4Code())) return 0;
|
if (!iconvd.Open("wchar_t",iconvdescriptor::GetHostEndianUCS4Code())) return 0;
|
||||||
size_t inleft = 4;
|
size_t inleft = 4;
|
||||||
UINT cchW = iconvd.Convert(&codpt,&inleft,Dest,cchDest*sizeof(wchar_t)) / sizeof(wchar_t);
|
UINT cchW = iconvd.Convert(&CodPt,&inleft,Dest,cchDest*sizeof(wchar_t)) / sizeof(wchar_t);
|
||||||
return !inleft ? cchW : 0;
|
return !inleft ? cchW : 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -110,7 +103,7 @@ BOOL CharEncConv::IsValidCodePage(UINT cp)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (cp <= 1 || NStreamEncoding::IsUnicodeCodepage(cp)) return true; // Allow ACP/OEM/UTF*
|
if (cp <= 1 || NStreamEncoding::IsUnicodeCodepage(cp)) return true; // Allow ACP/OEM/UTF*
|
||||||
#endif
|
#endif
|
||||||
return cp < (WORD)-1 && ::IsValidCodePage(cp);
|
return cp < NStreamEncoding::CPCOUNT && ::IsValidCodePage(cp);
|
||||||
}
|
}
|
||||||
bool CharEncConv::Initialize(UINT32 ToEnc, UINT32 FromEnc)
|
bool CharEncConv::Initialize(UINT32 ToEnc, UINT32 FromEnc)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +116,7 @@ bool CharEncConv::Initialize(UINT32 ToEnc, UINT32 FromEnc)
|
||||||
if (NStreamEncoding::UTF16LE == FromEnc) FromEnc = -1;
|
if (NStreamEncoding::UTF16LE == FromEnc) FromEnc = -1;
|
||||||
#endif
|
#endif
|
||||||
m_TE = (WORD) ToEnc, m_FE = (WORD) FromEnc;
|
m_TE = (WORD) ToEnc, m_FE = (WORD) FromEnc;
|
||||||
if ((UTF32LE|1) == (m_FE|1) || (UTF32LE|1) == (m_TE|1)) return false; // UTF32 is a pain to deal with on Windows
|
if ((UTF32LE|1) == (m_FE|1) || (UTF32LE|1) == (m_TE|1)) return false; // UTF-32 is a pain to deal with on Windows
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (IsWE(m_FE) || IsValidCodePage(FromEnc)) && (IsWE(m_TE) || IsValidCodePage(ToEnc));
|
return (IsWE(m_FE) || IsValidCodePage(FromEnc)) && (IsWE(m_TE) || IsValidCodePage(ToEnc));
|
||||||
#else
|
#else
|
||||||
|
@ -154,7 +147,9 @@ void* CharEncConv::Convert(const void*Src, size_t cbSrc, size_t*cbOut)
|
||||||
** Returns a pointer to the buffer on success or 0 on error.
|
** Returns a pointer to the buffer on success or 0 on error.
|
||||||
** The buffer is valid until you call Close() or Convert().
|
** The buffer is valid until you call Close() or Convert().
|
||||||
*/
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
m_OptimizedReturn = false;
|
m_OptimizedReturn = false;
|
||||||
|
#endif
|
||||||
if ((size_t)-1 == cbSrc)
|
if ((size_t)-1 == cbSrc)
|
||||||
{
|
{
|
||||||
UINT cus = IsWE(m_FE) ? sizeof(wchar_t) : NStreamEncoding::GetCodeUnitSize(m_FE);
|
UINT cus = IsWE(m_FE) ? sizeof(wchar_t) : NStreamEncoding::GetCodeUnitSize(m_FE);
|
||||||
|
@ -162,7 +157,7 @@ void* CharEncConv::Convert(const void*Src, size_t cbSrc, size_t*cbOut)
|
||||||
{
|
{
|
||||||
case 1: cbSrc = strlen((char*)Src); break;
|
case 1: cbSrc = strlen((char*)Src); break;
|
||||||
case 2: cbSrc = StrLenUTF16(Src); break;
|
case 2: cbSrc = StrLenUTF16(Src); break;
|
||||||
//case 4: // No UTF32 support...
|
//case 4: // No UTF-32 support...
|
||||||
default:
|
default:
|
||||||
if (sizeof(wchar_t) > 2 && sizeof(wchar_t) == cus)
|
if (sizeof(wchar_t) > 2 && sizeof(wchar_t) == cus)
|
||||||
{
|
{
|
||||||
|
@ -212,10 +207,10 @@ void* CharEncConv::Convert(const void*Src, size_t cbSrc, size_t*cbOut)
|
||||||
{
|
{
|
||||||
if (NStreamEncoding::UTF16BE == m_TE) goto l_swapUTF16;
|
if (NStreamEncoding::UTF16BE == m_TE) goto l_swapUTF16;
|
||||||
cbSrc /= sizeof(wchar_t);
|
cbSrc /= sizeof(wchar_t);
|
||||||
UINT cbDest = WideCharToMultiByte(m_TE, 0, (LPWSTR)Src, cbSrc, 0, 0, 0, 0);
|
UINT cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, cbSrc, 0, 0, 0, 0);
|
||||||
char *p = (char*) realloc(m_Result, (cbDest + 1) * sizeof(char));
|
char *p = (char*) realloc(m_Result, (cbDest + 1) * sizeof(char));
|
||||||
if (p) m_Result = p; else return 0;
|
if (p) m_Result = p; else return 0;
|
||||||
if (!(cbDest = WideCharToMultiByte(m_TE, 0, (LPWSTR)Src, cbSrc, p, cbDest, 0, 0))) return 0;
|
if (!(cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, cbSrc, p, cbDest, 0, 0))) return 0;
|
||||||
if (p[--cbDest]) p[++cbDest] = '\0'; // Always \0 terminate
|
if (p[--cbDest]) p[++cbDest] = '\0'; // Always \0 terminate
|
||||||
if (cbOut) *cbOut = cbDest; // cbOut never includes the \0 terminator
|
if (cbOut) *cbOut = cbDest; // cbOut never includes the \0 terminator
|
||||||
}
|
}
|
||||||
|
@ -253,12 +248,12 @@ l_swapUTF16:
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) || !defined(_UNICODE)
|
#if !defined(_WIN32) || !defined(_UNICODE)
|
||||||
bool WCToUTF16LEHlpr::Create(const TCHAR*in)
|
bool WCToUTF16LEHlpr::Create(const TCHAR*in, unsigned int codepage)
|
||||||
{
|
{
|
||||||
CharEncConv cec;
|
CharEncConv cec;
|
||||||
if (!cec.Initialize(NStreamEncoding::UTF16LE, -1)) return false;
|
if (!cec.Initialize(NStreamEncoding::UTF16LE, -1)) return false;
|
||||||
if (!cec.Convert(in)) return false;
|
if (!cec.Convert(in)) return false;
|
||||||
m_s = cec.Detach();
|
m_s = (unsigned short*) cec.Detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -399,7 +394,7 @@ bool NOStream::WriteString(const wchar_t*Str, size_t cch /*= -1*/)
|
||||||
CharEncConv cec;
|
CharEncConv cec;
|
||||||
if (!cec.Initialize(m_Enc.GetCodepage(), -1)) return false;
|
if (!cec.Initialize(m_Enc.GetCodepage(), -1)) return false;
|
||||||
cec.SetAllowOptimizedReturn(true);
|
cec.SetAllowOptimizedReturn(true);
|
||||||
if ((unsigned)-1 != cch) cch *= sizeof(wchar_t); // cec.Convert wants byte count
|
if ((size_t)-1 != cch) cch *= sizeof(wchar_t); // cec.Convert wants byte count
|
||||||
size_t cbConv;
|
size_t cbConv;
|
||||||
char *p = (char*) cec.Convert(Str, cch, &cbConv);
|
char *p = (char*) cec.Convert(Str, cch, &cbConv);
|
||||||
return p && WriteOctets(p, cbConv);
|
return p && WriteOctets(p, cbConv);
|
||||||
|
@ -453,7 +448,7 @@ tstring NStreamLineReader::GetErrorMessage(UINT Error, const TCHAR*Filename, UIN
|
||||||
if (Filename)
|
if (Filename)
|
||||||
{
|
{
|
||||||
const TCHAR *filelinesep = *Filename ? _T(":") : _T("");
|
const TCHAR *filelinesep = *Filename ? _T(":") : _T("");
|
||||||
_stprintf(buf,_T("%s%u"),filelinesep,Line);
|
_stprintf(buf,_T("%") NPRIs _T("%u"),filelinesep,Line);
|
||||||
msg = msg + _T(": ") + Filename + buf;
|
msg = msg + _T(": ") + Filename + buf;
|
||||||
}
|
}
|
||||||
return msg + _T("\n");
|
return msg + _T("\n");
|
||||||
|
@ -478,7 +473,6 @@ UINT NStreamLineReader::ReadLine(wchar_t*Buffer, UINT cchBuf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
l_restart:
|
l_restart:
|
||||||
// Only supports MBCS and UTF-8 for now...
|
|
||||||
if (StreamEncoding().IsUTF8())
|
if (StreamEncoding().IsUTF8())
|
||||||
{
|
{
|
||||||
for(;;)
|
for(;;)
|
||||||
|
@ -518,7 +512,7 @@ l_restart:
|
||||||
else if (StreamEncoding().IsUTF16())
|
else if (StreamEncoding().IsUTF16())
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (!iconvd.Open("wchar_t", iconvd::GetHostEndianUCS4Code())) goto ERR_UNSUPPORTEDENCODING;
|
if (!iconvd.Open("wchar_t", iconvdescriptor::GetHostEndianUCS4Code())) goto l_unsupportedencoding;
|
||||||
#endif
|
#endif
|
||||||
const bool utf16be = StreamEncoding().IsUTF16BE();
|
const bool utf16be = StreamEncoding().IsUTF16BE();
|
||||||
unsigned short lead, trail, cchWC;
|
unsigned short lead, trail, cchWC;
|
||||||
|
@ -557,7 +551,7 @@ l_restart:
|
||||||
}
|
}
|
||||||
else if (StreamEncoding().IsUnicode())
|
else if (StreamEncoding().IsUnicode())
|
||||||
{
|
{
|
||||||
goto l_unsupportedencoding;
|
goto l_unsupportedencoding;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,6 +77,7 @@ inline bool UTF8_GetTrailCount(unsigned char chFirst, unsigned char &cb)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "tstring.h"
|
#include "tstring.h"
|
||||||
|
#include "util.h" // iconvdescriptor & my_fopen
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h> // For _setmode
|
#include <io.h> // For _setmode
|
||||||
#include <fcntl.h> // For _O_BINARY
|
#include <fcntl.h> // For _O_BINARY
|
||||||
|
@ -84,8 +85,6 @@ inline bool UTF8_GetTrailCount(unsigned char chFirst, unsigned char &cb)
|
||||||
|
|
||||||
FILE* my_fopen(const TCHAR *path, const char *mode); // from util.h
|
FILE* my_fopen(const TCHAR *path, const char *mode); // from util.h
|
||||||
|
|
||||||
void RawTStrToASCII(const TCHAR*in,char*out,UINT maxcch);
|
|
||||||
|
|
||||||
void UTF16InplaceEndianSwap(void*Buffer, UINT cch);
|
void UTF16InplaceEndianSwap(void*Buffer, UINT cch);
|
||||||
UINT StrLenUTF16(const void*str);
|
UINT StrLenUTF16(const void*str);
|
||||||
bool StrSetUTF16LE(tstring&dest, const void*src);
|
bool StrSetUTF16LE(tstring&dest, const void*src);
|
||||||
|
@ -141,7 +140,7 @@ class WCToUTF16LEHlpr {
|
||||||
public:
|
public:
|
||||||
WCToUTF16LEHlpr() : m_s(0) {}
|
WCToUTF16LEHlpr() : m_s(0) {}
|
||||||
|
|
||||||
bool Create(const TCHAR*in)
|
bool Create(const TCHAR*in, unsigned int codepage = CP_ACP)
|
||||||
#if !defined(_WIN32) || !defined(_UNICODE)
|
#if !defined(_WIN32) || !defined(_UNICODE)
|
||||||
;
|
;
|
||||||
#else
|
#else
|
||||||
|
@ -159,6 +158,8 @@ public:
|
||||||
const unsigned short* Get() const { return m_s; }
|
const unsigned short* Get() const { return m_s; }
|
||||||
UINT GetLen() const { return StrLenUTF16(m_s); }
|
UINT GetLen() const { return StrLenUTF16(m_s); }
|
||||||
UINT GetSize() const { return (GetLen()+1) * 2; }
|
UINT GetSize() const { return (GetLen()+1) * 2; }
|
||||||
|
unsigned short* Detach() { unsigned short *r = m_s; m_s = 0; return r; }
|
||||||
|
void CopyTo(unsigned short*Dest) const { memcpy(Dest, Get(), GetSize()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class NStreamEncoding {
|
class NStreamEncoding {
|
||||||
|
|
717
Source/util.cpp
717
Source/util.cpp
File diff suppressed because it is too large
Load diff
|
@ -32,16 +32,14 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
extern double my_wtof(const wchar_t *str);
|
extern double my_wtof(const wchar_t *str);
|
||||||
extern unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax);
|
extern unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax);
|
||||||
|
size_t my_strftime(TCHAR *s, size_t max, const TCHAR *fmt, const struct tm *tm);
|
||||||
|
|
||||||
// Adds the bitmap in filename using resource editor re as id id.
|
// Adds the bitmap in filename using resource editor re as id id.
|
||||||
// If width or height are specified it will also make sure the bitmap is in that size
|
// If width or height are specified it will also make sure the bitmap is in that size
|
||||||
int update_bitmap(CResourceEditor* re, WORD id, const TCHAR* filename, int width=0, int height=0, int maxbpp=0);
|
int update_bitmap(CResourceEditor* re, WORD id, const TCHAR* filename, int width=0, int height=0, int maxbpp=0);
|
||||||
|
|
||||||
size_t my_strftime(TCHAR *s, size_t max, const TCHAR *fmt, const struct tm *tm);
|
|
||||||
|
|
||||||
bool GetDLLVersion(const tstring& filepath, DWORD& high, DWORD& low);
|
bool GetDLLVersion(const tstring& filepath, DWORD& high, DWORD& low);
|
||||||
|
|
||||||
tstring get_full_path(const tstring& path);
|
tstring get_full_path(const tstring& path);
|
||||||
|
@ -54,6 +52,7 @@ tstring lowercase(const tstring&);
|
||||||
tstring get_string_prefix(const tstring& str, const tstring& separator);
|
tstring get_string_prefix(const tstring& str, const tstring& separator);
|
||||||
tstring get_string_suffix(const tstring& str, const tstring& separator);
|
tstring get_string_suffix(const tstring& str, const tstring& separator);
|
||||||
|
|
||||||
|
void RawTStrToASCII(const TCHAR*in,char*out,UINT maxcch);
|
||||||
size_t ExpandoStrFmtVaList(wchar_t*Stack, size_t cchStack, wchar_t**ppMalloc, const wchar_t*FmtStr, va_list Args);
|
size_t ExpandoStrFmtVaList(wchar_t*Stack, size_t cchStack, wchar_t**ppMalloc, const wchar_t*FmtStr, va_list Args);
|
||||||
|
|
||||||
template<typename T, size_t S> class ExpandoString {
|
template<typename T, size_t S> class ExpandoString {
|
||||||
|
@ -112,7 +111,7 @@ int WinStdIO_wprintf(const wchar_t*Fmt, ...);
|
||||||
#define _vftprintf WinStdIO_vfwprintf
|
#define _vftprintf WinStdIO_vfwprintf
|
||||||
#endif // ~MAKENSIS
|
#endif // ~MAKENSIS
|
||||||
#endif // ~_UNICODE
|
#endif // ~_UNICODE
|
||||||
#define ResetPrintColor() FlushOutputAndResetPrintColor() // For reset ONLY use PrintColorFmtMsg(0,NULL ...
|
#define ResetPrintColor() FlushOutputAndResetPrintColor() // For reset ONLY, use PrintColorFmtMsg(0,NULL ...
|
||||||
#define SetPrintColorWARN() PrintColorFmtMsg(1|0x10, NULL, (va_list)NULL)
|
#define SetPrintColorWARN() PrintColorFmtMsg(1|0x10, NULL, (va_list)NULL)
|
||||||
#define SetPrintColorERR() PrintColorFmtMsg(2|0x10, NULL, (va_list)NULL)
|
#define SetPrintColorERR() PrintColorFmtMsg(2|0x10, NULL, (va_list)NULL)
|
||||||
#else
|
#else
|
||||||
|
@ -136,7 +135,6 @@ inline void PrintColorFmtMsg_ERR(const TCHAR *fmtstr, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
// iconv const inconsistency workaround by Alexandre Oliva
|
// iconv const inconsistency workaround by Alexandre Oliva
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -148,7 +146,9 @@ inline size_t nsis_iconv_adaptor
|
||||||
return iconv_func (cd, (T)inbuf, inbytesleft, outbuf, outbytesleft);
|
return iconv_func (cd, (T)inbuf, inbytesleft, outbuf, outbytesleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* nsis_iconv_get_host_endian_ucs4_code();
|
||||||
bool nsis_iconv_reallociconv(iconv_t CD, char**In, size_t*cbInLeft, char**Mem, size_t&cbConverted);
|
bool nsis_iconv_reallociconv(iconv_t CD, char**In, size_t*cbInLeft, char**Mem, size_t&cbConverted);
|
||||||
|
void create_code_page_string(char*buf, size_t len, UINT code_page); // Create iconv code from Windows codepage
|
||||||
|
|
||||||
class iconvdescriptor {
|
class iconvdescriptor {
|
||||||
iconv_t m_cd;
|
iconv_t m_cd;
|
||||||
|
@ -182,25 +182,44 @@ public:
|
||||||
iconv_t GetDescriptor() const { return m_cd; }
|
iconv_t GetDescriptor() const { return m_cd; }
|
||||||
operator iconv_t() const { return m_cd; }
|
operator iconv_t() const { return m_cd; }
|
||||||
|
|
||||||
static const char* GetHostEndianUCS4Code() { return "UCS-4-INTERNAL"; }
|
static const char* GetHostEndianUCS4Code() { return nsis_iconv_get_host_endian_ucs4_code(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BOOL IsDBCSLeadByteEx(unsigned int CodePage, unsigned char TestChar);
|
||||||
TCHAR *CharPrev(const TCHAR *s, const TCHAR *p);
|
TCHAR *CharPrev(const TCHAR *s, const TCHAR *p);
|
||||||
char *CharNextA(const char *s);
|
char *CharNextA(const char *s);
|
||||||
WCHAR *CharNextW(const WCHAR *s);
|
wchar_t *CharNextW(const wchar_t *s);
|
||||||
char *CharNextExA(WORD codepage, const char *s, int flags);
|
char *CharNextExA(WORD codepage, const char *s, int flags);
|
||||||
int wsprintf(TCHAR *s, const TCHAR *format, ...);
|
int wsprintf(TCHAR *s, const TCHAR *format, ...);
|
||||||
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
|
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, const wchar_t* lpWideCharStr,
|
||||||
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,
|
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,
|
||||||
LPBOOL lpUsedDefaultChar);
|
LPBOOL lpUsedDefaultChar);
|
||||||
int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
|
int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
|
||||||
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
|
int cbMultiByte, wchar_t* lpWideCharStr, int cchWideChar);
|
||||||
BOOL IsValidCodePage(UINT CodePage);
|
BOOL IsValidCodePage(UINT CodePage);
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#define CharNext CharNextW
|
#define CharNext CharNextW
|
||||||
#else
|
#else
|
||||||
#define CharNext CharNextA
|
#define CharNext CharNextA
|
||||||
#endif
|
#endif
|
||||||
|
bool NSISRT_Initialize();
|
||||||
|
#define NSISRT_free(p) ( free((void*)(p)) )
|
||||||
|
wchar_t* NSISRT_mbtowc(const char *Str);
|
||||||
|
char* NSISRT_wctomb(const wchar_t *Str);
|
||||||
|
char* NSISRT_wctombpath(const wchar_t *Path);
|
||||||
|
char* NSISRT_ttombpath(const TCHAR *Path);
|
||||||
|
const char* NSISRT_setlocale_wincp(int cat, unsigned int cp);
|
||||||
|
int _wcsicmp(const wchar_t *a, const wchar_t *b);
|
||||||
|
int _wcsnicmp(const wchar_t *a, const wchar_t *b, size_t n);
|
||||||
|
long _wtol(const wchar_t *s);
|
||||||
|
int _wtoi(const wchar_t *s);
|
||||||
|
int _swprintf(wchar_t *d, const wchar_t *f, ...);
|
||||||
|
wchar_t* _wcsdup(const wchar_t *s);
|
||||||
|
wchar_t* _wgetenv(const wchar_t *wname);
|
||||||
|
int _wremove(const wchar_t *Path);
|
||||||
|
#define _wunlink _wremove // BUGBUG: This is not 100% correct, _wremove can also call rmdir
|
||||||
|
int _wchdir(const wchar_t *Path);
|
||||||
|
int _wstat(const wchar_t *Path, struct stat *pS);
|
||||||
|
|
||||||
TCHAR *my_convert(const TCHAR *path);
|
TCHAR *my_convert(const TCHAR *path);
|
||||||
void my_convert_free(TCHAR *converted_path);
|
void my_convert_free(TCHAR *converted_path);
|
||||||
|
@ -208,14 +227,16 @@ int my_open(const TCHAR *pathname, int flags);
|
||||||
|
|
||||||
#define OPEN(a, b) my_open(a, b)
|
#define OPEN(a, b) my_open(a, b)
|
||||||
|
|
||||||
#else
|
#else // _WIN32
|
||||||
|
|
||||||
|
#define NSISRT_Initialize() (true)
|
||||||
|
|
||||||
#define my_convert(x) (x)
|
#define my_convert(x) (x)
|
||||||
#define my_convert_free(x)
|
#define my_convert_free(x)
|
||||||
|
|
||||||
#define OPEN(a, b) _topen(a, b)
|
#define OPEN(a, b) _topen(a, b)
|
||||||
|
|
||||||
#endif
|
#endif // ~_WIN32
|
||||||
|
|
||||||
FILE* my_fopen(const TCHAR *path, const char *mode);
|
FILE* my_fopen(const TCHAR *path, const char *mode);
|
||||||
#define FOPEN(a, b) my_fopen((a), (b))
|
#define FOPEN(a, b) my_fopen((a), (b))
|
||||||
|
@ -240,9 +261,9 @@ inline T align_to_512(const T x) {
|
||||||
|
|
||||||
class BaseResourceManager {
|
class BaseResourceManager {
|
||||||
protected:
|
protected:
|
||||||
BaseResourceManager() {}
|
BaseResourceManager() {}
|
||||||
public:
|
public:
|
||||||
virtual ~BaseResourceManager() {}
|
virtual ~BaseResourceManager() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename _RESOURCE, typename _FREE_RESOURCE>
|
template <typename _RESOURCE, typename _FREE_RESOURCE>
|
||||||
|
@ -258,25 +279,23 @@ private: // don't copy instances
|
||||||
void operator=(const ResourceManager&);
|
void operator=(const ResourceManager&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RM_MANGLE_FREEFUNC(freefunc) \
|
#define RM_MANGLE_FREEFUNC(freefunc) __free_with_##freefunc
|
||||||
__free_with_##freefunc
|
|
||||||
|
|
||||||
#define RM_DEFINE_FREEFUNC(freefunc) \
|
#define RM_DEFINE_FREEFUNC(freefunc) \
|
||||||
struct RM_MANGLE_FREEFUNC(freefunc) { \
|
struct RM_MANGLE_FREEFUNC(freefunc) { \
|
||||||
template <typename T> void operator()(T& x) { freefunc(x); } \
|
template <typename T> void operator()(T& x) { freefunc(x); } \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef boost::scoped_ptr<BaseResourceManager> ResourceManagerPtr;
|
typedef boost::scoped_ptr<BaseResourceManager> ResourceManagerPtr;
|
||||||
|
|
||||||
template<typename _FREE_RESOURCE, typename _RESOURCE>
|
template<typename _FREE_RESOURCE, typename _RESOURCE>
|
||||||
void createResourceManager(_RESOURCE& resource, ResourceManagerPtr& ptr) {
|
void createResourceManager(_RESOURCE& resource, ResourceManagerPtr& ptr) {
|
||||||
ptr.reset(new ResourceManager<_RESOURCE, _FREE_RESOURCE>(resource));
|
ptr.reset(new ResourceManager<_RESOURCE, _FREE_RESOURCE>(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RM_MANGLE_RESOURCE(resource) resource##_autoManager
|
#define RM_MANGLE_RESOURCE(resource) resource##_autoManager
|
||||||
#define MANAGE_WITH(resource, freefunc) \
|
#define MANAGE_WITH(resource, freefunc) \
|
||||||
ResourceManagerPtr RM_MANGLE_RESOURCE(resource); \
|
ResourceManagerPtr RM_MANGLE_RESOURCE(resource); \
|
||||||
createResourceManager<RM_MANGLE_FREEFUNC(freefunc)>( \
|
createResourceManager<RM_MANGLE_FREEFUNC(freefunc)>( \
|
||||||
resource, RM_MANGLE_RESOURCE(resource))
|
resource, RM_MANGLE_RESOURCE(resource))
|
||||||
|
|
||||||
// Add more resource-freeing functions here when you need them
|
// Add more resource-freeing functions here when you need them
|
||||||
|
@ -294,6 +313,7 @@ RM_DEFINE_FREEFUNC(my_convert_free);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Platform detection
|
// Platform detection
|
||||||
bool Platform_SupportsUTF8Conversion();
|
inline bool Platform_IsBigEndian() { return FIX_ENDIAN_INT16(0x00ff) != 0x00ff; }
|
||||||
|
unsigned char Platform_SupportsUTF8Conversion();
|
||||||
|
|
||||||
#endif //_UTIL_H_
|
#endif //_UTIL_H_
|
||||||
|
|
|
@ -12,18 +12,98 @@
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*
|
|
||||||
* Reviewed for Unicode support by Jim Park -- 08/13/2007
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "winchar.h"
|
#include "winchar.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "utf.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
|
|
||||||
|
int WinWStrICmpASCII(const WINWCHAR *a, const char *b)
|
||||||
|
{
|
||||||
|
int diff = 0;
|
||||||
|
do
|
||||||
|
diff = static_cast<int>(S7ChLwr(*a)) - static_cast<int>(S7ChLwr(*b++));
|
||||||
|
while (*a++ && !diff);
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
int WinWStrNICmpASCII(const WINWCHAR *a, const char *b, size_t n)
|
||||||
|
{
|
||||||
|
int diff = 0;
|
||||||
|
for ( ; n--; ++a, ++b )
|
||||||
|
{
|
||||||
|
diff = static_cast<int>(S7ChLwr(*a)) - static_cast<int>(S7ChLwr(*b));
|
||||||
|
if (diff || !*a) break;
|
||||||
|
}
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
size_t WinWStrLen(const WINWCHAR *s)
|
||||||
|
{
|
||||||
|
return StrLenUTF16(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINWCHAR* WinWStrCpy(WINWCHAR *d, const WINWCHAR *s)
|
||||||
|
{
|
||||||
|
WINWCHAR *ret = d;
|
||||||
|
while (*s) *d++ = *s++;
|
||||||
|
*d = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINWCHAR* WinWStrNCpy(WINWCHAR *d, const WINWCHAR *s, size_t n)
|
||||||
|
{
|
||||||
|
WINWCHAR *ret = d;
|
||||||
|
while (n && *s) *d++ = *s++, n--;
|
||||||
|
while (n--) *d++ = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WinWStrCmp(const WINWCHAR *a, const WINWCHAR *b)
|
||||||
|
{
|
||||||
|
int diff = 0;
|
||||||
|
do
|
||||||
|
diff = static_cast<int>(*a) - static_cast<int>(*b++);
|
||||||
|
while (*a++ && !diff);
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINWCHAR* WinWStrDupFromWinWStr(const WINWCHAR *s)
|
||||||
|
{
|
||||||
|
WINWCHAR *d = (WINWCHAR*) malloc((WinWStrLen(s) + 1) * sizeof(WINWCHAR));
|
||||||
|
if (d) WinWStrCpy(d, s);
|
||||||
|
assert(!d || !IS_INTRESOURCE(d)); // DialogTemplate strings can be ATOMs
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINWCHAR* WinWStrDupFromTChar(const TCHAR *s)
|
||||||
|
{
|
||||||
|
WCToUTF16LEHlpr cnv;
|
||||||
|
if (!cnv.Create(s)) throw runtime_error("Unicode conversion failed");
|
||||||
|
return (WINWCHAR*) cnv.Detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
int WinWStrToInt(const WINWCHAR *s)
|
||||||
|
{
|
||||||
|
unsigned int v = 0, base = 10, top = '9';
|
||||||
|
int sign = 1;
|
||||||
|
if (*s == _T('-')) ++s, sign = -1;
|
||||||
|
for ( unsigned int c;; )
|
||||||
|
{
|
||||||
|
if ((c = *s++) >= '0' && c <= top) c -= '0'; else break;
|
||||||
|
v *= base, v += c;
|
||||||
|
}
|
||||||
|
return ((int)v) * sign;
|
||||||
|
}
|
||||||
|
#endif // ~!_WIN32
|
||||||
|
|
||||||
|
#if 0
|
||||||
WCHAR *wcsdup_fromansi(const char* s, unsigned int codepage/* = CP_ACP*/)
|
WCHAR *wcsdup_fromansi(const char* s, unsigned int codepage/* = CP_ACP*/)
|
||||||
{
|
{
|
||||||
int l = MultiByteToWideChar(codepage, 0, s, -1, 0, 0);
|
int l = MultiByteToWideChar(codepage, 0, s, -1, 0, 0);
|
||||||
|
@ -31,75 +111,8 @@ WCHAR *wcsdup_fromansi(const char* s, unsigned int codepage/* = CP_ACP*/)
|
||||||
throw runtime_error("Unicode conversion failed");
|
throw runtime_error("Unicode conversion failed");
|
||||||
|
|
||||||
WCHAR *ws = new WCHAR[l + 1];
|
WCHAR *ws = new WCHAR[l + 1];
|
||||||
|
|
||||||
if (MultiByteToWideChar(codepage, 0, s, -1, ws, l + 1) == 0)
|
if (MultiByteToWideChar(codepage, 0, s, -1, ws, l + 1) == 0)
|
||||||
throw runtime_error("Unicode conversion failed");
|
throw runtime_error("Unicode conversion failed");
|
||||||
|
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // Needed by some RTL missing wchar string functions ?
|
|
||||||
WCHAR *wcscpy(WCHAR *ws1, const WCHAR *ws2)
|
|
||||||
{
|
|
||||||
WCHAR *ret = ws1;
|
|
||||||
|
|
||||||
while (*ws2)
|
|
||||||
{
|
|
||||||
*ws1++ = *ws2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ws1 = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
WCHAR *wcsncpy(WCHAR *ws1, const WCHAR *ws2, size_t n)
|
|
||||||
{
|
|
||||||
WCHAR *ret = ws1;
|
|
||||||
|
|
||||||
while (n && *ws2)
|
|
||||||
{
|
|
||||||
*ws1++ = *ws2++;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n--)
|
|
||||||
{
|
|
||||||
*ws1++ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t wcslen(const WCHAR *ws)
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
while (*ws++)
|
|
||||||
{
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
WCHAR *_wcsdup(const WCHAR *ws)
|
|
||||||
{
|
|
||||||
WCHAR *dup = (WCHAR*) malloc(sizeof(WCHAR)*(wcslen(ws)+1)];
|
|
||||||
wcscpy(dup, ws);
|
|
||||||
return dup;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wcscmp(const WCHAR *ws1, const WCHAR *ws2)
|
|
||||||
{
|
|
||||||
int diff = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
diff = static_cast<int>(*ws1) - static_cast<int>(*ws2);
|
|
||||||
}
|
|
||||||
while (*ws1++ && *ws2++ && !diff);
|
|
||||||
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,23 +12,45 @@
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*
|
|
||||||
* Reviewed for Unicode support by Jim Park -- 07/31/2007
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_NSIS_WINCHAR
|
||||||
|
#define INC_NSIS_WINCHAR
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
#define MAKEINTRESOURCEWINW(i) ( (WINWCHAR*) MAKEINTRESOURCEW(i) )
|
||||||
|
|
||||||
|
int WinWStrICmpASCII(const WINWCHAR *a, const char *b);
|
||||||
|
int WinWStrNICmpASCII(const WINWCHAR *a, const char *b, size_t n);
|
||||||
|
#ifdef _WIN32
|
||||||
|
inline size_t WinWStrLen(const WINWCHAR *s) { return wcslen((wchar_t*)s); }
|
||||||
|
inline WINWCHAR* WinWStrCpy(WINWCHAR *d, const WINWCHAR *s) { return (WINWCHAR*)wcscpy((wchar_t*)d, (wchar_t*)s); }
|
||||||
|
inline WINWCHAR* WinWStrNCpy(WINWCHAR *d, const WINWCHAR *s, size_t n) { return (WINWCHAR*)wcsncpy((wchar_t*)d, (wchar_t*)s, n); }
|
||||||
|
inline int WinWStrCmp(const WINWCHAR *a, const WINWCHAR *b) { return wcscmp((wchar_t*)a, (wchar_t*)b); }
|
||||||
|
inline WINWCHAR* WinWStrDupFromWinWStr(const WINWCHAR *s) { return (WINWCHAR*)wcsdup((wchar_t*)s); }
|
||||||
|
inline WINWCHAR* WinWStrDupFromTChar(const wchar_t *s) { return WinWStrDupFromWinWStr((WINWCHAR*)s); }
|
||||||
|
inline int WinWStrToInt(const WINWCHAR *s) { return _wtoi((wchar_t*)s); }
|
||||||
|
#else // !_WIN32
|
||||||
|
size_t WinWStrLen(const WINWCHAR *s);
|
||||||
|
WINWCHAR* WinWStrCpy(WINWCHAR *d, const WINWCHAR *s);
|
||||||
|
WINWCHAR* WinWStrNCpy(WINWCHAR *d, const WINWCHAR *s, size_t n);
|
||||||
|
int WinWStrCmp(const WINWCHAR *a, const WINWCHAR *b);
|
||||||
|
WINWCHAR* WinWStrDupFromWinWStr(const WINWCHAR *s);
|
||||||
|
WINWCHAR* WinWStrDupFromTChar(const TCHAR *s);
|
||||||
|
int WinWStrToInt(const WINWCHAR *s);
|
||||||
|
#endif // ~_WIN32
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
inline WINWCHAR* WinWStrDupFromTChar(const TCHAR *s, unsigned int codepage) { return WinWStrDupFromTChar(s); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
WCHAR *wcsdup_fromansi(const char* s, unsigned int codepage = CP_ACP);
|
WCHAR *wcsdup_fromansi(const char* s, unsigned int codepage = CP_ACP);
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#define wcsdup_fromTchar(s, codepage) _wcsdup(s) // codepage is not used in this mode
|
#define wcsdup_fromTchar(s, codepage) _wcsdup(s) // codepage is not used in this mode
|
||||||
#else
|
#else
|
||||||
#define wcsdup_fromTchar(s, codepage) wcsdup_fromansi(s, codepage)
|
#define wcsdup_fromTchar(s, codepage) wcsdup_fromansi(s, codepage)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 // Needed by some RTL missing wchar string functions ?
|
|
||||||
WCHAR *wcscpy(WCHAR *ws1, const WCHAR *ws2);
|
|
||||||
WCHAR *wcsncpy(WCHAR *ws1, const WCHAR *ws2, size_t n);
|
|
||||||
size_t wcslen(const WCHAR *ws);
|
|
||||||
WCHAR *_wcsdup(const WCHAR *ws);
|
|
||||||
int wcscmp(const WCHAR *ws1, const WCHAR *ws2);
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif // ~INC_NSIS_WINCHAR
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue