Jim Park's Unicode NSIS merging - Step 4 : merging more TCHAR stuff that shouldn't have any impact

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6041 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-03-29 14:24:47 +00:00
parent 8ab72b9ece
commit acf9a8c21f
41 changed files with 937 additions and 586 deletions

View file

@ -28,7 +28,7 @@ BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
int iMainStringSet = 0; int iMainStringSet = 0;
popstring(buf); popstring(buf);
while (*(int*)buf == CHAR4_TO_DWORD('/','s','e','t') && !buf[4]) while (lstrcmp(buf, _T("/set")) == 0)
{ {
unsigned int id; unsigned int id;
popstring(buf); popstring(buf);

View file

@ -168,9 +168,9 @@ NSISFunc(SetBg) {
uWndWidth = uScrWidth; uWndWidth = uScrWidth;
uWndHeight = uScrHeight; uWndHeight = uScrHeight;
char szGradient[] = {'/', 'G', 'R', 'A', 'D', 'I', 'E', 'N', 'T', 0}; LPCTSTR szGradient = _T("/GRADIENT");
char szFillScreen[] = {'/', 'F', 'I' ,'L', 'L', 'S', 'C', 'R', 'E', 'E', 'N', 0}; LPCTSTR szFillScreen = _T("/FILLSCREEN");
char szTiled[] = {'/', 'T', 'I', 'L', 'E', 'D', 0}; LPCTSTR szTiled = _T("/TILED");
popstring(szTemp); popstring(szTemp);
if (!lstrcmpi(szTemp, szGradient)) { if (!lstrcmpi(szTemp, szGradient)) {
@ -357,9 +357,9 @@ NSISFunc(Destroy) {
} }
NSISFunc(Sound) { NSISFunc(Sound) {
char szLoop[] = {'/', 'L', 'O', 'O', 'P', 0}; LPCTSTR szLoop = _T("/LOOP");
char szWait[] = {'/', 'W', 'A', 'I', 'T', 0}; LPCTSTR szWait = _T("/WAIT");
char szStop[] = {'/', 'S', 'T', 'O', 'P', 0}; LPCTSTR szStop = _T("/STOP");
DWORD flags = SND_FILENAME | SND_NODEFAULT; DWORD flags = SND_FILENAME | SND_NODEFAULT;

View file

@ -13,7 +13,7 @@ int NSISCALL popstring(TCHAR *str)
stack_t *th; stack_t *th;
if (!g_stacktop || !*g_stacktop) return 1; if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop); th=(*g_stacktop);
if (str) lstrcpyA(str,th->text); if (str) lstrcpy(str,th->text);
*g_stacktop = th->next; *g_stacktop = th->next;
GlobalFree((HGLOBAL)th); GlobalFree((HGLOBAL)th);
return 0; return 0;
@ -24,7 +24,7 @@ int NSISCALL popstringn(TCHAR *str, int maxlen)
stack_t *th; stack_t *th;
if (!g_stacktop || !*g_stacktop) return 1; if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop); th=(*g_stacktop);
if (str) lstrcpynA(str,th->text,maxlen?maxlen:g_stringsize); if (str) lstrcpyn(str,th->text,maxlen?maxlen:g_stringsize);
*g_stacktop = th->next; *g_stacktop = th->next;
GlobalFree((HGLOBAL)th); GlobalFree((HGLOBAL)th);
return 0; return 0;
@ -34,8 +34,8 @@ void NSISCALL pushstring(const TCHAR *str)
{ {
stack_t *th; stack_t *th;
if (!g_stacktop) return; if (!g_stacktop) return;
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize); th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR)));
lstrcpynA(th->text,str,g_stringsize); lstrcpyn(th->text,str,g_stringsize);
th->next=*g_stacktop; th->next=*g_stacktop;
*g_stacktop=th; *g_stacktop=th;
} }
@ -49,9 +49,108 @@ TCHAR * NSISCALL getuservariable(const int varnum)
void NSISCALL setuservariable(const int varnum, const TCHAR *var) void NSISCALL setuservariable(const int varnum, const TCHAR *var)
{ {
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
lstrcpyA(g_variables + varnum*g_stringsize, var); lstrcpy(g_variables + varnum*g_stringsize, var);
} }
#ifdef _UNICODE
int NSISCALL PopStringA(char* ansiStr)
{
wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
int rval = popstring(wideStr);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
GlobalFree((HGLOBAL)wideStr);
return rval;
}
int NSISCALL PopStringNA(char* ansiStr, int maxlen)
{
int realLen = maxlen ? maxlen : g_stringsize;
wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, realLen*sizeof(wchar_t));
int rval = popstringn(wideStr, realLen);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, realLen, NULL, NULL);
GlobalFree((HGLOBAL)wideStr);
return rval;
}
void NSISCALL PushStringA(const char* ansiStr)
{
wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
pushstring(wideStr);
GlobalFree((HGLOBAL)wideStr);
return;
}
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr)
{
lstrcpyW(wideStr, getuservariable(varnum));
}
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr)
{
wchar_t* wideStr = getuservariable(varnum);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
}
void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr)
{
if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
{
wchar_t* wideStr = g_variables + varnum * g_stringsize;
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
}
}
#else
// ANSI defs
int NSISCALL PopStringW(wchar_t* wideStr)
{
char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
int rval = popstring(ansiStr);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
GlobalFree((HGLOBAL)ansiStr);
return rval;
}
int NSISCALL PopStringNW(wchar_t* wideStr, int maxlen)
{
int realLen = maxlen ? maxlen : g_stringsize;
char* ansiStr = (char*) GlobalAlloc(GPTR, realLen);
int rval = popstringn(ansiStr, realLen);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, realLen);
GlobalFree((HGLOBAL)ansiStr);
return rval;
}
void NSISCALL PushStringW(wchar_t* wideStr)
{
char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
pushstring(ansiStr);
GlobalFree((HGLOBAL)ansiStr);
}
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr)
{
char* ansiStr = getuservariable(varnum);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
}
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr)
{
lstrcpyA(ansiStr, getuservariable(varnum));
}
void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr)
{
if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
{
char* ansiStr = g_variables + varnum * g_stringsize;
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
}
}
#endif
// playing with integers // playing with integers
int NSISCALL myatoi(const TCHAR *s) int NSISCALL myatoi(const TCHAR *s)
@ -168,7 +267,7 @@ int NSISCALL myatoi_or(const TCHAR *s)
int NSISCALL popint() int NSISCALL popint()
{ {
TCHAR buf[128]; TCHAR buf[128];
if (popstringn(buf,sizeof(buf))) if (popstringn(buf,_countof(buf)))
return 0; return 0;
return myatoi(buf); return myatoi(buf);
@ -177,7 +276,7 @@ int NSISCALL popint()
int NSISCALL popint_or() int NSISCALL popint_or()
{ {
TCHAR buf[128]; TCHAR buf[128];
if (popstringn(buf,sizeof(buf))) if (popstringn(buf,_countof(buf)))
return 0; return 0;
return myatoi_or(buf); return myatoi_or(buf);

View file

@ -68,12 +68,32 @@ void NSISCALL pushint(int value);
TCHAR * NSISCALL getuservariable(const int varnum); TCHAR * NSISCALL getuservariable(const int varnum);
void NSISCALL setuservariable(const int varnum, const TCHAR *var); void NSISCALL setuservariable(const int varnum, const TCHAR *var);
#ifdef _UNICODE
#define PopStringW(x) popstring(x)
#define PushStringW(x) pushstring(x)
#define SetUserVariableW(x,y) setuservariable(x,y)
int NSISCALL PopStringA(char* ansiStr);
void NSISCALL PushStringA(const char* ansiStr);
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr);
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr);
void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr);
#else
// ANSI defs // ANSI defs
#define PopStringA(x) popstring(x) #define PopStringA(x) popstring(x)
#define PushStringA(x) pushstring(x) #define PushStringA(x) pushstring(x)
#define SetUserVariableA(x,y) setuservariable(x,y) #define SetUserVariableA(x,y) setuservariable(x,y)
int NSISCALL PopStringW(wchar_t* wideStr);
void NSISCALL PushStringW(wchar_t* wideStr);
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr);
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr);
void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -344,19 +344,19 @@ bool WINAPI SaveSettings(void) {
{ {
switch (*p1) { switch (*p1) {
case _T('\t'): case _T('\t'):
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 't'); *p2++ = _T('\\');
p2++; *p2 = _T('t');
break; break;
case _T('\n'): case _T('\n'):
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'n'); *p2++ = _T('\\');
p2++; *p2 = _T('n');
break; break;
case _T('\r'): case _T('\r'):
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'r'); *p2++ = _T('\\');
p2++; *p2 = _T('n');
break; break;
case _T('\\'): case _T('\\'):
*p2++ = '\\'; *p2 = _T('\\');
// Jim Park: used to be p2++ but that's a bug that works because // Jim Park: used to be p2++ but that's a bug that works because
// CharNext()'s behavior at terminating null char. But still // CharNext()'s behavior at terminating null char. But still
// definitely, unsafe. // definitely, unsafe.
@ -672,13 +672,17 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
ULONG eaten; ULONG eaten;
LPITEMIDLIST root; LPITEMIDLIST root;
int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2; int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
SHGetDesktopFolder(&sf);
#ifdef _UNICODE
sf->ParseDisplayName(hConfigWindow, NULL, pField->pszRoot, &eaten, &root, NULL);
#else
LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot); LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot); MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
SHGetDesktopFolder(&sf);
sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL); sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
FREE(pwszRoot);
#endif
bi.pidlRoot = root; bi.pidlRoot = root;
sf->Release(); sf->Release();
FREE(pwszRoot);
} }
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
LPITEMIDLIST pResult = SHBrowseForFolder(&bi); LPITEMIDLIST pResult = SHBrowseForFolder(&bi);
@ -892,7 +896,11 @@ int WINAPI NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM l
{ {
if (OpenClipboard(hWin)) if (OpenClipboard(hWin))
{ {
#ifdef _UNICODE
HGLOBAL hData = GetClipboardData(CF_UNICODETEXT);
#else
HGLOBAL hData = GetClipboardData(CF_TEXT); HGLOBAL hData = GetClipboardData(CF_TEXT);
#endif
if (hData) if (hData)
{ {
@ -1113,7 +1121,7 @@ int WINAPI createCfgDlg()
#undef DEFAULT_STYLES #undef DEFAULT_STYLES
if (pField->nType < 1 || pField->nType > (int)(sizeof(ClassTable) / sizeof(ClassTable[0]))) if (pField->nType < 1 || pField->nType > (int)(_countof(ClassTable)))
continue; continue;
DWORD dwStyle, dwExStyle; DWORD dwStyle, dwExStyle;
@ -1622,41 +1630,38 @@ int WINAPI LookupTokens(TableEntry* psTable_, TCHAR* pszTokens_)
*/ */
void WINAPI ConvertNewLines(TCHAR *str) { void WINAPI ConvertNewLines(TCHAR *str) {
TCHAR *p1, *p2, *p3; TCHAR *p1, *p2, *p3;
TCHAR tch0, tch1, nch;
if (!str) if (!str)
return; return;
p1 = p2 = str; p1 = p2 = str;
while (*p1) while ((tch0 = *p1) != 0)
{ {
switch (*(LPWORD)p1) nch = 0; // new translated char
if (tch0 == _T('\\'))
{ {
case CHAR2_TO_WORD(_T('\\'), _T('t')): tch1 = *(p1+1);
*p2 = _T('\t');
p1 += 2; if (tch1 == _T('t')) nch = _T('\t');
p2++; else if (tch1 == _T('n')) nch = _T('\n');
break; else if (tch1 == _T('r')) nch = _T('\r');
case CHAR2_TO_WORD(_T('\\'), _T('n')): else if (tch1 == _T('\\')) nch = _T('\\');
*p2 = _T('\n'); }
p1 += 2;
p2++; // Was it a special char?
break; if (nch)
case CHAR2_TO_WORD(_T('\\'), _T('r')): {
*p2 = _T('\r'); *p2++ = nch;
p1 += 2; p1 += 2;
p2++; }
break; else
case CHAR2_TO_WORD(_T('\\'), _T('\\')): {
*p2 = _T('\\'); // For MBCS
p1 += 2;
p2++;
break;
default:
p3 = CharNext(p1); p3 = CharNext(p1);
while (p1 < p3) while (p1 < p3)
*p2++ = *p1++; *p2++ = *p1++;
break;
} }
} }

View file

@ -63,11 +63,13 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
continue; continue;
wsprintf(valname, _T("%u.file"), j); wsprintf(valname, _T("%u.file"), j);
l = STR_SIZE; l = (lstrlen(file)+1)*sizeof(TCHAR);
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ) if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
continue; continue;
RegFile(mode[0], file, mode[1] == _T('X')); // JP: Note, if this mode[1] is used as anything but a boolean later on,
// we'll need to consider the next line carefully.
RegFile(mode[0], file, mode[1] == 'X');
} }
} }
@ -208,34 +210,142 @@ void RegTypeLib(TCHAR *file)
} }
} }
TCHAR *mystrstri(TCHAR *a, TCHAR *b) char *mystrstriA(char *a, const char *b)
{ {
int l = lstrlen(b); int l = lstrlenA(b);
while (lstrlen(a) >= l) while (lstrlenA(a) >= l)
{ {
TCHAR c = a[l]; char c = a[l];
a[l] = 0; a[l] = 0;
if (!lstrcmpi(a, b)) if (!lstrcmpiA(a, b))
{ {
a[l] = c; a[l] = c;
return a; return a;
} }
a[l] = c; a[l] = c;
a = CharNext(a); a = CharNextA(a);
} }
return NULL; return NULL;
} }
void mini_memcpy(void *out, const void *in, int len) void mini_memcpy(void *out, const void *in, int len)
{ {
TCHAR *c_out=(TCHAR*)out; char *c_out=(char*)out;
TCHAR *c_in=(TCHAR *)in; char *c_in=(char *)in;
while (len-- > 0) while (len-- > 0)
{ {
*c_out++=*c_in++; *c_out++=*c_in++;
} }
} }
HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
{
int attr = GetFileAttributes(fn);
return CreateFile(
fn,
da,
FILE_SHARE_READ,
NULL,
cd,
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
NULL
);
}
/** Modifies the wininit.ini file to rename / delete a file.
*
* @param prevName The previous / current name of the file.
* @param newName The new name to move the file to. If NULL, the current file
* will be deleted.
*/
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
{
static char szRenameLine[1024];
static TCHAR wininit[1024];
static TCHAR tmpbuf[1024];
int cchRenameLine;
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
HANDLE hfile;
DWORD dwFileSize;
DWORD dwBytes;
DWORD dwRenameLinePos;
char *pszWinInit; // Contains the file contents of wininit.ini
int spn; // length of the short path name in TCHARs.
lstrcpy(tmpbuf, _T("NUL"));
if (newName) {
// create the file if it's not already there to prevent GetShortPathName from failing
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
spn = GetShortPathName(newName,tmpbuf,1024);
if (!spn || spn > 1024)
return;
}
// wininit is used as a temporary here
spn = GetShortPathName(prevName,wininit,1024);
if (!spn || spn > 1024)
return;
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
// Get the path to the wininit.ini file.
GetWindowsDirectory(wininit, 1024-16);
lstrcat(wininit, _T("\\wininit.ini"));
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
if (hfile != INVALID_HANDLE_VALUE)
{
// We are now working on the Windows wininit file
dwFileSize = GetFileSize(hfile, NULL);
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
if (pszWinInit != NULL)
{
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
{
// Look for the rename section in the current file.
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
if (pszRenameSecInFile == NULL)
{
// No rename section. So we add it to the end of file.
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
dwFileSize += 10;
dwRenameLinePos = dwFileSize;
}
else
{
// There is a rename section, but is there another section after it?
char *pszFirstRenameLine = pszRenameSecInFile+10;
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
if (pszNextSec)
{
TCHAR *p = ++pszNextSec;
while (p < pszWinInit + dwFileSize) {
p[cchRenameLine] = *p;
p++;
}
dwRenameLinePos = pszNextSec - pszWinInit;
}
// rename section is last, stick item at end of file
else dwRenameLinePos = dwFileSize;
}
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
dwFileSize += cchRenameLine;
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
GlobalFree(pszWinInit);
}
}
CloseHandle(hfile);
}
}
void DeleteFileOnReboot(TCHAR *pszFile) void DeleteFileOnReboot(TCHAR *pszFile)
{ {
BOOL fOk = 0; BOOL fOk = 0;
@ -253,73 +363,6 @@ void DeleteFileOnReboot(TCHAR *pszFile)
if (!fOk) if (!fOk)
{ {
static TCHAR szRenameLine[1024]; RenameViaWininit(pszFile, NULL);
static TCHAR wininit[1024];
int cchRenameLine;
TCHAR *szRenameSec = _T("[Rename]\r\n");
HANDLE hfile, hfilemap;
DWORD dwFileSize, dwRenameLinePos;
int spn;
// wininit is used as a temporary here
spn = GetShortPathName(pszFile,wininit,1024);
if (!spn || spn > 1024)
return;
cchRenameLine = wsprintf(szRenameLine,_T("NUL=%s\r\n"),wininit);
GetWindowsDirectory(wininit, 1024-16);
lstrcat(wininit, _T("\\wininit.ini"));
hfile = CreateFile(wininit,
GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hfile != INVALID_HANDLE_VALUE)
{
dwFileSize = GetFileSize(hfile, NULL);
hfilemap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, dwFileSize + cchRenameLine + 10, NULL);
if (hfilemap != NULL)
{
LPTSTR pszWinInit = (LPTSTR) MapViewOfFile(hfilemap, FILE_MAP_WRITE, 0, 0, 0);
if (pszWinInit != NULL)
{
LPTSTR pszRenameSecInFile = mystrstri(pszWinInit, szRenameSec);
if (pszRenameSecInFile == NULL)
{
lstrcpy(pszWinInit+dwFileSize, szRenameSec);
dwFileSize += 10;
dwRenameLinePos = dwFileSize;
}
else
{
TCHAR *pszFirstRenameLine = pszRenameSecInFile+10;
TCHAR *pszNextSec = mystrstri(pszFirstRenameLine,_T("\n["));
if (pszNextSec)
{
TCHAR *p = ++pszNextSec;
while (p < pszWinInit + dwFileSize) {
p[cchRenameLine] = *p;
p++;
}
dwRenameLinePos = pszNextSec - pszWinInit;
}
// rename section is last, stick item at end of file
else dwRenameLinePos = dwFileSize;
}
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
dwFileSize += cchRenameLine;
UnmapViewOfFile(pszWinInit);
}
CloseHandle(hfilemap);
}
SetFilePointer(hfile, dwFileSize, NULL, FILE_BEGIN);
SetEndOfFile(hfile);
CloseHandle(hfile);
}
} }
} }

View file

@ -21,11 +21,8 @@ NSISFunction(Register) {
EXDLL_INIT(); EXDLL_INIT();
char filename[1024];
popstring(filename);
wchar_t ole_filename[1024]; wchar_t ole_filename[1024];
MultiByteToWideChar(CP_ACP, 0, filename, 1024, ole_filename, 1024); PopStringW(ole_filename);
ITypeLib* typeLib; ITypeLib* typeLib;
HRESULT hr; HRESULT hr;
@ -46,11 +43,8 @@ NSISFunction(UnRegister) {
EXDLL_INIT(); EXDLL_INIT();
char filename[1024];
popstring(filename);
wchar_t ole_filename[1024]; wchar_t ole_filename[1024];
MultiByteToWideChar(CP_ACP, 0, filename, 1024, ole_filename, 1024); PopStringW(ole_filename);
ITypeLib* typeLib; ITypeLib* typeLib;
HRESULT hr; HRESULT hr;
@ -87,11 +81,8 @@ NSISFunction(GetLibVersion) {
EXDLL_INIT(); EXDLL_INIT();
char filename[1024];
popstring(filename);
wchar_t ole_filename[1024]; wchar_t ole_filename[1024];
MultiByteToWideChar(CP_ACP, 0, filename, 1024, ole_filename, 1024); PopStringW(ole_filename);
ITypeLib* typeLib; ITypeLib* typeLib;
HRESULT hr; HRESULT hr;

View file

@ -218,7 +218,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
GlobalUnlock(hMem); GlobalUnlock(hMem);
if (!OpenClipboard(hwndDlg)) return 0; if (!OpenClipboard(hwndDlg)) return 0;
EmptyClipboard(); EmptyClipboard();
#ifdef _UNICODE
SetClipboardData(CF_UNICODETEXT,hMem);
#else
SetClipboardData(CF_TEXT,hMem); SetClipboardData(CF_TEXT,hMem);
#endif
CloseClipboard(); CloseClipboard();
} }
} }

View file

@ -123,8 +123,8 @@ void UpdateToolBarCompressorButton()
{ {
int iBitmap; int iBitmap;
int iString; int iString;
TCHAR szBuffer[64]; TCHAR szBuffer[124]; // increased to 124 for good measure, also.
TCHAR temp[32]; TCHAR temp[64]; // increased to 64. Hit limit 08/20/2007 -- Jim Park.
TOOLINFO ti; TOOLINFO ti;
my_memset(&ti, 0, sizeof(TOOLINFO)); my_memset(&ti, 0, sizeof(TOOLINFO));
@ -139,14 +139,14 @@ void UpdateToolBarCompressorButton()
LoadString(g_sdata.hInstance, LoadString(g_sdata.hInstance,
IDS_COMPRESSOR, IDS_COMPRESSOR,
temp, temp,
sizeof(temp)); _countof(temp));
my_memset(szBuffer, 0, sizeof(szBuffer)); my_memset(szBuffer, 0, sizeof(szBuffer));
lstrcat(szBuffer,temp); lstrcat(szBuffer,temp);
lstrcat(szBuffer,_T(" [")); lstrcat(szBuffer,_T(" ["));
LoadString(g_sdata.hInstance, LoadString(g_sdata.hInstance,
iString, iString,
temp, temp,
sizeof(temp)); _countof(temp));
lstrcat(szBuffer,temp); lstrcat(szBuffer,temp);
lstrcat(szBuffer,_T("]")); lstrcat(szBuffer,_T("]"));
@ -181,7 +181,7 @@ void AddToolBarButtonTooltip(int id, int iString)
LoadString(g_sdata.hInstance, LoadString(g_sdata.hInstance,
iString, iString,
szBuffer, szBuffer,
sizeof(szBuffer)); _countof(szBuffer));
ti.lpszText = (LPTSTR) szBuffer; ti.lpszText = (LPTSTR) szBuffer;
ti.rect.left =rect.left; ti.rect.left =rect.left;
ti.rect.top = rect.top; ti.rect.top = rect.top;

View file

@ -151,7 +151,11 @@ void CopyToClipboard(HWND hwnd) {
existing_text[0]=0; existing_text[0]=0;
GetDlgItemText(hwnd, IDC_LOGWIN, existing_text, len+1); GetDlgItemText(hwnd, IDC_LOGWIN, existing_text, len+1);
GlobalUnlock(mem); GlobalUnlock(mem);
#ifdef _UNICODE
SetClipboardData(CF_UNICODETEXT,mem);
#else
SetClipboardData(CF_TEXT,mem); SetClipboardData(CF_TEXT,mem);
#endif
CloseClipboard(); CloseClipboard();
} }
@ -295,15 +299,16 @@ void CompileNSISScript() {
TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args); TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args);
g_sdata.compile_command = (char *) GlobalAlloc( size_t byteSize = sizeof(TCHAR)*(
GPTR, /* makensis.exe */ lstrlen(EXENAME) + /* space */ 1 +
/* makensis.exe */ _countof(EXENAME) + /* space */ 1 +
/* script path */ lstrlen(g_sdata.script) + /* space */ 1 + /* script path */ lstrlen(g_sdata.script) + /* space */ 1 +
/* script cmd args */ lstrlen(args) + /* space */ 1 + /* script cmd args */ lstrlen(args) + /* space */ 1 +
/* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 + /* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 +
/* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 + /* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 +
/* /NOTTIFYHWND + HWND */ _countof(_T("/NOTIFYHWND -4294967295")) + /* space */ 1 /* /NOTTIFYHWND + HWND */ _countof(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
); +6); /* for -- \"\" and NULL */
g_sdata.compile_command = (TCHAR *) GlobalAlloc(GPTR, byteSize);
wsprintf( wsprintf(
g_sdata.compile_command, g_sdata.compile_command,
@ -468,9 +473,10 @@ TCHAR** LoadSymbolSet(TCHAR *name)
} }
if(symbols) { if(symbols) {
l++; l++;
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, l*sizeof(TCHAR)); DWORD bytes = sizeof(TCHAR) * l;
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, bytes);
if (symbols[i]) { if (symbols[i]) {
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&l); RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&bytes);
} }
else { else {
break; break;
@ -540,7 +546,10 @@ void SaveSymbolSet(TCHAR *name, TCHAR **symbols)
void ResetObjects() { void ResetObjects() {
if (g_sdata.compile_command) if (g_sdata.compile_command)
{
GlobalFree(g_sdata.compile_command); GlobalFree(g_sdata.compile_command);
g_sdata.compile_command = 0;
}
g_sdata.warnings = FALSE; g_sdata.warnings = FALSE;
g_sdata.retcode = -1; g_sdata.retcode = -1;
@ -565,8 +574,10 @@ void ResetSymbols() {
int InitBranding() { int InitBranding() {
TCHAR *s; TCHAR *s;
s = (TCHAR *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10); TCHAR opt[] = _T(" /version");
wsprintf(s,_T("%s /version"),EXENAME); s = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(EXENAME)+lstrlen(opt)+1)*sizeof(TCHAR));
lstrcpy(s, EXENAME);
lstrcat(s, opt);
{ {
STARTUPINFO si={sizeof(si),}; STARTUPINFO si={sizeof(si),};
SECURITY_ATTRIBUTES sa={sizeof(sa),}; SECURITY_ATTRIBUTES sa={sizeof(sa),};
@ -601,8 +612,8 @@ int InitBranding() {
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) { if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
return 0; return 0;
} }
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL); ReadFile(read_stdout, szBuf, sizeof(szBuf)-sizeof(TCHAR), &dwRead, NULL);
szBuf[dwRead] = 0; szBuf[dwRead/sizeof(TCHAR)] = 0;
if (lstrlen(szBuf)==0) return 0; if (lstrlen(szBuf)==0) return 0;
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+6)*sizeof(TCHAR)); g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+6)*sizeof(TCHAR));
wsprintf(g_sdata.branding,_T("NSIS %s"),szBuf); wsprintf(g_sdata.branding,_T("NSIS %s"),szBuf);
@ -613,6 +624,7 @@ int InitBranding() {
return 1; return 1;
} }
void InitTooltips(HWND h) { void InitTooltips(HWND h) {
if (h == NULL) return; if (h == NULL) return;
my_memset(&g_tip,0,sizeof(NTOOLTIP)); my_memset(&g_tip,0,sizeof(NTOOLTIP));
@ -736,7 +748,6 @@ void PushMRUFile(TCHAR* fname)
{ {
int i; int i;
DWORD rv; DWORD rv;
TCHAR* file_part;
TCHAR full_file_name[MAX_PATH+1]; TCHAR full_file_name[MAX_PATH+1];
if(!fname || fname[0] == _T('\0') || fname[0] == _T('/') || fname[0] == _T('-')) { if(!fname || fname[0] == _T('\0') || fname[0] == _T('/') || fname[0] == _T('-')) {
@ -744,7 +755,7 @@ void PushMRUFile(TCHAR* fname)
} }
my_memset(full_file_name,0,sizeof(full_file_name)); my_memset(full_file_name,0,sizeof(full_file_name));
rv = GetFullPathName(fname,_countof(full_file_name),full_file_name,&file_part); rv = GetFullPathName(fname,_countof(full_file_name),full_file_name,NULL);
if (rv == 0) { if (rv == 0) {
return; return;
} }
@ -897,7 +908,7 @@ void SaveMRUList()
for(i = 0; i < MRU_LIST_SIZE; i++) { for(i = 0; i < MRU_LIST_SIZE; i++) {
wsprintf(buf,_T("%d"),i); wsprintf(buf,_T("%d"),i);
// cbData must include the size of the terminating null character. // cbData must include the size of the terminating null character.
RegSetValueEx(hSubKey,buf,0,REG_SZ,(const BYTE*)g_mru_list[i],(lstrlen(g_mru_list[i]))*sizeof(TCHAR)); RegSetValueEx(hSubKey,buf,0,REG_SZ,(const BYTE*)g_mru_list[i],(lstrlen(g_mru_list[i])+1)*sizeof(TCHAR));
} }
RegCloseKey(hSubKey); RegCloseKey(hSubKey);
} }

View file

@ -13,7 +13,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
{ {
BITMAP bm; BITMAP bm;
RECT vp; RECT vp;
GetObject(g_hbm, sizeof(bm), (LPTSTR)&bm); GetObject(g_hbm, sizeof(bm), &bm);
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);
SetWindowLong(hwnd,GWL_STYLE,0); SetWindowLong(hwnd,GWL_STYLE,0);
SetWindowPos(hwnd,NULL, SetWindowPos(hwnd,NULL,

View file

@ -368,14 +368,10 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND: case WM_COMMAND:
if (LOWORD(wParam) == IDC_DIRLIST && HIWORD(wParam) == LBN_SELCHANGE) if (LOWORD(wParam) == IDC_DIRLIST && HIWORD(wParam) == LBN_SELCHANGE)
{ {
LRESULT selection = SendMessage(hwDirList, LB_GETCURSEL, 0, 0); SendMessage(hwDirList, LB_GETTEXT, SendMessage(hwDirList, LB_GETCURSEL, 0, 0), (WPARAM)buf);
if (selection != LB_ERR) if (autoadd)
{ lstrcat(lstrcat(buf, _T("\\")), progname);
SendMessage(hwDirList, LB_GETTEXT, selection, (WPARAM)buf); SetWindowText(hwLocation, buf);
if (autoadd)
lstrcat(lstrcat(buf, _T("\\")), progname);
SetWindowText(hwLocation, buf);
}
} }
else if (LOWORD(wParam) == IDC_CHECK && HIWORD(wParam) == BN_CLICKED) else if (LOWORD(wParam) == IDC_CHECK && HIWORD(wParam) == BN_CLICKED)
{ {
@ -458,9 +454,9 @@ void AddFolderFromReg(int nFolder)
{ {
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{ {
if (*(WORD*)FileData.cFileName != *(WORD*)_T(".")) if (lstrcmp(FileData.cFileName, _T(".")) != 0)
{ {
if (*(WORD*)FileData.cFileName != *(WORD*)_T("..") || FileData.cFileName[2]) if (lstrcmp(FileData.cFileName, _T("..")) != 0)
{ {
if (SendMessage(g_hwDirList, LB_FINDSTRINGEXACT, (WPARAM) -1, (LPARAM)FileData.cFileName) == LB_ERR) if (SendMessage(g_hwDirList, LB_FINDSTRINGEXACT, (WPARAM) -1, (LPARAM)FileData.cFileName) == LB_ERR)
SendMessage(g_hwDirList, LB_ADDSTRING, 0, (LPARAM)FileData.cFileName); SendMessage(g_hwDirList, LB_ADDSTRING, 0, (LPARAM)FileData.cFileName);

View file

@ -87,6 +87,11 @@ IF 0
.set SYSTEM_LOG_DEBUG,1 .set SYSTEM_LOG_DEBUG,1
#endif #endif
#ifdef _UNICODE
#undef _UNICODE
.set _UNICODE,1
#endif
#define IFDEF .ifdef #define IFDEF .ifdef
#define ELSE .else #define ELSE .else
#define ENDIF .endif #define ENDIF .endif
@ -99,6 +104,7 @@ IF 0
#define DATA_SUFFIX : #define DATA_SUFFIX :
#define BYTE .byte #define BYTE .byte
#define DWORD .int #define DWORD .int
#define WORD .word
#define ASCII .ascii #define ASCII .ascii
#define MACRO_DECL .macro #define MACRO_DECL .macro
@ -140,7 +146,12 @@ EXTERN __alloca_probe : PROC
EXTERN __imp__GlobalFree@4 : PROC EXTERN __imp__GlobalFree@4 : PROC
EXTERN __imp__GetLastError@0 : PROC EXTERN __imp__GetLastError@0 : PROC
IFDEF _UNICODE
EXTERN __imp__wsprintfW : PROC
ELSE
EXTERN __imp__wsprintfA : PROC EXTERN __imp__wsprintfA : PROC
ENDIF
EXTERN _GlobalCopy : PROC EXTERN _GlobalCopy : PROC
@ -181,54 +192,130 @@ SECTION_DATA
IFDEF SYSTEM_LOG_DEBUG IFDEF SYSTEM_LOG_DEBUG
LogStack DATA_SUFFIX ASCII "%s ESP = 0x%08X Stack = 0x%08X Real = 0x%08X" IFDEF _UNICODE
BYTE 0 LogStack DATA_SUFFIX
BYTE '%', 0, 's', 0, ' ', 0, ' ', 0, 'E', 0, 'S', 0, 'P', 0, ' ', 0
BYTE ' ', 0, '0', 0, 'x', 0, '%', 0, '0', 0, '8', 0, 'X', 0, ' ', 0
BYTE 'S', 0, 't', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0, '=', 0, ' ', 0
BYTE 'x', 0, '%', 0, '0', 0, '8', 0, 'X', 0, ' ', 0, ' ', 0, 'R', 0
BYTE 'a', 0, 'l', 0, ' ', 0, '=', 0, ' ', 0, '0', 0, 'x', 0, '%', 0
BYTE '8', 0, 'X', 0
WORD 0
LogCall DATA_SUFFIX BYTE 9,9 LogCall DATA_SUFFIX WORD 9,9
ASCII "Call:" BYTE 'C', 0, 'a', 0, 'l', 0, 'l', 0, ':', 0
BYTE 10,0 WORD 10,0
LogBeforeCall DATA_SUFFIX BYTE 9,9,9 LogBeforeCall DATA_SUFFIX WORD 9,9,9
ASCII "Before call " BYTE 'B', 0, 'e', 0, 'f', 0, 'o', 0, 'r', 0, 'e', 0, ' ', 0, 'c', 0
BYTE 0 BYTE 'l', 0, 'l', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0
BYTE ' ', 0
WORD 0
LogNearCall DATA_SUFFIX BYTE 10,9,9,9 LogNearCall DATA_SUFFIX WORD 10,9,9,9
ASCII "Near call " BYTE 'N', 0, 'e', 0, 'a', 0, 'r', 0, ' ', 0, 'c', 0, 'a', 0, 'l', 0
BYTE 0 BYTE ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0
BYTE ' ', 0
WORD 0
LogBackFrom DATA_SUFFIX BYTE 9 LogBackFrom DATA_SUFFIX WORD 9
ASCII "Back from " BYTE 'B', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0, 'f', 0, 'r', 0, 'o', 0
BYTE 0 BYTE ' ', 0
WORD 0
LogAfterCall DATA_SUFFIX BYTE 10,9,9,9 LogAfterCall DATA_SUFFIX WORD 10,9,9,9
ASCII "After call " BYTE 'A', 0, 'f', 0, 't', 0, 'e', 0, 'r', 0, ' ', 0, 'c', 0, 'a', 0
BYTE 0 BYTE 'l', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0
BYTE ' ', 0
WORD 0
LogReturnAfter DATA_SUFFIX BYTE 10,9,9,9 LogReturnAfter DATA_SUFFIX WORD 10,9,9,9
ASCII "Return 0x%08X 0x%08X" BYTE 'R', 0, 'e', 0, 't', 0, 'u', 0, 'r', 0, 'n', 0, ' ', 0, ' ', 0
BYTE 0 BYTE ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0
BYTE ' ', 0, ' ', 0, ' ', 0, '0', 0, 'x', 0, '%', 0, '0', 0, '8', 0
BYTE ' ', 0, ' ', 0, ' ', 0, ' ', 0, '0', 0, 'x', 0, '%', 0, '0', 0
BYTE 'X', 0
WORD 0
LogCalled DATA_SUFFIX ASCII "Called callback from " LogCalled DATA_SUFFIX
BYTE 0 BYTE 'C', 0, 'a', 0, 'l', 0, 'l', 0, 'e', 0, 'd', 0, ' ', 0, 'c', 0
BYTE 'l', 0, 'l', 0, 'b', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0, 'f', 0
BYTE 'o', 0, 'm', 0, ' ', 0
WORD 0
LogShortAfter DATA_SUFFIX BYTE 10,9,9,9 LogShortAfter DATA_SUFFIX WORD 10,9,9,9
ASCII "Short-After call " BYTE 'S', 0, 'h', 0, 'o', 0, 'r', 0, 't', 0, '-', 0, 'A', 0, 'f', 0
BYTE 0 BYTE 'e', 0, 'r', 0, ' ', 0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, ' ', 0
BYTE ' ', 0
WORD 0
LogReturn DATA_SUFFIX BYTE 9,9 LogReturn DATA_SUFFIX WORD 9,9
ASCII "Return from callback:" BYTE 'R', 0, 'e', 0, 't', 0, 'u', 0, 'r', 0, 'n', 0, ' ', 0, 'f', 0
BYTE 10,0 BYTE 'o', 0, 'm', 0, ' ', 0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, 'b', 0
BYTE 'c', 0, 'k', 0, ':', 0
WORD 10,0
LogBefore DATA_SUFFIX BYTE 9,9,9 LogBefore DATA_SUFFIX WORD 9,9,9
ASCII "Before call-back " BYTE 'B', 0, 'e', 0, 'f', 0, 'o', 0, 'r', 0, 'e', 0, ' ', 0, 'c', 0
BYTE 0 BYTE 'l', 0, 'l', 0, '-', 0, 'b', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0
BYTE ' ', 0
WORD 0
LogShortBefore DATA_SUFFIX BYTE 10,9,9,9 LogShortBefore DATA_SUFFIX WORD 10,9,9,9
ASCII "Sh-Before call-back" BYTE 'S', 0, 'h', 0, '-', 0, 'B', 0, 'e', 0, 'f', 0, 'o', 0, 'r', 0
BYTE 0 BYTE ' ', 0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, '-', 0, 'b', 0, 'a', 0
BYTE 'k', 0
WORD 0
LogLF DATA_SUFFIX WORD 10,0
ELSE
LogStack DATA_SUFFIX ASCII "%s ESP = 0x%08X Stack = 0x%08X Real = 0x%08X"
BYTE 0
LogLF DATA_SUFFIX BYTE 10,0 LogCall DATA_SUFFIX BYTE 9,9
ASCII "Call:"
BYTE 10,0
LogBeforeCall DATA_SUFFIX BYTE 9,9,9
ASCII "Before call "
BYTE 0
LogNearCall DATA_SUFFIX BYTE 10,9,9,9
ASCII "Near call "
BYTE 0
LogBackFrom DATA_SUFFIX BYTE 9
ASCII "Back from "
BYTE 0
LogAfterCall DATA_SUFFIX BYTE 10,9,9,9
ASCII "After call "
BYTE 0
LogReturnAfter DATA_SUFFIX BYTE 10,9,9,9
ASCII "Return 0x%08X 0x%08X"
BYTE 0
LogCalled DATA_SUFFIX ASCII "Called callback from "
BYTE 0
LogShortAfter DATA_SUFFIX BYTE 10,9,9,9
ASCII "Short-After call "
BYTE 0
LogReturn DATA_SUFFIX BYTE 9,9
ASCII "Return from callback:"
BYTE 10,0
LogBefore DATA_SUFFIX BYTE 9,9,9
ASCII "Before call-back "
BYTE 0
LogShortBefore DATA_SUFFIX BYTE 10,9,9,9
ASCII "Sh-Before call-back"
BYTE 0
LogLF DATA_SUFFIX BYTE 10,0
ENDIF
ENDIF ENDIF
SECTION_CODE SECTION_CODE
@ -263,7 +350,11 @@ ELSE
ENDIF ENDIF
;# Log buffer ;# Log buffer
push edi push edi
IFDEF _UNICODE
call dword ptr [__imp__wsprintfW]
ELSE
call dword ptr [__imp__wsprintfA] call dword ptr [__imp__wsprintfA]
ENDIF
;# If wsprintf succeeds then advance edi by number of bytes ;# If wsprintf succeeds then advance edi by number of bytes
;# written to buffer ;# written to buffer
cmp eax,0 cmp eax,0

View file

@ -151,18 +151,21 @@ void system_pushint(int value)
system_pushstring(buffer); system_pushstring(buffer);
} }
TCHAR *copymem(TCHAR *output, TCHAR *input, int size) void *copymem(void *output, void *input, size_t cbSize)
{ {
TCHAR *out = output; BYTE *out = (BYTE*) output;
if ((input != NULL) && (output != NULL)) BYTE *in = (BYTE*) input;
while (size-- > 0) *(out++) = *(input++); if ((input != NULL) && (output != NULL))
return output; {
while (cbSize-- > 0) *(out++) = *(in++);
}
return output;
} }
HANDLE GlobalCopy(HANDLE Old) HANDLE GlobalCopy(HANDLE Old)
{ {
SIZE_T size = GlobalSize(Old); size_t size = GlobalSize(Old);
return copymem(GlobalAlloc(GPTR, size), Old, (int) size); return copymem(GlobalAlloc(GPTR, size), Old, size);
} }
UINT_PTR NSISCallback(enum NSPIM msg) UINT_PTR NSISCallback(enum NSPIM msg)

View file

@ -27,7 +27,7 @@ extern int popint64(); // -1 -> stack empty
extern void system_pushint(int value); extern void system_pushint(int value);
extern HANDLE GlobalCopy(HANDLE Old); extern HANDLE GlobalCopy(HANDLE Old);
extern TCHAR *copymem(TCHAR *output, TCHAR *input, int size); extern void *copymem(void *output, void *input, size_t cbSize);
extern UINT_PTR NSISCallback(enum NSPIM); extern UINT_PTR NSISCallback(enum NSPIM);

View file

@ -46,7 +46,7 @@ CallbackThunk* CallbackThunkListHead;
HINSTANCE g_hInstance; HINSTANCE g_hInstance;
// Return to callback caller with stack restore // Return to callback caller with stack restore
TCHAR retexpr[4]; char retexpr[4];
HANDLE retaddr; HANDLE retaddr;
TCHAR *GetResultStr(SystemProc *proc) TCHAR *GetResultStr(SystemProc *proc)
@ -61,7 +61,7 @@ TCHAR *GetResultStr(SystemProc *proc)
#ifdef SYSTEM_LOG_DEBUG #ifdef SYSTEM_LOG_DEBUG
// System log debugging turned on // System log debugging turned on
#define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, sizeof(syslogbuf) - _len); } #define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, _countof(syslogbuf) - _len); }
#define SYSTEM_LOG_POST { SYSTEM_LOG_ADD(_T("\n")); WriteToLog(syslogbuf); *syslogbuf = 0; } #define SYSTEM_LOG_POST { SYSTEM_LOG_ADD(_T("\n")); WriteToLog(syslogbuf); *syslogbuf = 0; }
HANDLE logfile = NULL; HANDLE logfile = NULL;
@ -82,11 +82,18 @@ void WriteToLog(TCHAR *buffer)
wsprintf(timebuffer, _T("%04d %04d.%03d "), (++logop)%10000, (GetTickCount() / 1000) % 10000, wsprintf(timebuffer, _T("%04d %04d.%03d "), (++logop)%10000, (GetTickCount() / 1000) % 10000,
GetTickCount() % 1000); GetTickCount() % 1000);
#ifdef _UNICODE
#ifdef _RPTW0
_RPTW0(_CRT_WARN, timebuffer);
_RPTW0(_CRT_WARN, buffer);
#endif
#else
_RPT0(_CRT_WARN, timebuffer); _RPT0(_CRT_WARN, timebuffer);
_RPT0(_CRT_WARN, buffer); _RPT0(_CRT_WARN, buffer);
#endif
WriteFile(logfile, timebuffer, lstrlen(timebuffer), &written, NULL); WriteFile(logfile, timebuffer, lstrlen(timebuffer)*sizeof(TCHAR), &written, NULL);
WriteFile(logfile, buffer, lstrlen(buffer), &written, NULL); WriteFile(logfile, buffer, lstrlen(buffer)*sizeof(TCHAR), &written, NULL);
// FlushFileBuffers(logfile); // FlushFileBuffers(logfile);
} }
@ -108,10 +115,17 @@ PLUGINFUNCTION(Debug)
SetFilePointer(logfile, 0, 0, FILE_END); SetFilePointer(logfile, 0, 0, FILE_END);
logop = 0; logop = 0;
#ifdef _UNICODE
{ // write Unicode Byte-Order Mark
DWORD written;
unsigned short bom = 0xfeff;
WriteFile(logfile, &bom, 2, &written, NULL);
}
#endif
GetLocalTime(&t); GetLocalTime(&t);
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, buftime, 1024); GetTimeFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, buftime, 1024);
GetDateFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, bufdate, 1024); GetDateFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, bufdate, 1024);
wsprintf(buffer, _T("System, %s %s [build "__TIME__" ")__DATE___T("]\n"), buftime, bufdate); wsprintf(buffer, _T("System, %s %s [build ") __TTIME__ _T(" ") __TDATE__ _T("]\n"), buftime, bufdate);
WriteToLog(buffer); WriteToLog(buffer);
} else ; } else ;
else else
@ -543,9 +557,9 @@ SystemProc *PrepareProc(BOOL NeedForCall)
case _T('l'): case _T('l'):
case _T('L'): temp2 = PAT_LONG; break; case _T('L'): temp2 = PAT_LONG; break;
case _T('m'): case _T('m'):
case _T('M'): case _T('M'): temp2 = PAT_STRING; break;
case _T('t'): case _T('t'):
case _T('T'): temp2 = PAT_STRING; break; case _T('T'): temp2 = PAT_STRING; break; // will be PAT_WSTRING for Unicode NSIS
case _T('g'): case _T('g'):
case _T('G'): temp2 = PAT_GUID; break; case _T('G'): temp2 = PAT_GUID; break;
case _T('w'): case _T('w'):
@ -705,7 +719,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
// Use direct system proc address // Use direct system proc address
int addr; int addr;
proc->Dll = (HANDLE) INT_TO_POINTER(myatoi64(proc->DllName)); proc->Dll = (HMODULE) INT_TO_POINTER(myatoi64(proc->DllName));
if (proc->Dll == 0) if (proc->Dll == 0)
{ {
@ -749,8 +763,13 @@ SystemProc *PrepareProc(BOOL NeedForCall)
// Get proc address // Get proc address
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL) if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
{ {
#ifdef _UNICODE
// automatic W discover
lstrcat(proc->ProcName, _T("W"));
#else
// automatic A discover // automatic A discover
lstrcat(proc->ProcName, _T("A")); lstrcat(proc->ProcName, "A");
#endif
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL) if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
proc->ProcResult = PR_ERROR; proc->ProcResult = PR_ERROR;
} }
@ -826,7 +845,7 @@ void ParamsIn(SystemProc *proc)
break; break;
case PAT_WSTRING: case PAT_WSTRING:
case PAT_GUID: case PAT_GUID:
wstr = (LPWSTR) (par->allocatedBlock = GlobalAlloc(GPTR, g_stringsize*2)); wstr = (LPWSTR) (par->allocatedBlock = GlobalAlloc(GPTR, g_stringsize*sizeof(WCHAR)));
MultiByteToWideChar(CP_ACP, 0, realbuf, g_stringsize, wstr, g_stringsize); MultiByteToWideChar(CP_ACP, 0, realbuf, g_stringsize, wstr, g_stringsize);
if (par->Type == PAT_GUID) if (par->Type == PAT_GUID)
{ {
@ -900,7 +919,7 @@ void ParamsOut(SystemProc *proc)
break; break;
case PAT_STRING: case PAT_STRING:
{ {
unsigned num = lstrlen(*((TCHAR**) place)); unsigned int num = lstrlen(*((TCHAR**) place));
if (num >= g_stringsize) num = g_stringsize-1; if (num >= g_stringsize) num = g_stringsize-1;
lstrcpyn(realbuf,*((TCHAR**) place), num+1); lstrcpyn(realbuf,*((TCHAR**) place), num+1);
realbuf[num] = 0; realbuf[num] = 0;
@ -908,7 +927,7 @@ void ParamsOut(SystemProc *proc)
break; break;
case PAT_GUID: case PAT_GUID:
wstr = (LPWSTR) GlobalAlloc(GPTR, g_stringsize*2); wstr = (LPWSTR) GlobalAlloc(GPTR, g_stringsize*2);
StringFromGUID2(*((REFGUID*)place), wstr, g_stringsize*2); StringFromGUID2(*((REFGUID*)place), wstr, g_stringsize);
WideCharToMultiByte(CP_ACP, 0, wstr, g_stringsize, realbuf, g_stringsize, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, wstr, g_stringsize, realbuf, g_stringsize, NULL, NULL);
GlobalFree((HGLOBAL)wstr); GlobalFree((HGLOBAL)wstr);
break; break;
@ -942,7 +961,6 @@ HANDLE CreateCallback(SystemProc *cbproc)
{ {
char *mem; char *mem;
if (cbproc->Proc == NULL) if (cbproc->Proc == NULL)
{ {
// Set callback index // Set callback index
@ -975,7 +993,7 @@ void CallStruct(SystemProc *proc)
{ {
BOOL ssflag; BOOL ssflag;
int i, structsize = 0, size = 0; int i, structsize = 0, size = 0;
TCHAR *st, *ptr; char *st, *ptr;
SYSTEM_LOG_ADD(_T("\t\tStruct...")); SYSTEM_LOG_ADD(_T("\t\tStruct..."));
@ -994,7 +1012,7 @@ void CallStruct(SystemProc *proc)
if (structsize == 0) structsize = (int) GlobalSize((HANDLE) proc->Proc); if (structsize == 0) structsize = (int) GlobalSize((HANDLE) proc->Proc);
// Pointer to current data // Pointer to current data
st = (TCHAR*) proc->Proc; st = (char*) proc->Proc;
for (i = 1; i <= proc->ParamCount; i++) for (i = 1; i <= proc->ParamCount; i++)
{ {
@ -1005,7 +1023,7 @@ void CallStruct(SystemProc *proc)
{ {
// Normal // Normal
size = proc->Params[i].Size*4; size = proc->Params[i].Size*4;
ptr = (TCHAR*) &(proc->Params[i].Value); ptr = (char*) &(proc->Params[i].Value);
} }
else else
{ {
@ -1026,13 +1044,14 @@ void CallStruct(SystemProc *proc)
// clear unused value bits // clear unused value bits
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)]; proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
// pointer // pointer
ptr = (TCHAR*) &(proc->Params[i].Value); ptr = (char*) &(proc->Params[i].Value);
break; break;
case PAT_STRING: case PAT_STRING:
case PAT_GUID: case PAT_GUID:
case PAT_WSTRING: case PAT_WSTRING:
ptr = (TCHAR*) proc->Params[i].Value; break; // Jim Park: Pointer for memcopy, so keep as char*
ptr = (char*) proc->Params[i].Value; break;
} }
} }
@ -1071,7 +1090,7 @@ the same means as used for the _RPT0 macro. This leads to an endless recursion.
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{ {
g_hInstance=hInst; g_hInstance=(HINSTANCE)hInst;
if (ul_reason_for_call == DLL_PROCESS_ATTACH) if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{ {
@ -1084,7 +1103,6 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
LastError = 0; LastError = 0;
LastProc = NULL; LastProc = NULL;
CallbackIndex = 0; CallbackIndex = 0;
retexpr[0] = (char) 0xC2;
CallbackThunkListHead = NULL; CallbackThunkListHead = NULL;
retexpr[0] = (char) 0xC2; retexpr[0] = (char) 0xC2;
retexpr[2] = 0x00; retexpr[2] = 0x00;
@ -1181,7 +1199,6 @@ unsigned int GetSizeOfProcParam(void)
return (sizeof(ProcParameter)); return (sizeof(ProcParameter));
} }
/* /*
Returns offset for element Size of ProcParameter structure Returns offset for element Size of ProcParameter structure
*/ */

View file

@ -87,11 +87,10 @@ struct tag_SystemProc
int ProcResult; int ProcResult;
TCHAR DllName[1024]; TCHAR DllName[1024];
TCHAR ProcName[1024]; TCHAR ProcName[1024];
HANDLE Dll; HMODULE Dll;
HANDLE Proc; HANDLE Proc;
int Options; int Options;
int ParamCount; int ParamCount;
// if you'll change ProcParameter or SystemProc structure - update SYSTEM_ZERO_PARAM_VALUE_OFFSET value
ProcParameter Params[100]; // I hope nobody will use more than 100 params ProcParameter Params[100]; // I hope nobody will use more than 100 params
// Callback specific // Callback specific

View file

@ -21,16 +21,18 @@ void __declspec(dllexport) GetName(HWND hwndParent, int string_size,
} }
} }
TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
{
TCHAR *group = NULL;
HANDLE hToken = NULL;
struct group struct group
{ {
DWORD auth_id; DWORD auth_id;
TCHAR *name; TCHAR *name;
}; };
// Jim Park: Moved this array from inside the func to the outside. While it
// was probably "safe" for this array to be inside because the strings are in
// the .data section and so the pointer to the string returned is probably
// safe, this is a bad practice to have as that's making an assumption on what
// the compiler will do. Besides which, other types of data returned would
// actually fail as the local vars would be popped off the stack.
struct group groups[] = struct group groups[] =
{ {
{DOMAIN_ALIAS_RID_USERS, _T("User")}, {DOMAIN_ALIAS_RID_USERS, _T("User")},
@ -40,6 +42,12 @@ struct group groups[] =
{DOMAIN_ALIAS_RID_ADMINS, _T("Admin")} {DOMAIN_ALIAS_RID_ADMINS, _T("Admin")}
}; };
TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
{
TCHAR *group = NULL;
HANDLE hToken = NULL;
if (GetVersion() & 0x80000000) // Not NT if (GetVersion() & 0x80000000) // Not NT
{ {
return _T("Admin"); return _T("Admin");

View file

@ -202,7 +202,7 @@ int _tmain( int argc, TCHAR * argv[] ) {
} catch(const TCHAR* s) { } catch(const TCHAR* s) {
terr << _T("ERROR: ") << s << _T("\n"); terr << _T("ERROR: ") << s << _T("\n");
patch.close(); patch.close();
unlink(tempFileName.c_str()); _tunlink(tempFileName.c_str());
return 3; return 3;
} }
@ -299,6 +299,6 @@ int _tmain( int argc, TCHAR * argv[] ) {
terr << _T("WARNING: source and target file have equal CRCs!"); terr << _T("WARNING: source and target file have equal CRCs!");
delete sourceCRC; delete sourceCRC;
delete targetCRC; delete targetCRC;
unlink(tempFileName.c_str()); _tunlink(tempFileName.c_str());
return 0; return 0;
} }

View file

@ -156,6 +156,10 @@ void ExecScript(int log) {
IMAGE_FILE_LINE_NUMS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE; IMAGE_FILE_LINE_NUMS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE;
// Windows character-mode user interface (CUI) subsystem. // Windows character-mode user interface (CUI) subsystem.
pNTHeaders->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI; pNTHeaders->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
// g_hInst is assumed to be the very base of the DLL in memory.
// WinMain will have the address of the WinMain function in memory.
// Getting the difference gets you the relative location of the
// WinMain function.
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD)_tWinMain - (DWORD)g_hInst; pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD)_tWinMain - (DWORD)g_hInst;
UnmapViewOfFile(pMapView); UnmapViewOfFile(pMapView);
} }
@ -278,10 +282,10 @@ params:
szBuf[dwRead] = 0; szBuf[dwRead] = 0;
if (log) { if (log) {
TCHAR *p, *p2; TCHAR *p, *p2;
SIZE_T iReqLen = lstrlen(szBuf) + lstrlen(szUnusedBuf); SIZE_T iReqLen = lstrlen(szBuf) + lstrlen(szUnusedBuf) + 1;
if (GlobalSize(hUnusedBuf) < iReqLen && (iReqLen < g_stringsize || !(log & 2))) { if (GlobalSize(hUnusedBuf) < iReqLen*sizeof(TCHAR) && (iReqLen < g_stringsize || !(log & 2))) {
GlobalUnlock(hUnusedBuf); GlobalUnlock(hUnusedBuf);
hUnusedBuf = GlobalReAlloc(hUnusedBuf, iReqLen+sizeof(szBuf), GHND); hUnusedBuf = GlobalReAlloc(hUnusedBuf, iReqLen*sizeof(TCHAR)+sizeof(szBuf), GHND);
if (!hUnusedBuf) { if (!hUnusedBuf) {
lstrcpy(szRet, _T("error")); lstrcpy(szRet, _T("error"));
break; break;
@ -289,14 +293,16 @@ params:
szUnusedBuf = (TCHAR *)GlobalLock(hUnusedBuf); szUnusedBuf = (TCHAR *)GlobalLock(hUnusedBuf);
} }
p = szUnusedBuf; // get the old left overs p = szUnusedBuf; // get the old left overs
if (iReqLen < g_stringsize || !(log & 2)) lstrcat(p, szBuf); if (iReqLen < g_stringsize || !(log & 2)) {
lstrcat(p, szBuf);
}
else { else {
lstrcpyn(p + lstrlen(p), szBuf, g_stringsize - lstrlen(p)); lstrcpyn(p + lstrlen(p), szBuf, g_stringsize - lstrlen(p));
} }
if (!(log & 2)) { if (!(log & 2)) {
while ((p = my_strstr(p, _T("\t")))) { while ((p = my_strstr(p, _T("\t")))) {
if ((int)(p - szUnusedBuf) > (int)(GlobalSize(hUnusedBuf) - TAB_REPLACE_SIZE - 1)) if ((int)(p - szUnusedBuf) > (int)(GlobalSize(hUnusedBuf)/sizeof(TCHAR) - TAB_REPLACE_SIZE - 1))
{ {
*p++ = _T(' '); *p++ = _T(' ');
} }
@ -381,7 +387,9 @@ void LogMessage(const TCHAR *pStr, BOOL bOEM) {
int nItemCount; int nItemCount;
if (!g_hwndList) return; if (!g_hwndList) return;
//if (!lstrlen(pStr)) return; //if (!lstrlen(pStr)) return;
if (bOEM == TRUE) OemToCharBuff(pStr, (TCHAR *)pStr, lstrlen(pStr)); #ifndef _UNICODE
if (bOEM == TRUE) OemToCharBuff(pStr, (char*)pStr, lstrlen(pStr));
#endif
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0); nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
item.mask=LVIF_TEXT; item.mask=LVIF_TEXT;
item.pszText=(TCHAR *)pStr; item.pszText=(TCHAR *)pStr;

View file

@ -71,7 +71,6 @@ TCHAR *g_options=_T("");//_T("/V3");
static BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
LPTSTR lpszCmdParam, int nCmdShow) LPTSTR lpszCmdParam, int nCmdShow)
{ {
@ -752,7 +751,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_HIDE);
{ {
for (size_t x = 0; x < sizeof(ids)/sizeof(ids[0]); x ++) for (size_t x = 0; x < _countof(ids); x ++)
ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_SHOWNA); ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_SHOWNA);
SetDlgItemText(hwndDlg,IDOK,_T("&Generate")); SetDlgItemText(hwndDlg,IDOK,_T("&Generate"));
EnableWindow(GetDlgItem(hwndDlg,IDOK),1); EnableWindow(GetDlgItem(hwndDlg,IDOK),1);
@ -783,7 +782,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
g_compressor_solid = 0; g_compressor_solid = 0;
g_mui=!IsDlgButtonChecked(hwndDlg,IDC_CLASSICUI); g_mui=!IsDlgButtonChecked(hwndDlg,IDC_CLASSICUI);
SetDlgItemText(g_hwnd, IDC_OUTPUTTEXT, _T("")); SetDlgItemText(g_hwnd, IDC_OUTPUTTEXT, _T(""));
for (size_t x = 0; x < sizeof(ids)/sizeof(ids[0]); x ++) for (size_t x = 0; x < _countof(ids); x ++)
ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_SHOWNA); ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_SHOWNA);
SetDlgItemText(hwndDlg,IDOK,_T("&Close")); SetDlgItemText(hwndDlg,IDOK,_T("&Close"));

View file

@ -351,7 +351,7 @@ HRESULT CEncoder::Create()
static int FindMatchFinder(const wchar_t *s) static int FindMatchFinder(const wchar_t *s)
{ {
for (int m = 0; m < (int)(sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0])); m++) for (int m = 0; m < (int)(_countof(kMatchFinderIDs)); m++)
if (AreStringsEqual(kMatchFinderIDs[m], s)) if (AreStringsEqual(kMatchFinderIDs[m], s))
return m; return m;
return -1; return -1;

View file

@ -436,12 +436,6 @@ void CDialogTemplate::ConvertToRTL() {
for (unsigned int i = 0; i < m_vItems.size(); i++) { for (unsigned int i = 0; i < m_vItems.size(); i++) {
bool addExStyle = false; bool addExStyle = false;
bool addExLeftScrollbar = true; bool addExLeftScrollbar = true;
char *szClass;
if (IS_INTRESOURCE(m_vItems[i]->szClass))
szClass = (char *) m_vItems[i]->szClass;
else
szClass = winchar_toansi(m_vItems[i]->szClass);
// Button // Button
if ((ULONG_PTR)(m_vItems[i]->szClass) == 0x80) { if ((ULONG_PTR)(m_vItems[i]->szClass) == 0x80) {
@ -474,18 +468,18 @@ void CDialogTemplate::ConvertToRTL() {
m_vItems[i]->dwStyle |= SS_CENTERIMAGE; m_vItems[i]->dwStyle |= SS_CENTERIMAGE;
} }
} }
else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !stricmp(szClass, "RichEdit20A")) { else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsicmp(m_vItems[i]->szClass, L"RichEdit20A")) {
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) && !stricmp(szClass, "SysTreeView32")) { else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsicmp(m_vItems[i]->szClass, L"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) && !stricmp(szClass, "SysListView32")) { else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !_wcsicmp(m_vItems[i]->szClass, L"SysListView32")) {
m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL; m_vItems[i]->dwExtStyle |= WS_EX_LAYOUTRTL;
addExLeftScrollbar = false; addExLeftScrollbar = false;
} }
@ -499,9 +493,6 @@ void CDialogTemplate::ConvertToRTL() {
m_vItems[i]->dwExtStyle |= WS_EX_RTLREADING; m_vItems[i]->dwExtStyle |= WS_EX_RTLREADING;
m_vItems[i]->sX = m_sWidth - m_vItems[i]->sWidth - m_vItems[i]->sX; m_vItems[i]->sX = m_sWidth - m_vItems[i]->sWidth - m_vItems[i]->sX;
if (!IS_INTRESOURCE(m_vItems[i]->szClass))
delete [] szClass;
} }
m_dwExtStyle |= WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR; m_dwExtStyle |= WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR;
} }

View file

@ -76,7 +76,9 @@ size_t file_size(ifstream& file) {
return (size_t)result; return (size_t)result;
} }
vector<unsigned char> read_file(const string& filename) { // This function slurps the whole file into the vector.
// Modified so the huge vector isn't returned by value.
void read_file(const tstring& filename, vector<unsigned char>& data) {
ifstream file(filename.c_str(), ios::binary); ifstream file(filename.c_str(), ios::binary);
if (!file) { if (!file) {
@ -86,16 +88,13 @@ vector<unsigned char> read_file(const string& filename) {
// get the file size // get the file size
size_t filesize = file_size(file); size_t filesize = file_size(file);
vector<unsigned char> result; data.resize(filesize);
result.resize(filesize);
file.read(reinterpret_cast<TCHAR*>(&result[0]), filesize); file.read(reinterpret_cast<char*>(&data[0]), filesize);
if (size_t(file.tellg()) != filesize) { // ifstream::eof doesn't return true here if (size_t(file.tellg()) != filesize) { // ifstream::eof doesn't return true here
throw NSISException("Couldn't read entire file '" + filename + "'"); throw NSISException("Couldn't read entire file '" + filename + "'");
} }
return result;
} }
} }
@ -104,7 +103,7 @@ void Plugins::GetExports(const tstring &pathToDll, bool displayInfo)
vector<unsigned char> dlldata; vector<unsigned char> dlldata;
PIMAGE_NT_HEADERS NTHeaders; PIMAGE_NT_HEADERS NTHeaders;
try { try {
dlldata = read_file(pathToDll); read_file(pathToDll, dlldata);
NTHeaders = CResourceEditor::GetNTHeaders(&dlldata[0]); NTHeaders = CResourceEditor::GetNTHeaders(&dlldata[0]);
} catch (std::runtime_error&) { } catch (std::runtime_error&) {
return; return;

View file

@ -201,9 +201,7 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
WCHAR *KeyName, *KeyValue; WCHAR *KeyName, *KeyValue;
strm.resize(0); strm.resize(0);
KeyName = winchar_fromansi(_T("VS_VERSION_INFO")); SaveVersionHeader (strm, 0, sizeof (VS_FIXEDFILEINFO), 0, L"VS_VERSION_INFO", &m_FixedInfo);
SaveVersionHeader (strm, 0, sizeof (VS_FIXEDFILEINFO), 0, KeyName, &m_FixedInfo);
delete [] KeyName;
DefineList *pChildStrings = m_ChildStringLists.get_strings(Index); DefineList *pChildStrings = m_ChildStringLists.get_strings(Index);
if ( pChildStrings->getnum() > 0 ) if ( pChildStrings->getnum() > 0 )
@ -211,11 +209,9 @@ 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);
TCHAR Buff[16]; WCHAR Buff[16];
sprintf(Buff, _T("%04x%04x"), langid, codepage); swprintf(Buff, _countof(Buff), L"%04x%04x", langid, codepage);
KeyName = winchar_fromansi(Buff, CP_ACP); SaveVersionHeader (stringInfoStream, 0, 0, 0, Buff, &ZEROS);
SaveVersionHeader (stringInfoStream, 0, 0, 0, KeyName, &ZEROS);
delete [] KeyName;
for ( int i = 0; i < pChildStrings->getnum(); i++ ) for ( int i = 0; i < pChildStrings->getnum(); i++ )
{ {
@ -237,9 +233,7 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
PadStream (strm); PadStream (strm);
p = strm.getlen(); p = strm.getlen();
KeyName = winchar_fromansi(_T("StringFileInfo"), CP_ACP); SaveVersionHeader (strm, 0, 0, 0, L"StringFileInfo", &ZEROS);
SaveVersionHeader (strm, 0, 0, 0, KeyName, &ZEROS);
delete [] KeyName;
strm.add (stringInfoStream.get(), stringInfoStream.getlen()); strm.add (stringInfoStream.get(), stringInfoStream.getlen());
wSize = WORD(strm.getlen() - p); wSize = WORD(strm.getlen() - p);
@ -251,15 +245,11 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
{ {
PadStream (strm); PadStream (strm);
p = strm.getlen(); p = strm.getlen();
KeyName = winchar_fromansi(_T("VarFileInfo"), CP_ACP); SaveVersionHeader (strm, 0, 0, 0, L"VarFileInfo", &ZEROS);
SaveVersionHeader (strm, 0, 0, 0, KeyName, &ZEROS);
delete [] KeyName;
PadStream (strm); PadStream (strm);
p1 = strm.getlen(); p1 = strm.getlen();
KeyName = winchar_fromansi(_T("Translation"), CP_ACP); SaveVersionHeader (strm, 0, 0, 0, L"Translation", &ZEROS);
SaveVersionHeader (strm, 0, 0, 0, KeyName, &ZEROS);
delete [] KeyName;
// 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));

View file

@ -76,6 +76,8 @@ TCHAR* ConstantsStringList::idx2name(int idx)
int ConstantsStringList::get_internal_idx(int idx) int ConstantsStringList::get_internal_idx(int idx)
{ {
struct constantstring *data=(struct constantstring *)gr.get(); struct constantstring *data=(struct constantstring *)gr.get();
// We do a linear search because the strings are sorted.
for (int i = 0; i < index; i++) for (int i = 0; i < index; i++)
{ {
if (data[i].index == idx) if (data[i].index == idx)

View file

@ -16,6 +16,7 @@
* Unicode support added by Jim Park -- 08/07/2007 * Unicode support added by Jim Park -- 08/07/2007
*/ */
#include "tchar.h"
#include "Platform.h" #include "Platform.h"
#include <stdio.h> #include <stdio.h>
#include "exehead/config.h" #include "exehead/config.h"
@ -114,6 +115,13 @@ CEXEBuild::CEXEBuild() :
definedlist.add(_T("NSIS_VERSION"), NSIS_VERSION); definedlist.add(_T("NSIS_VERSION"), NSIS_VERSION);
#ifdef _UNICODE
definedlist.add(_T("NSIS_UNICODE"));
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("2"));
#else
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1"));
#endif
// automatically generated header file containing all defines // automatically generated header file containing all defines
#include <nsis-defines.h> #include <nsis-defines.h>
@ -286,12 +294,12 @@ CEXEBuild::CEXEBuild() :
int i; int i;
for (i = 0; i < 10; i++) // 0 - 9 for (i = 0; i < 10; i++) // 0 - 9
{ {
sprintf(Aux, _T("%d"), i); wsprintf(Aux, _T("%d"), i);
m_UserVarNames.add(Aux,1); m_UserVarNames.add(Aux,1);
} }
for (i = 0; i < 10; i++) // 10 - 19 for (i = 0; i < 10; i++) // 10 - 19
{ {
sprintf(Aux, _T("R%d"), i); wsprintf(Aux, _T("R%d"), i);
m_UserVarNames.add(Aux,1); m_UserVarNames.add(Aux,1);
} }
m_UserVarNames.add(_T("CMDLINE"),1); // 20 everything before here doesn't have trailing slash removal m_UserVarNames.add(_T("CMDLINE"),1); // 20 everything before here doesn't have trailing slash removal
@ -450,7 +458,7 @@ int CEXEBuild::add_string(const TCHAR *string, int process/*=1*/, WORD codepage/
if (*string == _T('$') && *(string+1) == _T('(')) { if (*string == _T('$') && *(string+1) == _T('(')) {
int idx = 0; int idx = 0;
TCHAR *cp = strdup(string+2); TCHAR *cp = _tcsdup(string+2);
TCHAR *p = _tcschr(cp, _T(')')); TCHAR *p = _tcschr(cp, _T(')'));
if (p && p[1] == _T('\0') ) { // if string is only a language str identifier if (p && p[1] == _T('\0') ) { // if string is only a language str identifier
*p = 0; *p = 0;
@ -480,14 +488,19 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
const TCHAR *p=in; const TCHAR *p=in;
while (*p) while (*p)
{ {
const TCHAR *np = CharNextExA(codepage, p, 0); const TCHAR *np;
#ifdef _UNICODE
np = CharNext(p);
#else
np = CharNextExA(codepage, p, 0);
#endif
if (np - p > 1) // multibyte TCHAR if (np - p > 1) // multibyte TCHAR
{ {
int l = np - p; int l = np - p;
while (l--) while (l--)
{ {
_TUCHAR i = (_TUCHAR)*p++; _TUCHAR i = (_TUCHAR)*p++;
if (i >= NS_CODES_START) { if (NS_IS_CODE(i)) {
*out++ = (TCHAR)NS_SKIP_CODE; *out++ = (TCHAR)NS_SKIP_CODE;
} }
*out++=(TCHAR)i; *out++=(TCHAR)i;
@ -500,7 +513,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
p=np; // increment p. p=np; // increment p.
// Test for characters extending into the variable codes // Test for characters extending into the variable codes
if (i >= NS_CODES_START) { if (NS_IS_CODE(i)) {
*out++ = (TCHAR)NS_SKIP_CODE; *out++ = (TCHAR)NS_SKIP_CODE;
// out does get the NS_CODE as well because of // out does get the NS_CODE as well because of
// "*out++=(TCHAR)i" at the end. // "*out++=(TCHAR)i" at the end.
@ -584,7 +597,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
if ( !bProceced && *p == _T('(') ) if ( !bProceced && *p == _T('(') )
{ {
int idx = -1; int idx = -1;
TCHAR *cp = strdup(p+1); // JP: Bad... should avoid memory alloc. TCHAR *cp = _tcsdup(p+1); // JP: Bad... should avoid memory alloc.
TCHAR *pos = _tcschr(cp, _T(')')); TCHAR *pos = _tcschr(cp, _T(')'));
if (pos) if (pos)
{ {
@ -625,7 +638,7 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
if (_tcschr(tbuf,cBracket)) (_tcschr(tbuf,cBracket)+1)[0]=0; if (_tcschr(tbuf,cBracket)) (_tcschr(tbuf,cBracket)+1)[0]=0;
if ( tbuf[0] == _T('{') && tbuf[_tcsclen(tbuf)-1] == _T('}') ) if ( tbuf[0] == _T('{') && tbuf[_tcsclen(tbuf)-1] == _T('}') )
{ {
TCHAR *tstIfDefine = strdup(tbuf+1); TCHAR *tstIfDefine = _tcsdup(tbuf+1);
tstIfDefine[_tcsclen(tstIfDefine)-1] = _T('\0'); tstIfDefine[_tcsclen(tstIfDefine)-1] = _T('\0');
bDoWarning = definedlist.find(tstIfDefine) == NULL; bDoWarning = definedlist.find(tstIfDefine) == NULL;
// If it's a defined identifier, then don't warn. // If it's a defined identifier, then don't warn.
@ -941,7 +954,7 @@ int CEXEBuild::add_label(const TCHAR *name)
int cs=build_cursection->code; int cs=build_cursection->code;
int ce=cs+build_cursection->code_size; int ce=cs+build_cursection->code_size;
TCHAR *p=strdup(name); TCHAR *p=_tcsdup(name);
if (p[_tcsclen(p)-1] == _T(':')) p[_tcsclen(p)-1]=0; if (p[_tcsclen(p)-1] == _T(':')) p[_tcsclen(p)-1]=0;
int offs=ns_label.add(p,0); int offs=ns_label.add(p,0);
free(p); free(p);
@ -961,10 +974,10 @@ int CEXEBuild::add_label(const TCHAR *name)
if (*name == _T('.')) ERROR_MSG(_T("Error: global label \"%s\" already declared\n"),name); if (*name == _T('.')) ERROR_MSG(_T("Error: global label \"%s\" already declared\n"),name);
else else
{ {
const TCHAR *t = _T("section"); const TCHAR *szType = _T("section");
if (build_cursection_isfunc) if (build_cursection_isfunc)
t = _T("function"); szType = _T("function");
ERROR_MSG(_T("Error: label \"%s\" already declared in %s\n"),name,t); ERROR_MSG(_T("Error: label \"%s\" already declared in %s\n"),name,szType);
} }
return PS_ERROR; return PS_ERROR;
} }
@ -1003,7 +1016,7 @@ int CEXEBuild::add_function(const TCHAR *funname)
return PS_ERROR; return PS_ERROR;
} }
set_uninstall_mode(!strnicmp(funname,_T("un."),3)); set_uninstall_mode(!_tcsncicmp(funname,_T("un."),3));
// ns_func contains all the function names defined. // ns_func contains all the function names defined.
int addr=ns_func.add(funname,0); int addr=ns_func.add(funname,0);
@ -1159,13 +1172,13 @@ int CEXEBuild::add_section(const TCHAR *secname, const TCHAR *defname, int expan
set_uninstall_mode(0); set_uninstall_mode(0);
if (!strnicmp(name, _T("un."), 3)) if (!_tcsncicmp(name, _T("un."), 3))
{ {
set_uninstall_mode(1); set_uninstall_mode(1);
name += 3; name += 3;
} }
if (!stricmp(name, _T("uninstall"))) if (!_tcsicmp(name, _T("uninstall")))
{ {
set_uninstall_mode(1); set_uninstall_mode(1);
} }
@ -1724,7 +1737,7 @@ int CEXEBuild::AddVersionInfo()
} }
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error adding version information: %s\n"), err.what()); ERROR_MSG(_T("Error adding version information: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
} }
@ -1735,6 +1748,7 @@ int CEXEBuild::AddVersionInfo()
#endif // NSIS_SUPPORT_VERSION_INFO #endif // NSIS_SUPPORT_VERSION_INFO
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
int CEXEBuild::ProcessPages() int CEXEBuild::ProcessPages()
{ {
SCRIPT_MSG(_T("Processing pages... ")); SCRIPT_MSG(_T("Processing pages... "));
@ -2130,7 +2144,7 @@ again:
SCRIPT_MSG(_T("Done!\n")); SCRIPT_MSG(_T("Done!\n"));
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("\nError: %s\n"), err.what()); ERROR_MSG(_T("\nError: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
@ -2247,7 +2261,7 @@ int CEXEBuild::SetVarsSection()
} }
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("\nError: %s\n"), err.what()); ERROR_MSG(_T("\nError: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
@ -2264,10 +2278,11 @@ int CEXEBuild::SetManifest()
if (manifest == "") if (manifest == "")
return PS_OK; return PS_OK;
// Saved directly as binary into the exe.
res_editor->UpdateResourceA(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length()); res_editor->UpdateResourceA(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error setting manifest: %s\n"), err.what()); ERROR_MSG(_T("Error setting manifest: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
@ -2284,7 +2299,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"), err.what()); ERROR_MSG(_T("Error updating PE headers: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
@ -2479,7 +2494,7 @@ int CEXEBuild::write_output(void)
close_res_editor(); close_res_editor();
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("\nError: %s\n"), err.what()); ERROR_MSG(_T("\nError: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
@ -3192,6 +3207,7 @@ void CEXEBuild::warning(const TCHAR *s, ...)
_vsntprintf(buf,NSIS_MAX_STRLEN*10,s,val); _vsntprintf(buf,NSIS_MAX_STRLEN*10,s,val);
#endif #endif
va_end(val); va_end(val);
m_warnings.add(buf,0); m_warnings.add(buf,0);
notify(MAKENSIS_NOTIFY_WARNING,buf); notify(MAKENSIS_NOTIFY_WARNING,buf);
if (display_warnings) if (display_warnings)

View file

@ -199,7 +199,7 @@ int CLZMA::Init(int level, unsigned int dicSize)
NCoderPropID::kDictionarySize, NCoderPropID::kDictionarySize,
NCoderPropID::kNumFastBytes NCoderPropID::kNumFastBytes
}; };
const int kNumProps = sizeof(propdIDs) / sizeof(propdIDs[0]); const int kNumProps = _countof(propdIDs);
PROPVARIANT props[kNumProps]; PROPVARIANT props[kNumProps];
// NCoderPropID::kAlgorithm // NCoderPropID::kAlgorithm
props[0].vt = VT_UI4; props[0].vt = VT_UI4;

View file

@ -145,7 +145,7 @@ bool dir_reader::is_excluded(const tstring& name) const {
iterator e = m_excluded.end(); iterator e = m_excluded.end();
for (; i != e; i++) { for (; i != e; i++) {
if (!::stricmp(name.c_str(), i->c_str())) { if (!::_tcsicmp(name.c_str(), i->c_str())) {
return true; return true;
} }
} }

View file

@ -146,8 +146,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPTSTR lpszCmdPara
{ {
cmdline++; cmdline++;
// this only works with spaces because they have just one bit on #define END_OF_ARG(c) (c == _T(' ') || c == _T('\0'))
#define END_OF_ARG(c) (((c)|_T(' '))==_T(' '))
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT) #if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
if (cmdline[0] == _T('S') && END_OF_ARG(cmdline[1])) if (cmdline[0] == _T('S') && END_OF_ARG(cmdline[1]))

View file

@ -249,7 +249,9 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
static const TCHAR reg_nt_locale_key[] = _T(".DEFAULT\\Control Panel\\International"); static const TCHAR reg_nt_locale_key[] = _T(".DEFAULT\\Control Panel\\International");
const TCHAR *reg_nt_locale_val = &reg_9x_locale[30]; // = _T("Locale") with opt const TCHAR *reg_nt_locale_val = &reg_9x_locale[30]; // = _T("Locale") with opt
*(DWORD*)state_language = CHAR4_TO_DWORD(_T('0'), _T('x'), 0, 0); state_language[0] = _T('0');
state_language[1] = _T('x');
state_language[2] = 0;
{ {
// Windows 9x // Windows 9x
@ -318,7 +320,6 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
} }
} }
} }
mystrcpy(state_install_directory,addtrailingslash(p)); mystrcpy(state_install_directory,addtrailingslash(p));
} }
} }
@ -343,20 +344,20 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
#ifdef NSIS_SUPPORT_BGBG #ifdef NSIS_SUPPORT_BGBG
if (header->bg_color1 != -1) if (header->bg_color1 != -1)
{ {
DWORD cn = CHAR4_TO_DWORD(_T('_'), _T('N'), _T('b'), 0); LPCTSTR cn = _T("_Nb");
RECT vp; RECT vp;
extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM);
wc.lpfnWndProc = BG_WndProc; wc.lpfnWndProc = BG_WndProc;
wc.hInstance = g_hInstance; wc.hInstance = g_hInstance;
wc.hIcon = g_hIcon; wc.hIcon = g_hIcon;
//wc.hCursor = LoadCursor(NULL,IDC_ARROW); //wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.lpszClassName = (LPCTSTR)&cn; wc.lpszClassName = cn;
if (!RegisterClass(&wc)) return 0; if (!RegisterClass(&wc)) return 0;
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);
m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,(LPCTSTR)&cn,0,WS_POPUP, m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,cn,0,WS_POPUP,
vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL);
} }
@ -399,6 +400,7 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
RegisterClass(&wc); RegisterClass(&wc);
} }
} }
#endif #endif
{ {
@ -434,7 +436,6 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
#endif//NSIS_CONFIG_SILENT_SUPPORT #endif//NSIS_CONFIG_SILENT_SUPPORT
} }
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{ {
@ -894,6 +895,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
page *thispage = g_this_page; page *thispage = g_this_page;
TCHAR *dir = g_usrvars[thispage->parms[4]]; TCHAR *dir = g_usrvars[thispage->parms[4]];
int browse_text = thispage->parms[3]; int browse_text = thispage->parms[3];
if (uMsg == WM_NOTIFY_INIGO_MONTOYA) if (uMsg == WM_NOTIFY_INIGO_MONTOYA)
{ {
GetUIText(IDC_DIR,dir); GetUIText(IDC_DIR,dir);
@ -1026,7 +1028,6 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
* 6. `dir' is never modified. * 6. `dir' is never modified.
* *
*/ */
mystrcpy(s,dir); mystrcpy(s,dir);
// Test for and use the GetDiskFreeSpaceEx API // Test for and use the GetDiskFreeSpaceEx API
@ -1038,8 +1039,8 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
ULARGE_INTEGER available64; ULARGE_INTEGER available64;
ULARGE_INTEGER a, b; ULARGE_INTEGER a, b;
TCHAR *p; TCHAR *p;
WORD *pw = NULL; TCHAR *pw = NULL;
while ((TCHAR *) pw != s) // trimslashtoend() cut the entire string while (pw != s) // trimslashtoend() cut the entire string
{ {
if (GDFSE(s, &available64, &a, &b)) if (GDFSE(s, &available64, &a, &b))
{ {
@ -1057,8 +1058,11 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
*pw = 0; *pw = 0;
p = trimslashtoend(s); // trim last backslash p = trimslashtoend(s); // trim last backslash
pw = (LPWORD) (p - 1); // bring it back, but make the next char null
*pw = CHAR2_TO_WORD(_T('\\'), 0); // bring it back, but make the next TCHAR null pw = p;
*pw = 0;
--pw;
*pw = _T('\\');
} }
} }
} }
@ -1730,12 +1734,16 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
do { do {
item.pszText = ptr; item.pszText = ptr;
ptr += SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item); ptr += SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
*(WORD*)ptr = CHAR2_TO_WORD(_T('\r'),_T('\n')); *ptr++ = _T('\r');
ptr+=2; *ptr++ = _T('\n');
} while (++i < count); } while (++i < count);
// memory is auto zeroed when allocated with GHND - *ptr = 0; // memory is auto zeroed when allocated with GHND - *ptr = 0;
GlobalUnlock(memory); GlobalUnlock(memory);
#ifdef _UNICODE
SetClipboardData(CF_UNICODETEXT,memory);
#else
SetClipboardData(CF_TEXT,memory); SetClipboardData(CF_TEXT,memory);
#endif
CloseClipboard(); CloseClipboard();
} }
} }

View file

@ -1067,10 +1067,14 @@ static int NSISCALL ExecuteEntry(entry *entry_)
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
static WCHAR wsz[1024]; #ifdef _UNICODE
hres=E_FAIL; hres=ppf->lpVtbl->Save(ppf,(const WCHAR*)buf1,TRUE);
if (MultiByteToWideChar(CP_ACP, 0, buf1, -1, wsz, 1024)) #else
hres=ppf->lpVtbl->Save(ppf,(const WCHAR*)wsz,TRUE); static WCHAR wsz[1024];
hres=E_FAIL;
if (MultiByteToWideChar(CP_ACP, 0, buf1, -1, wsz, 1024))
hres=ppf->lpVtbl->Save(ppf,(const WCHAR*)wsz,TRUE);
#endif
} }
ppf->lpVtbl->Release(ppf); ppf->lpVtbl->Release(ppf);
} }

View file

@ -483,6 +483,7 @@ typedef struct {
#define NS_SHELL_CODE 254 #define NS_SHELL_CODE 254
#define NS_LANG_CODE 255 #define NS_LANG_CODE 255
#define NS_CODES_START NS_SKIP_CODE #define NS_CODES_START NS_SKIP_CODE
#define NS_IS_CODE(x) ((x) >= NS_SKIP_CODE)
// We are doing this to store an integer value into a char string and we // We are doing this to store an integer value into a char string and we
// don't want false end of string values so we shift then OR with 0x8080 // don't want false end of string values so we shift then OR with 0x8080

View file

@ -285,7 +285,8 @@ TCHAR * NSISCALL trimslashtoend(TCHAR *buf)
int NSISCALL validpathspec(TCHAR *ubuf) int NSISCALL validpathspec(TCHAR *ubuf)
{ {
TCHAR dl = ubuf[0] | 0x20; // convert alleged drive letter to lower case TCHAR dl = ubuf[0] | 0x20; // convert alleged drive letter to lower case
return ((*(WORD*)ubuf==CHAR2_TO_WORD(_T('\\'),_T('\\'))) || (dl >= _T('a') && dl <= _T('z') && ubuf[1]==_T(':'))); return ((ubuf[0] == _T('\\') && ubuf[1] == _T('\\')) ||
(dl >= _T('a') && dl <= _T('z') && ubuf[1] == _T(':')));
} }
TCHAR * NSISCALL skip_root(TCHAR *path) TCHAR * NSISCALL skip_root(TCHAR *path)
@ -293,11 +294,11 @@ TCHAR * NSISCALL skip_root(TCHAR *path)
TCHAR *p = CharNext(path); TCHAR *p = CharNext(path);
TCHAR *p2 = CharNext(p); TCHAR *p2 = CharNext(p);
if (*path && *(WORD*)p == CHAR2_TO_WORD(_T(':'), _T('\\'))) if (*path && p[0] == _T(':') && p[1] == _T('\\'))
{ {
return CharNext(p2); return CharNext(p2);
} }
else if (*(WORD*)path == CHAR2_TO_WORD(_T('\\'),_T('\\'))) else if (path[0] == _T('\\') && path[1] == _T('\\'))
{ {
// skip host and share name // skip host and share name
int x = 2; int x = 2;
@ -357,20 +358,21 @@ int NSISCALL is_valid_instpath(TCHAR *s)
return 1; return 1;
} }
TCHAR * NSISCALL mystrstri(TCHAR *a, const TCHAR *b) // Used strictly for the wininit.ini file which is an ASCII file.
char * NSISCALL mystrstriA(char *a, const char *b)
{ {
int l = mystrlen(b); int l = lstrlenA(b);
while (mystrlen(a) >= l) while (lstrlenA(a) >= l)
{ {
TCHAR c = a[l]; char c = a[l];
a[l] = 0; a[l] = 0;
if (!lstrcmpi(a, b)) if (!lstrcmpiA(a, b))
{ {
a[l] = c; a[l] = c;
return a; return a;
} }
a[l] = c; a[l] = c;
a = CharNext(a); a = CharNextA(a);
} }
return NULL; return NULL;
} }
@ -413,8 +415,7 @@ TCHAR * NSISCALL my_GetTempFileName(TCHAR *buf, const TCHAR *dir)
int n = 100; int n = 100;
while (n--) while (n--)
{ {
TCHAR prefix[4]; TCHAR prefix[4] = _T("nsa");
*(LPDWORD)prefix = CHAR4_TO_DWORD(_T('n'), _T('s'), _T('a'), 0);
prefix[2] += (TCHAR)(GetTickCount() % 26); prefix[2] += (TCHAR)(GetTickCount() % 26);
if (GetTempFileName(dir, prefix, 0, buf)) if (GetTempFileName(dir, prefix, 0, buf))
return buf; return buf;
@ -424,6 +425,106 @@ TCHAR * NSISCALL my_GetTempFileName(TCHAR *buf, const TCHAR *dir)
} }
#ifdef NSIS_SUPPORT_MOVEONREBOOT #ifdef NSIS_SUPPORT_MOVEONREBOOT
/** Modifies the wininit.ini file to rename / delete a file.
*
* @param prevName The previous / current name of the file.
* @param newName The new name to move the file to. If NULL, the current file
* will be deleted.
*/
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
{
static char szRenameLine[1024];
static TCHAR wininit[1024];
static TCHAR tmpbuf[1024];
int cchRenameLine;
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
HANDLE hfile;
DWORD dwFileSize;
DWORD dwBytes;
DWORD dwRenameLinePos;
char *pszWinInit; // Contains the file contents of wininit.ini
int spn; // length of the short path name in TCHARs.
lstrcpy(tmpbuf, _T("NUL"));
if (newName) {
// create the file if it's not already there to prevent GetShortPathName from failing
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
spn = GetShortPathName(newName,tmpbuf,1024);
if (!spn || spn > 1024)
return;
}
// wininit is used as a temporary here
spn = GetShortPathName(prevName,wininit,1024);
if (!spn || spn > 1024)
return;
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
// Get the path to the wininit.ini file.
GetNSISString(wininit, g_header->str_wininit);
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
if (hfile != INVALID_HANDLE_VALUE)
{
// We are now working on the Windows wininit file
dwFileSize = GetFileSize(hfile, NULL);
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
if (pszWinInit != NULL)
{
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
{
// Look for the rename section in the current file.
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
if (pszRenameSecInFile == NULL)
{
// No rename section. So we add it to the end of file.
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
dwFileSize += 10;
dwRenameLinePos = dwFileSize;
}
else
{
// There is a rename section, but is there another section after it?
char *pszFirstRenameLine = pszRenameSecInFile+10;
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
if (pszNextSec)
{
TCHAR *p = ++pszNextSec;
while (p < pszWinInit + dwFileSize) {
p[cchRenameLine] = *p;
p++;
}
dwRenameLinePos = pszNextSec - pszWinInit;
}
// rename section is last, stick item at end of file
else dwRenameLinePos = dwFileSize;
}
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
dwFileSize += cchRenameLine;
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
GlobalFree(pszWinInit);
}
}
CloseHandle(hfile);
}
}
/**
* MoveFileOnReboot tries to move a file by the name of pszExisting to the
* name pszNew.
*
* @param pszExisting The old name of the file.
* @param pszNew The new name of the file.
*/
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
{ {
BOOL fOk = 0; BOOL fOk = 0;
@ -434,86 +535,10 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
{ {
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
} }
if (!fOk) if (!fOk)
{ {
static TCHAR szRenameLine[1024]; RenameViaWininit(pszExisting, pszNew);
static TCHAR wininit[1024];
static TCHAR tmpbuf[1024];
int cchRenameLine;
static const TCHAR szRenameSec[] = _T("[Rename]\r\n");
HANDLE hfile;
DWORD dwFileSize;
DWORD dwBytes;
DWORD dwRenameLinePos;
TCHAR *pszWinInit;
int spn;
*(DWORD*)tmpbuf = CHAR4_TO_DWORD(_T('N'), _T('U'), _T('L'), 0);
if (pszNew) {
// create the file if it's not already there to prevent GetShortPathName from failing
CloseHandle(myOpenFile(pszNew,0,CREATE_NEW));
spn = GetShortPathName(pszNew,tmpbuf,1024);
if (!spn || spn > 1024)
return;
}
// wininit is used as a temporary here
spn = GetShortPathName(pszExisting,wininit,1024);
if (!spn || spn > 1024)
return;
cchRenameLine = wsprintf(szRenameLine,_T("%s=%s\r\n"),tmpbuf,wininit);
GetNSISString(wininit, g_header->str_wininit);
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
if (hfile != INVALID_HANDLE_VALUE)
{
dwFileSize = GetFileSize(hfile, NULL);
pszWinInit = GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
if (pszWinInit != NULL)
{
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
{
LPTSTR pszRenameSecInFile = mystrstri(pszWinInit, szRenameSec);
if (pszRenameSecInFile == NULL)
{
mystrcpy(pszWinInit+dwFileSize, szRenameSec);
dwFileSize += 10;
dwRenameLinePos = dwFileSize;
}
else
{
TCHAR *pszFirstRenameLine = pszRenameSecInFile+10;
TCHAR *pszNextSec = mystrstri(pszFirstRenameLine,_T("\n["));
if (pszNextSec)
{
TCHAR *p = ++pszNextSec;
while (p < pszWinInit + dwFileSize) {
p[cchRenameLine] = *p;
p++;
}
dwRenameLinePos = pszNextSec - pszWinInit;
}
// rename section is last, stick item at end of file
else dwRenameLinePos = dwFileSize;
}
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
dwFileSize += cchRenameLine;
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
GlobalFree(pszWinInit);
}
}
CloseHandle(hfile);
}
} }
#ifdef NSIS_SUPPORT_REBOOT #ifdef NSIS_SUPPORT_REBOOT
@ -622,11 +647,16 @@ TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab)
// indexes into the language // indexes into the language
TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab)); TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab));
TCHAR *out = ps_tmpbuf; TCHAR *out = ps_tmpbuf;
if ((unsigned int) (outbuf - ps_tmpbuf) < sizeof(ps_tmpbuf))
// Still working within ps_tmpbuf, so set out to the
// current position that is passed in.
if (outbuf >= ps_tmpbuf &&
(size_t) (outbuf - ps_tmpbuf) < _countof(ps_tmpbuf))
{ {
out = outbuf; out = outbuf;
outbuf = 0; outbuf = 0;
} }
while (*in && out - ps_tmpbuf < NSIS_MAX_STRLEN) while (*in && out - ps_tmpbuf < NSIS_MAX_STRLEN)
{ {
_TUCHAR nVarIdx = (_TUCHAR)*in++; _TUCHAR nVarIdx = (_TUCHAR)*in++;
@ -949,6 +979,19 @@ struct MGA_FUNC
const char *func; const char *func;
}; };
#ifdef _UNICODE
struct MGA_FUNC MGA_FUNCS[] = {
{"KERNEL32", "GetDiskFreeSpaceExW"},
{"KERNEL32", "MoveFileExW"},
{"ADVAPI32", "RegDeleteKeyExW"},
{"ADVAPI32", "OpenProcessToken"},
{"ADVAPI32", "LookupPrivilegeValueW"},
{"ADVAPI32", "AdjustTokenPrivileges"},
{"KERNEL32", "GetUserDefaultUILanguage"},
{"SHLWAPI", "SHAutoComplete"},
{"SHFOLDER", "SHGetFolderPathW"}
};
#else
struct MGA_FUNC MGA_FUNCS[] = { struct MGA_FUNC MGA_FUNCS[] = {
{"KERNEL32", "GetDiskFreeSpaceExA"}, {"KERNEL32", "GetDiskFreeSpaceExA"},
{"KERNEL32", "MoveFileExA"}, {"KERNEL32", "MoveFileExA"},
@ -960,6 +1003,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
{"SHLWAPI", "SHAutoComplete"}, {"SHLWAPI", "SHAutoComplete"},
{"SHFOLDER", "SHGetFolderPathA"} {"SHFOLDER", "SHGetFolderPathA"}
}; };
#endif
/** /**
* Given a function enum, it will load the appropriate DLL and get the * Given a function enum, it will load the appropriate DLL and get the

View file

@ -416,7 +416,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)
fprintf(g_output, _T("\nError generating uninstaller icon: %s -- failing!\n"), e.what()); _ftprintf(g_output, _T("\nError generating uninstaller icon: %s -- failing!\n"), CtoTString(e.what()));
return 0; return 0;
} }

View file

@ -21,7 +21,7 @@
#include "tchar.h" #include "tchar.h"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
//#include "tstring.h" #include "tstring.h"
LineParser::LineParser(bool bCommentBlock) LineParser::LineParser(bool bCommentBlock)
{ {
@ -126,7 +126,7 @@ int LineParser::gettoken_enum(int token, const TCHAR *strlist) // null seperated
TCHAR *tt=gettoken_str(token); TCHAR *tt=gettoken_str(token);
if (tt && *tt) while (*strlist) if (tt && *tt) while (*strlist)
{ {
if (!stricmp(tt,strlist)) return x; if (!_tcsicmp(tt,strlist)) return x;
strlist+=_tcsclen(strlist)+1; strlist+=_tcsclen(strlist)+1;
x++; x++;
} }

View file

@ -189,7 +189,7 @@ static tstring get_home()
static int process_config(CEXEBuild& build, tstring& conf) static int process_config(CEXEBuild& build, tstring& conf)
{ {
FILE *cfg=fopen(conf.c_str(),_T("rt")); FILE *cfg=FOPENTEXT(conf.c_str(),_T("rt"));
if (cfg) if (cfg)
{ {
if (build.display_script) if (build.display_script)
@ -227,7 +227,7 @@ static int change_to_script_dir(CEXEBuild& build, tstring& script)
_ftprintf(g_output,_T("Changing directory to: \"%s\"\n"),dir.c_str()); _ftprintf(g_output,_T("Changing directory to: \"%s\"\n"),dir.c_str());
fflush(g_output); fflush(g_output);
} }
if (chdir(dir.c_str())) if (_tchdir(dir.c_str()))
{ {
if (build.display_errors) if (build.display_errors)
{ {
@ -274,34 +274,34 @@ int _tmain(int argc, TCHAR **argv)
} }
catch (exception& err) catch (exception& err)
{ {
fprintf(g_output, _T("Error initalizing CEXEBuild: %s\n"), err.what()); _ftprintf(g_output, _T("Error initalizing CEXEBuild: %s\n"), CtoTString(err.what()));
fflush(g_output); fflush(g_output);
return 1; return 1;
} }
if (argc > 1 && IS_OPT(argv[1]) && !stricmp(&argv[1][1],_T("VERSION"))) if (argc > 1 && IS_OPT(argv[tmpargpos]) && !_tcsicmp(&argv[tmpargpos][1],_T("VERSION")))
{ {
fprintf(g_output,NSIS_VERSION); _ftprintf(g_output,NSIS_VERSION);
fflush(g_output); fflush(g_output);
return 0; return 0;
} }
if (argc > 1 && IS_OPT(argv[1]) && (argv[1][1]==_T('v') || argv[1][1]==_T('V'))) if (argc > 1 && IS_OPT(argv[tmpargpos]) && (argv[tmpargpos][1]==_T('v') || argv[tmpargpos][1]==_T('V')))
{ {
tmpargpos++; if (argv[tmpargpos][2] <= _T('2') && argv[tmpargpos][2] >= _T('0'))
if (argv[1][2] <= _T('2') && argv[1][2] >= _T('0'))
{ {
no_logo=1; no_logo=1;
} }
tmpargpos++;
} }
if (!no_logo) if (!no_logo)
{ {
if (argc > tmpargpos && IS_OPT(argv[tmpargpos]) && (argv[tmpargpos][1]==_T('o') || argv[tmpargpos][1]==_T('O')) && argv[tmpargpos][2]) if (argc > tmpargpos && IS_OPT(argv[tmpargpos]) && (argv[tmpargpos][1]==_T('o') || argv[tmpargpos][1]==_T('O')) && argv[tmpargpos][2])
{ {
g_output=fopen(argv[tmpargpos]+2,_T("w")); g_output=FOPENTEXT(argv[tmpargpos]+2,_T("w"));
if (!g_output) if (!g_output)
{ {
printf(_T("Error opening output log for writing. Using stdout.\n")); _tprintf(_T("Error opening output log for writing. Using stdout.\n"));
g_output=stdout; g_output=stdout;
} }
outputtried=1; outputtried=1;
@ -321,7 +321,7 @@ int _tmain(int argc, TCHAR **argv)
if ((argv[argpos][1]==_T('D') || argv[argpos][1]==_T('d')) && argv[argpos][2]) if ((argv[argpos][1]==_T('D') || argv[argpos][1]==_T('d')) && argv[argpos][2])
{ {
TCHAR *p=argv[argpos]+2; TCHAR *p=argv[argpos]+2;
TCHAR *s=strdup(p),*v; TCHAR *s=_tcsdup(p),*v;
if (build.display_script) if (build.display_script)
{ {
_ftprintf(g_output,_T("Command line defined: \"%s\"\n"),p); _ftprintf(g_output,_T("Command line defined: \"%s\"\n"),p);
@ -344,7 +344,7 @@ int _tmain(int argc, TCHAR **argv)
{ {
if (!outputtried) if (!outputtried)
{ {
g_output=fopen(argv[argpos]+2,_T("w")); g_output=FOPENTEXT(argv[argpos]+2,_T("w"));
if (!g_output) if (!g_output)
{ {
if (build.display_errors) _tprintf(_T("Error opening output log for writing. Using stdout.\n")); if (build.display_errors) _tprintf(_T("Error opening output log for writing. Using stdout.\n"));
@ -353,7 +353,7 @@ int _tmain(int argc, TCHAR **argv)
outputtried=1; outputtried=1;
} }
} }
else if (!stricmp(&argv[argpos][1],_T("NOCD"))) do_cd=0; else if (!_tcsicmp(&argv[argpos][1],_T("NOCD"))) do_cd=0;
else if ((argv[argpos][1] == _T('V') || argv[argpos][1] == _T('v')) && else if ((argv[argpos][1] == _T('V') || argv[argpos][1] == _T('v')) &&
argv[argpos][2] >= _T('0') && argv[argpos][2] <= _T('4') && !argv[argpos][3]) argv[argpos][2] >= _T('0') && argv[argpos][2] <= _T('4') && !argv[argpos][3])
{ {
@ -364,9 +364,9 @@ int _tmain(int argc, TCHAR **argv)
build.display_errors=v>0; build.display_errors=v>0;
g_display_errors=build.display_errors; g_display_errors=build.display_errors;
} }
else if (!stricmp(&argv[argpos][1],_T("NOCONFIG"))) g_noconfig=1; else if (!_tcsicmp(&argv[argpos][1],_T("NOCONFIG"))) g_noconfig=1;
else if (!stricmp(&argv[argpos][1],_T("PAUSE"))) g_dopause=1; else if (!_tcsicmp(&argv[argpos][1],_T("PAUSE"))) g_dopause=1;
else if (!stricmp(&argv[argpos][1],_T("LICENSE"))) else if (!_tcsicmp(&argv[argpos][1],_T("LICENSE")))
{ {
if (build.display_info) if (build.display_info)
{ {
@ -374,7 +374,7 @@ int _tmain(int argc, TCHAR **argv)
} }
nousage++; nousage++;
} }
else if (!stricmp(&argv[argpos][1],_T("CMDHELP"))) else if (!_tcsicmp(&argv[argpos][1],_T("CMDHELP")))
{ {
if (argpos < argc-1) if (argpos < argc-1)
build.print_help(argv[++argpos]); build.print_help(argv[++argpos]);
@ -382,7 +382,7 @@ int _tmain(int argc, TCHAR **argv)
build.print_help(NULL); build.print_help(NULL);
nousage++; nousage++;
} }
else if (!stricmp(&argv[argpos][1],_T("NOTIFYHWND"))) else if (!_tcsicmp(&argv[argpos][1],_T("NOTIFYHWND")))
{ {
#ifdef _WIN32 #ifdef _WIN32
build.notify_hwnd=(HWND)_ttol(argv[++argpos]); build.notify_hwnd=(HWND)_ttol(argv[++argpos]);
@ -393,7 +393,7 @@ int _tmain(int argc, TCHAR **argv)
build.warning(OPT_STR _T("NOTIFYHWND is disabled for non Win32 platforms.")); build.warning(OPT_STR _T("NOTIFYHWND is disabled for non Win32 platforms."));
#endif #endif
} }
else if (!stricmp(&argv[argpos][1],_T("HDRINFO"))) else if (!_tcsicmp(&argv[argpos][1],_T("HDRINFO")))
{ {
print_stub_info(build); print_stub_info(build);
nousage++; nousage++;
@ -479,11 +479,11 @@ int _tmain(int argc, TCHAR **argv)
else else
{ {
_tcscpy(sfile,argv[argpos]); _tcscpy(sfile,argv[argpos]);
fp=fopen(sfile,_T("rt")); fp=FOPENTEXT(sfile,_T("rt"));
if (!fp) if (!fp)
{ {
_stprintf(sfile,_T("%s.nsi"),argv[argpos]); _stprintf(sfile,_T("%s.nsi"),argv[argpos]);
fp=fopen(sfile,_T("rt")); fp=FOPENTEXT(sfile,_T("rt"));
if (!fp) if (!fp)
{ {
if (build.display_errors) if (build.display_errors)

View file

@ -33,7 +33,9 @@ string generate(comctl comctl_selection, exec_level exec_level_selection)
if (comctl_selection == comctl_old && exec_level_selection == exec_level_none) if (comctl_selection == comctl_old && exec_level_selection == exec_level_none)
return ""; return "";
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System " NSIS_VERSION "</description>"; string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System ";
xml += TtoCString(NSIS_VERSION);
xml += "</description>";
if (comctl_selection == comctl_xp) if (comctl_selection == comctl_xp)
{ {

View file

@ -57,7 +57,7 @@ TCHAR *CEXEBuild::set_file_predefine(const TCHAR *filename)
TCHAR *oldfilename = definedlist.find(_T("__FILE__")); TCHAR *oldfilename = definedlist.find(_T("__FILE__"));
if(oldfilename) if(oldfilename)
{ {
oldfilename = strdup(oldfilename); oldfilename = _tcsdup(oldfilename);
definedlist.del(_T("__FILE__")); definedlist.del(_T("__FILE__"));
} }
const TCHAR *p = _tcsrchr(filename,_T('\\')); const TCHAR *p = _tcsrchr(filename,_T('\\'));
@ -85,7 +85,7 @@ TCHAR *CEXEBuild::set_timestamp_predefine(const TCHAR *filename)
{ {
TCHAR *oldtimestamp = definedlist.find(_T("__TIMESTAMP__")); TCHAR *oldtimestamp = definedlist.find(_T("__TIMESTAMP__"));
if(oldtimestamp) { if(oldtimestamp) {
oldtimestamp = strdup(oldtimestamp); oldtimestamp = _tcsdup(oldtimestamp);
definedlist.del(_T("__TIMESTAMP__")); definedlist.del(_T("__TIMESTAMP__"));
} }
@ -105,8 +105,8 @@ TCHAR *CEXEBuild::set_timestamp_predefine(const TCHAR *filename)
FileTimeToLocalFileTime(&fd.ftLastWriteTime, &floctime); FileTimeToLocalFileTime(&fd.ftLastWriteTime, &floctime);
FileTimeToSystemTime(&floctime, &stime); FileTimeToSystemTime(&floctime, &stime);
GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &stime, NULL, datebuf, sizeof(datebuf)/sizeof(datebuf[0])); GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &stime, NULL, datebuf, _countof(datebuf));
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &stime, NULL, timebuf, sizeof(timebuf)/sizeof(timebuf[0])); GetTimeFormat(LOCALE_USER_DEFAULT, 0, &stime, NULL, timebuf, _countof(timebuf));
wsprintf(timestampbuf,_T("%s %s"),datebuf,timebuf); wsprintf(timestampbuf,_T("%s %s"),datebuf,timebuf);
definedlist.add(_T("__TIMESTAMP__"),timestampbuf); definedlist.add(_T("__TIMESTAMP__"),timestampbuf);
@ -139,7 +139,7 @@ TCHAR *CEXEBuild::set_line_predefine(int linecnt, BOOL is_macro)
TCHAR *oldline = definedlist.find(_T("__LINE__")); TCHAR *oldline = definedlist.find(_T("__LINE__"));
if(oldline) { if(oldline) {
oldline = strdup(oldline); oldline = _tcsdup(oldline);
definedlist.del(_T("__LINE__")); definedlist.del(_T("__LINE__"));
} }
if(is_macro && oldline) { if(is_macro && oldline) {
@ -147,7 +147,7 @@ TCHAR *CEXEBuild::set_line_predefine(int linecnt, BOOL is_macro)
_stprintf(linebuf,_T("%s.%s"),oldline,temp); _stprintf(linebuf,_T("%s.%s"),oldline,temp);
} }
else { else {
linebuf = strdup(temp); linebuf = _tcsdup(temp);
} }
definedlist.add(_T("__LINE__"),linebuf); definedlist.add(_T("__LINE__"),linebuf);
@ -313,7 +313,7 @@ int CEXEBuild::doParse(const TCHAR *str)
// escaped quotes should be ignored for compile time commands that set defines // escaped quotes should be ignored for compile time commands that set defines
// because defines can be inserted in commands at a later stage // because defines can be inserted in commands at a later stage
bool ignore_escaping = (!strnicmp((TCHAR*)m_linebuild.get(),_T("!define"),7) || !strnicmp((TCHAR*)m_linebuild.get(),_T("!insertmacro"),12)); bool ignore_escaping = (!_tcsncicmp((TCHAR*)m_linebuild.get(),_T("!define"),7) || !_tcsncicmp((TCHAR*)m_linebuild.get(),_T("!insertmacro"),12));
res=line.parse((TCHAR*)m_linebuild.get(), ignore_escaping); res=line.parse((TCHAR*)m_linebuild.get(), ignore_escaping);
inside_comment = line.inCommentBlock(); inside_comment = line.inCommentBlock();
@ -467,9 +467,9 @@ parse_again:
switch(mod) { switch(mod) {
case 0: case 0:
case 1: case 1:
istrue = stricmp(line.gettoken_str(1),line.gettoken_str(3)) == 0; break; istrue = _tcsicmp(line.gettoken_str(1),line.gettoken_str(3)) == 0; break;
case 2: case 2:
istrue = stricmp(line.gettoken_str(1),line.gettoken_str(3)) != 0; break; istrue = _tcsicmp(line.gettoken_str(1),line.gettoken_str(3)) != 0; break;
case 3: case 3:
istrue = line.gettoken_float(1) <= line.gettoken_float(3); break; istrue = line.gettoken_float(1) <= line.gettoken_float(3); break;
case 4: case 4:
@ -595,7 +595,7 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
} }
else if (in[0] == _T('{')) else if (in[0] == _T('{'))
{ {
TCHAR *s=strdup(in+1); TCHAR *s=_tcsdup(in+1);
MANAGE_WITH(s, free); MANAGE_WITH(s, free);
TCHAR *t=s; TCHAR *t=s;
unsigned int bn = 0; unsigned int bn = 0;
@ -633,7 +633,7 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
} }
else if (in[0] == _T('%')) else if (in[0] == _T('%'))
{ {
TCHAR *s=strdup(in+1); TCHAR *s=_tcsdup(in+1);
MANAGE_WITH(s, free); MANAGE_WITH(s, free);
TCHAR *t=s; TCHAR *t=s;
while (*t) while (*t)
@ -668,7 +668,7 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
{ {
if (in[1] == _T('{')) // Found $$ before - Don't replace this define if (in[1] == _T('{')) // Found $$ before - Don't replace this define
{ {
TCHAR *s=strdup(in+2); TCHAR *s=_tcsdup(in+2);
MANAGE_WITH(s, free); MANAGE_WITH(s, free);
TCHAR *t=s; TCHAR *t=s;
unsigned int bn = 0; unsigned int bn = 0;
@ -743,7 +743,7 @@ int CEXEBuild::parseScript()
int CEXEBuild::includeScript(TCHAR *f) int CEXEBuild::includeScript(TCHAR *f)
{ {
SCRIPT_MSG(_T("!include: \"%s\"\n"),f); SCRIPT_MSG(_T("!include: \"%s\"\n"),f);
FILE *incfp=FOPEN(f,_T("rt")); FILE *incfp=FOPENTEXT(f,_T("rt"));
if (!incfp) if (!incfp)
{ {
ERROR_MSG(_T("!include: could not open file: \"%s\"\n"),f); ERROR_MSG(_T("!include: could not open file: \"%s\"\n"),f);
@ -805,7 +805,7 @@ int CEXEBuild::MacroExists(const TCHAR *macroname)
while (m && *m) while (m && *m)
{ {
// check if macroname matches // check if macroname matches
if (!stricmp(m, macroname)) if (!_tcsicmp(m, macroname))
return 1; return 1;
// skip macro name // skip macro name
@ -876,7 +876,7 @@ int CEXEBuild::process_jump(LineParser &line, int wt, int *offs)
const TCHAR *s=line.gettoken_str(wt); const TCHAR *s=line.gettoken_str(wt);
int v; int v;
if (!stricmp(s,_T("0")) || !stricmp(s,_T(""))) *offs=0; if (!_tcsicmp(s,_T("0")) || !_tcsicmp(s,_T(""))) *offs=0;
else if ((v=GetUserVarIndex(line, wt))>=0) else if ((v=GetUserVarIndex(line, wt))>=0)
{ {
*offs=-v-1; // to jump to a user variable target, -variable_index-1 is stored. *offs=-v-1; // to jump to a user variable target, -variable_index-1 is stored.
@ -930,7 +930,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *t=(TCHAR *)m_macros.get(); TCHAR *t=(TCHAR *)m_macros.get();
while (t && *t) while (t && *t)
{ {
if (!stricmp(t,line.gettoken_str(1))) break; if (!_tcsicmp(t,line.gettoken_str(1))) break;
t+=_tcsclen(t)+1; t+=_tcsclen(t)+1;
// advance over parameters // advance over parameters
@ -961,7 +961,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int a; int a;
for (a=2; a < pc; a ++) for (a=2; a < pc; a ++)
{ {
if (!stricmp(line.gettoken_str(pc),line.gettoken_str(a))) if (!_tcsicmp(line.gettoken_str(pc),line.gettoken_str(a)))
{ {
ERROR_MSG(_T("!macro: macro parameter named %s is used multiple times!\n"), ERROR_MSG(_T("!macro: macro parameter named %s is used multiple times!\n"),
line.gettoken_str(pc)); line.gettoken_str(pc));
@ -992,12 +992,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
LineParser l2(false); LineParser l2(false);
if (!l2.parse(str)) if (!l2.parse(str))
{ {
if (!stricmp(l2.gettoken_str(0),_T("!macroend"))) if (!_tcsicmp(l2.gettoken_str(0),_T("!macroend")))
{ {
linecnt++; linecnt++;
break; break;
} }
if (!stricmp(l2.gettoken_str(0),_T("!macro"))) if (!_tcsicmp(l2.gettoken_str(0),_T("!macro")))
{ {
ERROR_MSG(_T("Error: can't define a macro inside a macro!\n")); ERROR_MSG(_T("Error: can't define a macro inside a macro!\n"));
return PS_ERROR; return PS_ERROR;
@ -1020,7 +1020,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *m=t; TCHAR *m=t;
while (t && *t) while (t && *t)
{ {
if (!stricmp(t,line.gettoken_str(1))) break; if (!_tcsicmp(t,line.gettoken_str(1))) break;
t+=_tcsclen(t)+1; t+=_tcsclen(t)+1;
// advance over parms // advance over parms
@ -1170,7 +1170,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *fc = line.gettoken_str(a); TCHAR *fc = line.gettoken_str(a);
if (line.getnumtokens()==3) if (line.getnumtokens()==3)
{ {
if(!stricmp(fc,_T("/nonfatal"))) if(!_tcsicmp(fc,_T("/nonfatal")))
{ {
fatal = 0; fatal = 0;
fc = line.gettoken_str(++a); fc = line.gettoken_str(++a);
@ -1201,7 +1201,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
tstring file = basedir + *files_itr; tstring file = basedir + *files_itr;
int result = unlink(file.c_str()); int result = _tunlink(file.c_str());
if (result == -1) { if (result == -1) {
ERROR_MSG(_T("!delfile: \"%s\" couldn't be deleted.\n"), file.c_str()); ERROR_MSG(_T("!delfile: \"%s\" couldn't be deleted.\n"), file.c_str());
if (fatal) if (fatal)
@ -1222,7 +1222,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *file = line.gettoken_str(1); TCHAR *file = line.gettoken_str(1);
TCHAR *text = line.gettoken_str(2); TCHAR *text = line.gettoken_str(2);
FILE *fp = FOPEN(file, _T("a")); FILE *fp = FOPENTEXT(file, _T("a"));
if (!fp) if (!fp)
{ {
ERROR_MSG(_T("!appendfile: \"%s\" couldn't be opened.\n"), file); ERROR_MSG(_T("!appendfile: \"%s\" couldn't be opened.\n"), file);
@ -1250,12 +1250,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (!uninstall_mode) { if (!uninstall_mode) {
enable_last_page_cancel = 0; enable_last_page_cancel = 0;
if (!stricmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL"))) if (!_tcsicmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL")))
enable_last_page_cancel = 1; enable_last_page_cancel = 1;
} }
else { else {
uenable_last_page_cancel = 0; uenable_last_page_cancel = 0;
if (!stricmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL"))) if (!_tcsicmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL")))
uenable_last_page_cancel = 1; uenable_last_page_cancel = 1;
} }
@ -1395,7 +1395,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (*line.gettoken_str(2)) if (*line.gettoken_str(2))
{ {
if (strnicmp(line.gettoken_str(2), _T("un."), 3)) if (_tcsncicmp(line.gettoken_str(2), _T("un."), 3))
{ {
if (uninstall_mode) if (uninstall_mode)
{ {
@ -1418,7 +1418,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (*line.gettoken_str(1)) if (*line.gettoken_str(1))
{ {
if (strnicmp(line.gettoken_str(1), _T("un."), 3)) if (_tcsncicmp(line.gettoken_str(1), _T("un."), 3))
{ {
if (uninstall_mode) if (uninstall_mode)
{ {
@ -1447,7 +1447,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (*line.gettoken_str(3)) if (*line.gettoken_str(3))
{ {
if (strnicmp(line.gettoken_str(3), _T("un."), 3)) if (_tcsncicmp(line.gettoken_str(3), _T("un."), 3))
{ {
if (uninstall_mode) if (uninstall_mode)
{ {
@ -1470,7 +1470,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (*line.gettoken_str(2)) if (*line.gettoken_str(2))
{ {
if (strnicmp(line.gettoken_str(2), _T("un."), 3)) if (_tcsncicmp(line.gettoken_str(2), _T("un."), 3))
{ {
if (uninstall_mode) if (uninstall_mode)
{ {
@ -1493,7 +1493,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
if (*line.gettoken_str(1)) if (*line.gettoken_str(1))
{ {
if (strnicmp(line.gettoken_str(1), _T("un."), 3)) if (_tcsncicmp(line.gettoken_str(1), _T("un."), 3))
{ {
if (uninstall_mode) if (uninstall_mode)
{ {
@ -1652,7 +1652,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
installer_icon = load_icon_file(line.gettoken_str(1)); installer_icon = load_icon_file(line.gettoken_str(1));
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while loading icon from \"%s\": %s\n"), line.gettoken_str(1), err.what()); ERROR_MSG(_T("Error while loading icon from \"%s\": %s\n"), line.gettoken_str(1), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
return PS_OK; return PS_OK;
@ -1681,7 +1681,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while replacing bitmap: %s\n"), err.what()); ERROR_MSG(_T("Error while replacing bitmap: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
return PS_OK; return PS_OK;
@ -1783,17 +1783,17 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
int x; int x;
if (!stricmp(line.gettoken_str(1),_T("/NOCUSTOM"))) if (!_tcsicmp(line.gettoken_str(1),_T("/NOCUSTOM")))
{ {
build_header.flags|=CH_FLAGS_NO_CUSTOM; build_header.flags|=CH_FLAGS_NO_CUSTOM;
SCRIPT_MSG(_T("InstType: disabling custom install type\n")); SCRIPT_MSG(_T("InstType: disabling custom install type\n"));
} }
else if (!stricmp(line.gettoken_str(1),_T("/COMPONENTSONLYONCUSTOM"))) else if (!_tcsicmp(line.gettoken_str(1),_T("/COMPONENTSONLYONCUSTOM")))
{ {
build_header.flags|=CH_FLAGS_COMP_ONLY_ON_CUSTOM; build_header.flags|=CH_FLAGS_COMP_ONLY_ON_CUSTOM;
SCRIPT_MSG(_T("InstType: making components viewable only on custom install type\n")); SCRIPT_MSG(_T("InstType: making components viewable only on custom install type\n"));
} }
else if (!strnicmp(line.gettoken_str(1),_T("/CUSTOMSTRING="),14)) else if (!_tcsncicmp(line.gettoken_str(1),_T("/CUSTOMSTRING="),14))
{ {
SCRIPT_MSG(_T("InstType: setting custom text to: \"%s\"\n"),line.gettoken_str(1)+14); SCRIPT_MSG(_T("InstType: setting custom text to: \"%s\"\n"),line.gettoken_str(1)+14);
if (SetInnerString(NLF_COMP_CUSTOM,line.gettoken_str(1)+14) == PS_WARNING) if (SetInnerString(NLF_COMP_CUSTOM,line.gettoken_str(1)+14) == PS_WARNING)
@ -1807,7 +1807,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
TCHAR *itname = line.gettoken_str(1); TCHAR *itname = line.gettoken_str(1);
if (!strnicmp(itname, _T("un."), 3)) { if (!_tcsncicmp(itname, _T("un."), 3)) {
set_uninstall_mode(1); set_uninstall_mode(1);
itname += 3; itname += 3;
} }
@ -1864,7 +1864,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (file[0] == _T('$') && file[1] == _T('(')) if (file[0] == _T('$') && file[1] == _T('('))
{ {
TCHAR *cp = strdup(file+2); TCHAR *cp = _tcsdup(file+2);
MANAGE_WITH(cp, free); MANAGE_WITH(cp, free);
TCHAR *p = _tcschr(cp, _T(')')); TCHAR *p = _tcschr(cp, _T(')'));
if (p && p[1] == 0) { // if string is only a language str identifier if (p && p[1] == 0) { // if string is only a language str identifier
@ -1994,12 +1994,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_LICENSEBKCOLOR: case TOK_LICENSEBKCOLOR:
{ {
TCHAR *p = line.gettoken_str(1); TCHAR *p = line.gettoken_str(1);
if (!strcmpi(p,_T("/windows"))) if (!_tcsicmp(p,_T("/windows")))
{ {
build_header.license_bg=-COLOR_WINDOW; build_header.license_bg=-COLOR_WINDOW;
SCRIPT_MSG(_T("LicenseBkColor: /windows\n")); SCRIPT_MSG(_T("LicenseBkColor: /windows\n"));
} }
else if (!strcmpi(p,_T("/grey")) || !strcmpi(p,_T("/gray"))) else if (!_tcsicmp(p,_T("/grey")) || !_tcsicmp(p,_T("/gray")))
{ {
build_header.license_bg=-COLOR_BTNFACE; build_header.license_bg=-COLOR_BTNFACE;
SCRIPT_MSG(_T("LicenseBkColor: /grey\n")); SCRIPT_MSG(_T("LicenseBkColor: /grey\n"));
@ -2150,8 +2150,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
build_header.flags&=~CH_FLAGS_PROGRESS_COLORED; build_header.flags&=~CH_FLAGS_PROGRESS_COLORED;
for (x = 1; x < line.getnumtokens(); x ++) for (x = 1; x < line.getnumtokens(); x ++)
{ {
if (!stricmp(line.gettoken_str(x),_T("smooth"))) smooth=1; if (!_tcsicmp(line.gettoken_str(x),_T("smooth"))) smooth=1;
else if (!stricmp(line.gettoken_str(x),_T("colored"))) build_header.flags|=CH_FLAGS_PROGRESS_COLORED; else if (!_tcsicmp(line.gettoken_str(x),_T("colored"))) build_header.flags|=CH_FLAGS_PROGRESS_COLORED;
else PRINTHELP() else PRINTHELP()
} }
try { try {
@ -2177,7 +2177,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
delete [] dlg; delete [] dlg;
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error setting smooth progress bar: %s\n"), err.what()); ERROR_MSG(_T("Error setting smooth progress bar: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
SCRIPT_MSG(_T("InstProgressFlags: smooth=%d, colored=%d\n"),smooth, SCRIPT_MSG(_T("InstProgressFlags: smooth=%d, colored=%d\n"),smooth,
@ -2294,15 +2294,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
for (int i = 2; i < line.getnumtokens(); i++) { for (int i = 2; i < line.getnumtokens(); i++) {
TCHAR *tok=line.gettoken_str(i); TCHAR *tok=line.gettoken_str(i);
if (tok[0]==_T('/')) { if (tok[0]==_T('/')) {
if (!strcmpi(tok,_T("/ITALIC"))) { if (!_tcsicmp(tok,_T("/ITALIC"))) {
SCRIPT_MSG(_T(" /ITALIC")); SCRIPT_MSG(_T(" /ITALIC"));
newfont.lfItalic=TRUE; newfont.lfItalic=TRUE;
} }
else if (!strcmpi(tok,_T("/UNDERLINE"))) { else if (!_tcsicmp(tok,_T("/UNDERLINE"))) {
SCRIPT_MSG(_T(" /UNDERLINE")); SCRIPT_MSG(_T(" /UNDERLINE"));
newfont.lfUnderline=TRUE; newfont.lfUnderline=TRUE;
} }
else if (!strcmpi(tok,_T("/STRIKE"))) { else if (!_tcsicmp(tok,_T("/STRIKE"))) {
SCRIPT_MSG(_T(" /STRIKE")); SCRIPT_MSG(_T(" /STRIKE"));
newfont.lfStrikeOut=TRUE; newfont.lfStrikeOut=TRUE;
} }
@ -2344,7 +2344,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
build_header.bg_color1=0; build_header.bg_color1=0;
build_header.bg_color2=RGB(0,0,255); build_header.bg_color2=RGB(0,0,255);
} }
else if (!stricmp(line.gettoken_str(1),_T("off"))) else if (!_tcsicmp(line.gettoken_str(1),_T("off")))
{ {
build_header.bg_color1=build_header.bg_color2=build_header.bg_textcolor=-1; build_header.bg_color1=build_header.bg_color2=build_header.bg_textcolor=-1;
SCRIPT_MSG(_T("BGGradient: off\n")); SCRIPT_MSG(_T("BGGradient: off\n"));
@ -2363,7 +2363,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
p=line.gettoken_str(3); p=line.gettoken_str(3);
if (*p) if (*p)
{ {
if (!stricmp(p,_T("notext"))) build_header.bg_textcolor=-1; if (!_tcsicmp(p,_T("notext"))) build_header.bg_textcolor=-1;
else else
{ {
v3=_tcstoul(p,&p,16); v3=_tcstoul(p,&p,16);
@ -2387,7 +2387,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *p = line.gettoken_str(1); TCHAR *p = line.gettoken_str(1);
if (p[0]==_T('/')) if (p[0]==_T('/'))
{ {
if (stricmp(p,_T("/windows")) || line.getnumtokens()!=2) PRINTHELP() if (_tcsicmp(p,_T("/windows")) || line.getnumtokens()!=2) PRINTHELP()
build_header.lb_fg=build_header.lb_bg=-1; build_header.lb_fg=build_header.lb_bg=-1;
SCRIPT_MSG(_T("InstallColors: windows default colors\n")); SCRIPT_MSG(_T("InstallColors: windows default colors\n"));
} }
@ -2500,9 +2500,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
check = true; check = true;
} }
} else { } else {
TCHAR *szClass = winchar_toansi(dlgItem->szClass); check = _wcsicmp(dlgItem->szClass, L"Static") == 0;
check = stricmp(szClass, _T("Static")) == 0;
delete [] szClass;
} }
if (check) { if (check) {
@ -2557,7 +2555,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
SCRIPT_MSG(_T("ChangeUI: %s %s%s\n"), line.gettoken_str(1), line.gettoken_str(2), branding_image_found?_T(" (branding image holder found)"):_T("")); SCRIPT_MSG(_T("ChangeUI: %s %s%s\n"), line.gettoken_str(1), line.gettoken_str(2), branding_image_found?_T(" (branding image holder found)"):_T(""));
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while changing UI: %s\n"), err.what()); ERROR_MSG(_T("Error while changing UI: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
return PS_OK; return PS_OK;
@ -2631,7 +2629,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
branding_image_id = IDC_BRANDIMAGE; branding_image_id = IDC_BRANDIMAGE;
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while adding image branding support: %s\n"), err.what()); ERROR_MSG(_T("Error while adding image branding support: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
return PS_OK; return PS_OK;
@ -2641,7 +2639,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
#endif #endif
case TOK_SETFONT: case TOK_SETFONT:
{ {
if (!strnicmp(line.gettoken_str(1), _T("/LANG="), 6)) if (!_tcsncicmp(line.gettoken_str(1), _T("/LANG="), 6))
{ {
LANGID lang_id = _ttoi(line.gettoken_str(1) + 6); LANGID lang_id = _ttoi(line.gettoken_str(1) + 6);
LanguageTable *table = GetLangTable(lang_id); LanguageTable *table = GetLangTable(lang_id);
@ -2653,7 +2651,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
else else
{ {
_tcsnccpy(build_font, line.gettoken_str(1), sizeof(build_font)/sizeof(TCHAR)); _tcsnccpy(build_font, line.gettoken_str(1), _countof(build_font));
build_font_size = line.gettoken_int(2); build_font_size = line.gettoken_int(2);
SCRIPT_MSG(_T("SetFont: \"%s\" %s\n"), line.gettoken_str(1), line.gettoken_str(2)); SCRIPT_MSG(_T("SetFont: \"%s\" %s\n"), line.gettoken_str(1), line.gettoken_str(2));
@ -2714,12 +2712,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
while (line.gettoken_str(a)[0] == _T('/')) while (line.gettoken_str(a)[0] == _T('/'))
{ {
if (!strcmpi(line.gettoken_str(a),_T("/FINAL"))) if (!_tcsicmp(line.gettoken_str(a),_T("/FINAL")))
{ {
build_compressor_final = true; build_compressor_final = true;
a++; a++;
} }
else if (!strcmpi(line.gettoken_str(a),_T("/SOLID"))) else if (!_tcsicmp(line.gettoken_str(a),_T("/SOLID")))
{ {
build_compress_whole = true; build_compress_whole = true;
a++; a++;
@ -2807,7 +2805,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR datebuf[256]; TCHAR datebuf[256];
TCHAR mathbuf[256]; TCHAR mathbuf[256];
if (!stricmp(define,_T("/date")) || !stricmp(define,_T("/utcdate"))) { if (!_tcsicmp(define,_T("/date")) || !_tcsicmp(define,_T("/utcdate"))) {
if (line.getnumtokens()!=4) PRINTHELP() if (line.getnumtokens()!=4) PRINTHELP()
TCHAR *date_type = define; TCHAR *date_type = define;
@ -2818,11 +2816,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
time_t rawtime; time_t rawtime;
time(&rawtime); time(&rawtime);
if (!stricmp(date_type,_T("/utcdate"))) if (!_tcsicmp(date_type,_T("/utcdate")))
rawtime = mktime(gmtime(&rawtime)); rawtime = mktime(gmtime(&rawtime));
datebuf[0]=0; datebuf[0]=0;
size_t s=strftime(datebuf,sizeof(datebuf),value,localtime(&rawtime)); size_t s=_tcsftime(datebuf,_countof(datebuf),value,localtime(&rawtime));
if (s == 0) if (s == 0)
datebuf[0]=0; datebuf[0]=0;
@ -2830,15 +2828,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
datebuf[max(s,sizeof(datebuf)-1)]=0; datebuf[max(s,sizeof(datebuf)-1)]=0;
value=datebuf; value=datebuf;
} else if (!stricmp(define,_T("/file")) || !stricmp(define,_T("/file_noerr"))) { } else if (!_tcsicmp(define,_T("/file")) || !_tcsicmp(define,_T("/file_noerr"))) {
if (line.getnumtokens()!=4) PRINTHELP() if (line.getnumtokens()!=4) PRINTHELP()
define=line.gettoken_str(2); define=line.gettoken_str(2);
const TCHAR *filename=line.gettoken_str(3); const TCHAR *filename=line.gettoken_str(3);
FILE *fp=fopen(filename,_T("r")); FILE *fp=FOPENTEXT(filename,_T("r"));
if (!fp && stricmp(define,_T("/file_noerr"))) { if (!fp && _tcsicmp(define,_T("/file_noerr"))) {
ERROR_MSG(_T("!define /file: file not found (\"%s\")\n"),filename); ERROR_MSG(_T("!define /file: file not found (\"%s\")\n"),filename);
return PS_ERROR; return PS_ERROR;
} }
@ -2857,14 +2855,14 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
while (p >= str && (*p == _T('\r') || *p == _T('\n'))) p--; while (p >= str && (*p == _T('\r') || *p == _T('\n'))) p--;
*++p=0; *++p=0;
if (file_buf.getlen()) file_buf.add(_T("\n"),1); if (file_buf.getlen()) file_buf.add(_T("\n"),1);
file_buf.add(str,strlen(str)); file_buf.add(str,_tcsclen(str));
} }
fclose(fp); fclose(fp);
} }
file_buf.add(_T("\0"),1); file_buf.add(_T("\0"),1);
value = (TCHAR *)file_buf.get(); value = (TCHAR *)file_buf.get();
} else if (!stricmp(define,_T("/math"))) { } else if (!_tcsicmp(define,_T("/math"))) {
int value1; int value1;
int value2; int value2;
@ -2927,8 +2925,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
SCRIPT_MSG(_T("!undef: \"%s\"\n"),line.gettoken_str(1)); SCRIPT_MSG(_T("!undef: \"%s\"\n"),line.gettoken_str(1));
return PS_OK; return PS_OK;
case TOK_P_PACKEXEHEADER: case TOK_P_PACKEXEHEADER:
_tcsnccpy(build_packname,line.gettoken_str(1),sizeof(build_packname)/sizeof(TCHAR)-1); _tcsnccpy(build_packname,line.gettoken_str(1),_countof(build_packname)-1);
_tcsnccpy(build_packcmd,line.gettoken_str(2),sizeof(build_packcmd)/sizeof(TCHAR)-1); _tcsnccpy(build_packcmd,line.gettoken_str(2),_countof(build_packcmd)-1);
SCRIPT_MSG(_T("!packhdr: filename=\"%s\", command=\"%s\"\n"), SCRIPT_MSG(_T("!packhdr: filename=\"%s\", command=\"%s\"\n"),
build_packname, build_packcmd); build_packname, build_packcmd);
return PS_OK; return PS_OK;
@ -2994,7 +2992,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *f = line.gettoken_str(1); TCHAR *f = line.gettoken_str(1);
if(!stricmp(f,_T("/nonfatal"))) { if(!_tcsicmp(f,_T("/nonfatal"))) {
if (line.getnumtokens()!=3) if (line.getnumtokens()!=3)
PRINTHELP(); PRINTHELP();
@ -3085,7 +3083,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
return PS_OK; return PS_OK;
case TOK_P_CD: case TOK_P_CD:
if (!line.gettoken_str(1)[0] || chdir(line.gettoken_str(1))) if (!line.gettoken_str(1)[0] || _tchdir(line.gettoken_str(1)))
{ {
ERROR_MSG(_T("!cd: error changing to: \"%s\"\n"),line.gettoken_str(1)); ERROR_MSG(_T("!cd: error changing to: \"%s\"\n"),line.gettoken_str(1));
return PS_ERROR; return PS_ERROR;
@ -3108,9 +3106,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int parmOffs=1; int parmOffs=1;
while (parmOffs < line.getnumtokens()) while (parmOffs < line.getnumtokens())
{ {
if (!stricmp(line.gettoken_str(parmOffs),_T("/ignorecase"))) { ignCase=true; parmOffs++; } if (!_tcsicmp(line.gettoken_str(parmOffs),_T("/ignorecase"))) { ignCase=true; parmOffs++; }
else if (!stricmp(line.gettoken_str(parmOffs),_T("/noerrors"))) { noErrors=true; parmOffs++; } else if (!_tcsicmp(line.gettoken_str(parmOffs),_T("/noerrors"))) { noErrors=true; parmOffs++; }
else if (!stricmp(line.gettoken_str(parmOffs),_T("/file"))) { isFile=true; parmOffs++; } else if (!_tcsicmp(line.gettoken_str(parmOffs),_T("/file"))) { isFile=true; parmOffs++; }
else break; else break;
} }
if (parmOffs+3 > line.getnumtokens()) if (parmOffs+3 > line.getnumtokens())
@ -3124,7 +3122,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (isFile) if (isFile)
{ {
FILE *fp=fopen(source_string,_T("r")); FILE *fp=FOPENTEXT(source_string,_T("r"));
if (!fp) if (!fp)
{ {
ERROR_MSG(_T("!searchparse /file: error opening \"%s\"\n"),source_string); ERROR_MSG(_T("!searchparse /file: error opening \"%s\"\n"),source_string);
@ -3150,8 +3148,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
while (p >= str && (*p == _T('\r') || *p == _T('\n'))) p--; while (p >= str && (*p == _T('\r') || *p == _T('\n'))) p--;
*++p=0; *++p=0;
bool endSlash = (str[0] && str[strlen(str)-1] == _T('\\')); bool endSlash = (str[0] && str[_tcsclen(str)-1] == _T('\\'));
if (tmpstr.getlen() || endSlash) tmpstr.add(str,strlen(str)); if (tmpstr.getlen() || endSlash) tmpstr.add(str,_tcsclen(str));
// if we have valid contents and not ending on slash, then done // if we have valid contents and not ending on slash, then done
if (!endSlash && (str[0] || tmpstr.getlen())) break; if (!endSlash && (str[0] || tmpstr.getlen())) break;
@ -3220,7 +3218,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
case TOK_P_SEARCHREPLACESTRING: case TOK_P_SEARCHREPLACESTRING:
{ {
int ignoreCase=!stricmp(line.gettoken_str(1),_T("/ignorecase")); int ignoreCase=!_tcsicmp(line.gettoken_str(1),_T("/ignorecase"));
if (line.getnumtokens()!=5+ignoreCase) PRINTHELP() if (line.getnumtokens()!=5+ignoreCase) PRINTHELP()
TCHAR *define=line.gettoken_str(1+ignoreCase); TCHAR *define=line.gettoken_str(1+ignoreCase);
@ -3239,7 +3237,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
while (*src) while (*src)
{ {
if (ignoreCase ? strnicmp(src,search,searchlen) : _tcsncmp(src,search,searchlen)) if (ignoreCase ? _tcsncicmp(src,search,searchlen) : _tcsncmp(src,search,searchlen))
valout.add(src++,1); valout.add(src++,1);
else else
{ {
@ -3334,7 +3332,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
uninstaller_icon = load_icon_file(line.gettoken_str(1)); uninstaller_icon = load_icon_file(line.gettoken_str(1));
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while loading icon from \"%s\": %s\n"), line.gettoken_str(1), err.what()); ERROR_MSG(_T("Error while loading icon from \"%s\": %s\n"), line.gettoken_str(1), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
return PS_OK; return PS_OK;
@ -3403,7 +3401,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_SECTION: case TOK_SECTION:
{ {
int a=1,unselected = 0; int a=1,unselected = 0;
if (!strcmpi(line.gettoken_str(1),_T("/o"))) if (!_tcsicmp(line.gettoken_str(1),_T("/o")))
{ {
unselected = 1; unselected = 1;
a++; a++;
@ -3414,7 +3412,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (line.gettoken_str(a+1)[0]) SCRIPT_MSG(_T(" ->(%s)"),line.gettoken_str(a+1)); if (line.gettoken_str(a+1)[0]) SCRIPT_MSG(_T(" ->(%s)"),line.gettoken_str(a+1));
SCRIPT_MSG(_T("\n")); SCRIPT_MSG(_T("\n"));
#ifndef NSIS_CONFIG_UNINSTALL_SUPPORT #ifndef NSIS_CONFIG_UNINSTALL_SUPPORT
if (!stricmp(line.gettoken_str(a),_T("uninstall"))) if (!_tcsicmp(line.gettoken_str(a),_T("uninstall")))
{ {
ERROR_MSG(_T("Error: Uninstall section declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n")); ERROR_MSG(_T("Error: Uninstall section declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n"));
return PS_ERROR; return PS_ERROR;
@ -3425,7 +3423,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (line.gettoken_str(a)[0]==_T('-')) if (line.gettoken_str(a)[0]==_T('-'))
{ {
if (!strnicmp(line.gettoken_str(a)+1,_T("un."),3)) if (!_tcsncicmp(line.gettoken_str(a)+1,_T("un."),3))
ret=add_section(_T("un."),line.gettoken_str(a+1)); ret=add_section(_T("un."),line.gettoken_str(a+1));
else else
ret=add_section(_T(""),line.gettoken_str(a+1)); ret=add_section(_T(""),line.gettoken_str(a+1));
@ -3448,7 +3446,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
for (wt = 1; wt < line.getnumtokens(); wt ++) for (wt = 1; wt < line.getnumtokens(); wt ++)
{ {
TCHAR *p=line.gettoken_str(wt); TCHAR *p=line.gettoken_str(wt);
if (!stricmp(p, _T("RO"))) if (!_tcsicmp(p, _T("RO")))
{ {
if (section_add_flags(SF_RO) != PS_OK) return PS_ERROR; if (section_add_flags(SF_RO) != PS_OK) return PS_ERROR;
SCRIPT_MSG(_T("[RO] ")); SCRIPT_MSG(_T("[RO] "));
@ -3483,7 +3481,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
TCHAR buf[1024]; TCHAR buf[1024];
int a=1,ex = 0; int a=1,ex = 0;
if (!strcmpi(line.gettoken_str(1),_T("/e"))) if (!_tcsicmp(line.gettoken_str(1),_T("/e")))
{ {
ex = 1; ex = 1;
a++; a++;
@ -3492,7 +3490,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (which_token == TOK_SECTIONGROUP || which_token == TOK_SUBSECTION) if (which_token == TOK_SECTIONGROUP || which_token == TOK_SUBSECTION)
{ {
TCHAR *s = line.gettoken_str(a); TCHAR *s = line.gettoken_str(a);
if (!s[0] || (!strcmpi(s, _T("un.")) && !s[3])) if (!s[0] || (!_tcsicmp(s, _T("un.")) && !s[3]))
PRINTHELP(); PRINTHELP();
} }
@ -3510,7 +3508,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
SCRIPT_MSG(_T("Function: \"%s\"\n"),line.gettoken_str(1)); SCRIPT_MSG(_T("Function: \"%s\"\n"),line.gettoken_str(1));
#ifndef NSIS_CONFIG_UNINSTALL_SUPPORT #ifndef NSIS_CONFIG_UNINSTALL_SUPPORT
if (!strnicmp(line.gettoken_str(1),_T("un."),3)) if (!_tcsncicmp(line.gettoken_str(1),_T("un."),3))
{ {
ERROR_MSG(_T("Error: Uninstall function declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n")); ERROR_MSG(_T("Error: Uninstall function declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n"));
return PS_ERROR; return PS_ERROR;
@ -3654,10 +3652,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int a = 1; int a = 1;
int trim = 0; int trim = 0;
while (line.gettoken_str(a)[0] == _T('/')) { while (line.gettoken_str(a)[0] == _T('/')) {
if (!strnicmp(line.gettoken_str(a),_T("/TRIM"),5)) { if (!_tcsncicmp(line.gettoken_str(a),_T("/TRIM"),5)) {
if (!stricmp(line.gettoken_str(a)+5,_T("LEFT"))) trim = 1; if (!_tcsicmp(line.gettoken_str(a)+5,_T("LEFT"))) trim = 1;
else if (!stricmp(line.gettoken_str(a)+5,_T("RIGHT"))) trim = 2; else if (!_tcsicmp(line.gettoken_str(a)+5,_T("RIGHT"))) trim = 2;
else if (!stricmp(line.gettoken_str(a)+5,_T("CENTER"))) trim = 3; else if (!_tcsicmp(line.gettoken_str(a)+5,_T("CENTER"))) trim = 3;
else PRINTHELP(); else PRINTHELP();
a++; a++;
} }
@ -3677,7 +3675,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (trim) { if (trim) {
TCHAR str[512]; TCHAR str[512];
if (line.getnumtokens()==a+1 && line.gettoken_str(a)[0]) if (line.getnumtokens()==a+1 && line.gettoken_str(a)[0])
strcpy(str, line.gettoken_str(a)); _tcscpy(str, line.gettoken_str(a));
else else
wsprintf(str, _T("Nullsoft Install System %s"), NSIS_VERSION); wsprintf(str, _T("Nullsoft Install System %s"), NSIS_VERSION);
@ -3701,7 +3699,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
res_editor->FreeResource(dlg); res_editor->FreeResource(dlg);
} }
catch (exception& err) { catch (exception& err) {
ERROR_MSG(_T("Error while triming branding text control: %s\n"), err.what()); ERROR_MSG(_T("Error while triming branding text control: %s\n"), CtoTString(err.what()));
return PS_ERROR; return PS_ERROR;
} }
#else #else
@ -3725,7 +3723,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
case TOK_SPACETEXTS: case TOK_SPACETEXTS:
{ {
if (!strcmpi(line.gettoken_str(1), _T("none"))) { if (!_tcsicmp(line.gettoken_str(1), _T("none"))) {
no_space_texts=true; no_space_texts=true;
SCRIPT_MSG(_T("SpaceTexts: none\n")); SCRIPT_MSG(_T("SpaceTexts: none\n"));
} }
@ -3831,13 +3829,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_CALL: case TOK_CALL:
if (!line.gettoken_str(1)[0] || (line.gettoken_str(1)[0]==_T(':') && !line.gettoken_str(1)[1] )) PRINTHELP() if (!line.gettoken_str(1)[0] || (line.gettoken_str(1)[0]==_T(':') && !line.gettoken_str(1)[1] )) PRINTHELP()
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
if (uninstall_mode && strnicmp(line.gettoken_str(1),_T("un."),3) if (uninstall_mode && _tcsncicmp(line.gettoken_str(1),_T("un."),3)
&& (GetUserVarIndex(line,1) < 0) && line.gettoken_str(1)[0]!=_T(':')) && (GetUserVarIndex(line,1) < 0) && line.gettoken_str(1)[0]!=_T(':'))
{ {
ERROR_MSG(_T("Call must be used with function names starting with \"un.\" in the uninstall section.\n")); ERROR_MSG(_T("Call must be used with function names starting with \"un.\" in the uninstall section.\n"));
PRINTHELP() PRINTHELP()
} }
if (!uninstall_mode && !strnicmp(line.gettoken_str(1),_T("un."),3)) if (!uninstall_mode && !_tcsncicmp(line.gettoken_str(1),_T("un."),3))
{ {
ERROR_MSG(_T("Call must not be used with functions starting with \"un.\" in the non-uninstall sections.\n")); ERROR_MSG(_T("Call must not be used with functions starting with \"un.\" in the non-uninstall sections.\n"));
PRINTHELP() PRINTHELP()
@ -3886,9 +3884,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
else else
{ {
if (p[0] == _T('\\') && p[1] != _T('\\')) p++; if (p[0] == _T('\\') && p[1] != _T('\\')) p++;
strncpy(out_path,p,1024-1); _tcsnccpy(out_path,p,1024-1);
if (*CharPrev(out_path,out_path+strlen(out_path))==_T('\\')) if (*CharPrev(out_path,out_path+_tcsclen(out_path))==_T('\\'))
*CharPrev(out_path,out_path+strlen(out_path))=0; // remove trailing slash *CharPrev(out_path,out_path+_tcsclen(out_path))=0; // remove trailing slash
} }
if (!*out_path) PRINTHELP() if (!*out_path) PRINTHELP()
SCRIPT_MSG(_T("CreateDirectory: \"%s\"\n"),out_path); SCRIPT_MSG(_T("CreateDirectory: \"%s\"\n"),out_path);
@ -3962,7 +3960,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
else if (which_token == TOK_CALLINSTDLL) else if (which_token == TOK_CALLINSTDLL)
{ {
int a = 2; int a = 2;
if (!stricmp(line.gettoken_str(a), _T("/NOUNLOAD"))) { if (!_tcsicmp(line.gettoken_str(a), _T("/NOUNLOAD"))) {
ent.offsets[3]=1; ent.offsets[3]=1;
a++; a++;
} }
@ -3991,7 +3989,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
int a=1; int a=1;
ent.which=EW_RENAME; ent.which=EW_RENAME;
if (!stricmp(line.gettoken_str(1),_T("/REBOOTOK"))) if (!_tcsicmp(line.gettoken_str(1),_T("/REBOOTOK")))
{ {
ent.offsets[2]=1; ent.offsets[2]=1;
a++; a++;
@ -4061,8 +4059,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *np=p; TCHAR *np=p;
while (*np && *np != _T('|')) np++; while (*np && *np != _T('|')) np++;
if (*np) *np++=0; if (*np) *np++=0;
for (x = 0 ; (unsigned) x < sizeof(list) / sizeof(list[0]) && strcmpi(list[x].str, p); x++); for (x = 0 ; (unsigned) x < _countof(list) && _tcsicmp(list[x].str, p); x++);
if ((unsigned) x < sizeof(list) / sizeof(list[0])) if ((unsigned) x < _countof(list))
{ {
r|=list[x].id; r|=list[x].id;
} }
@ -4080,7 +4078,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int a=3; int a=3;
if (line.getnumtokens() > 3) if (line.getnumtokens() > 3)
{ {
if (!strcmpi(line.gettoken_str(3),_T("/SD"))) if (!_tcsicmp(line.gettoken_str(3),_T("/SD")))
{ {
int k=line.gettoken_enum(4,retstr); int k=line.gettoken_enum(4,retstr);
if (k <= 0) PRINTHELP(); if (k <= 0) PRINTHELP();
@ -4153,9 +4151,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *s=(line.gettoken_str(7)); TCHAR *s=(line.gettoken_str(7));
TCHAR b[255]; TCHAR b[255];
for (unsigned int spos=0; (spos <= strlen(s)) && (spos <= 255); spos++) for (unsigned int spos=0; (spos <= _tcsclen(s)) && (spos <= 255); spos++)
b[spos]=toupper(*(s+spos)); b[spos]=_totupper(*(s+spos));
strcpy(s,b); _tcscpy(s,b);
if (*s) if (*s)
{ {
@ -4284,7 +4282,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int a = 2; int a = 2;
if (!strcmpi(line.gettoken_str(2),_T("/BRANDING"))) if (!_tcsicmp(line.gettoken_str(2),_T("/BRANDING")))
a++; a++;
{ {
@ -4295,7 +4293,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_ERROR; return PS_ERROR;
} }
if (!strcmpi(line.gettoken_str(a+1),_T("transparent"))) { if (!_tcsicmp(line.gettoken_str(a+1),_T("transparent"))) {
c.flags|=CC_BKB; c.flags|=CC_BKB;
c.lbStyle=BS_NULL; c.lbStyle=BS_NULL;
c.bkmode=TRANSPARENT; c.bkmode=TRANSPARENT;
@ -4366,15 +4364,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
for (int i = 3; i < line.getnumtokens(); i++) { for (int i = 3; i < line.getnumtokens(); i++) {
TCHAR *tok=line.gettoken_str(i); TCHAR *tok=line.gettoken_str(i);
if (tok[0]=='/') { if (tok[0]=='/') {
if (!strcmpi(tok,_T("/ITALIC"))) { if (!_tcsicmp(tok,_T("/ITALIC"))) {
SCRIPT_MSG(_T(" /ITALIC")); SCRIPT_MSG(_T(" /ITALIC"));
flags|=1; flags|=1;
} }
else if (!strcmpi(tok,_T("/UNDERLINE"))) { else if (!_tcsicmp(tok,_T("/UNDERLINE"))) {
SCRIPT_MSG(_T(" /UNDERLINE")); SCRIPT_MSG(_T(" /UNDERLINE"));
flags|=2; flags|=2;
} }
else if (!strcmpi(tok,_T("/STRIKE"))) { else if (!_tcsicmp(tok,_T("/STRIKE"))) {
SCRIPT_MSG(_T(" /STRIKE")); SCRIPT_MSG(_T(" /STRIKE"));
flags|=4; flags|=4;
} }
@ -4468,7 +4466,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
int a=1; int a=1;
ent.which=EW_DELETEFILE; ent.which=EW_DELETEFILE;
if (!stricmp(line.gettoken_str(a),_T("/REBOOTOK"))) if (!_tcsicmp(line.gettoken_str(a),_T("/REBOOTOK")))
{ {
a++; a++;
ent.offsets[1]=DEL_REBOOT; ent.offsets[1]=DEL_REBOOT;
@ -4503,13 +4501,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
ent.offsets[1]=DEL_DIR; ent.offsets[1]=DEL_DIR;
while (line.gettoken_str(a)[0]==_T('/')) while (line.gettoken_str(a)[0]==_T('/'))
{ {
if (!stricmp(line.gettoken_str(a),_T("/r"))) if (!_tcsicmp(line.gettoken_str(a),_T("/r")))
{ {
if (a == 3) PRINTHELP(); if (a == 3) PRINTHELP();
a++; a++;
ent.offsets[1]|=DEL_RECURSE; ent.offsets[1]|=DEL_RECURSE;
} }
else if (!stricmp(line.gettoken_str(a),_T("/REBOOTOK"))) else if (!_tcsicmp(line.gettoken_str(a),_T("/REBOOTOK")))
{ {
if (a == 3) PRINTHELP(); if (a == 3) PRINTHELP();
a++; a++;
@ -4543,11 +4541,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
set<tstring> excluded; set<tstring> excluded;
int a=1,attrib=0,rec=0,fatal=1; int a=1,attrib=0,rec=0,fatal=1;
if (!stricmp(line.gettoken_str(a),_T("/nonfatal"))) { if (!_tcsicmp(line.gettoken_str(a),_T("/nonfatal"))) {
fatal=0; fatal=0;
a++; a++;
} }
if (which_token == TOK_FILE && !stricmp(line.gettoken_str(a),_T("/a"))) if (which_token == TOK_FILE && !_tcsicmp(line.gettoken_str(a),_T("/a")))
{ {
#ifdef _WIN32 #ifdef _WIN32
attrib=1; attrib=1;
@ -4556,12 +4554,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
#endif #endif
a++; a++;
} }
if (!stricmp(line.gettoken_str(a),_T("/r"))) if (!_tcsicmp(line.gettoken_str(a),_T("/r")))
{ {
rec=1; rec=1;
a++; a++;
} }
else if (which_token == TOK_FILE && !strnicmp(line.gettoken_str(a),_T("/oname="),7)) else if (which_token == TOK_FILE && !_tcsncicmp(line.gettoken_str(a),_T("/oname="),7))
{ {
TCHAR *on=line.gettoken_str(a)+7; TCHAR *on=line.gettoken_str(a)+7;
a++; a++;
@ -4598,9 +4596,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
} }
if (!strnicmp(line.gettoken_str(a),_T("/x"),2)) if (!_tcsncicmp(line.gettoken_str(a),_T("/x"),2))
{ {
while (!strnicmp(line.gettoken_str(a),_T("/x"),2)) while (!_tcsncicmp(line.gettoken_str(a),_T("/x"),2))
{ {
a++; a++;
@ -4661,13 +4659,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int x; int x;
for (x = 0; x < 2; x ++) for (x = 0; x < 2; x ++)
{ {
if (!stricmp(line.gettoken_str(a),_T("/SILENT"))) if (!_tcsicmp(line.gettoken_str(a),_T("/SILENT")))
{ {
a++; a++;
ent.offsets[2]&=~FOF_SIMPLEPROGRESS; ent.offsets[2]&=~FOF_SIMPLEPROGRESS;
ent.offsets[2]|=FOF_SILENT; ent.offsets[2]|=FOF_SILENT;
} }
else if (!stricmp(line.gettoken_str(a),_T("/FILESONLY"))) else if (!_tcsicmp(line.gettoken_str(a),_T("/FILESONLY")))
{ {
a++; a++;
ent.offsets[2]|=FOF_FILESONLY; ent.offsets[2]|=FOF_FILESONLY;
@ -4731,9 +4729,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *np=p; TCHAR *np=p;
while (*np && *np != _T('|')) np++; while (*np && *np != _T('|')) np++;
if (*np) *np++=0; if (*np) *np++=0;
for (x = 0 ; (unsigned) x < sizeof(list)/sizeof(list[0]) && stricmp(list[x].str,p); x ++); for (x = 0 ; (unsigned) x < _countof(list) && _tcsicmp(list[x].str,p); x ++);
if ((unsigned) x < sizeof(list)/sizeof(list[0])) if ((unsigned) x < _countof(list))
{ {
r|=list[x].id; r|=list[x].id;
} }
@ -5079,7 +5077,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
int a=0; int a=0;
ent.which=EW_GETFULLPATHNAME; ent.which=EW_GETFULLPATHNAME;
if (line.getnumtokens()==4 && !stricmp(line.gettoken_str(1),_T("/SHORT"))) a++; if (line.getnumtokens()==4 && !_tcsicmp(line.gettoken_str(1),_T("/SHORT"))) a++;
else if (line.getnumtokens()==4 || *line.gettoken_str(1)==_T('/')) PRINTHELP() else if (line.getnumtokens()==4 || *line.gettoken_str(1)==_T('/')) PRINTHELP()
ent.offsets[0]=add_string(line.gettoken_str(2+a)); ent.offsets[0]=add_string(line.gettoken_str(2+a));
ent.offsets[1]=GetUserVarIndex(line, 1+a); ent.offsets[1]=GetUserVarIndex(line, 1+a);
@ -5206,7 +5204,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
TCHAR *s=line.gettoken_str(a); TCHAR *s=line.gettoken_str(a);
if (s[0] == _T('/')) if (s[0] == _T('/'))
{ {
if (stricmp(s,_T("/ifempty"))) PRINTHELP() if (_tcsicmp(s,_T("/ifempty"))) PRINTHELP()
a++; a++;
ent.offsets[4]=3; ent.offsets[4]=3;
} }
@ -5391,9 +5389,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
ent.offsets[0]=GetUserVarIndex(line, 1); ent.offsets[0]=GetUserVarIndex(line, 1);
{ {
TCHAR str[NSIS_MAX_STRLEN]; TCHAR str[NSIS_MAX_STRLEN];
strcpy(str, _T("%")); _tcscpy(str, _T("%"));
strcat(str, line.gettoken_str(2)); _tcscat(str, line.gettoken_str(2));
strcat(str, _T("%")); _tcscat(str, _T("%"));
ent.offsets[1]=add_string(str); ent.offsets[1]=add_string(str);
if (ent.offsets[0] < 0 || _tcsclen(line.gettoken_str(2))<1) PRINTHELP() if (ent.offsets[0] < 0 || _tcsclen(line.gettoken_str(2))<1) PRINTHELP()
} }
@ -5453,17 +5451,17 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle ent.offsets[0]=GetUserVarIndex(line, 1); // file handle
ent.offsets[3]=add_string(line.gettoken_str(2)); ent.offsets[3]=add_string(line.gettoken_str(2));
ent.offsets[1]=0; //openmode ent.offsets[1]=0; //openmode
if (!stricmp(line.gettoken_str(3),_T("r"))) if (!_tcsicmp(line.gettoken_str(3),_T("r")))
{ {
ent.offsets[1]=GENERIC_READ; ent.offsets[1]=GENERIC_READ;
ent.offsets[2]=OPEN_EXISTING; ent.offsets[2]=OPEN_EXISTING;
} }
else if (!stricmp(line.gettoken_str(3),_T("w"))) else if (!_tcsicmp(line.gettoken_str(3),_T("w")))
{ {
ent.offsets[1]=GENERIC_WRITE; ent.offsets[1]=GENERIC_WRITE;
ent.offsets[2]=CREATE_ALWAYS; ent.offsets[2]=CREATE_ALWAYS;
} }
else if (!stricmp(line.gettoken_str(3),_T("a"))) else if (!_tcsicmp(line.gettoken_str(3),_T("a")))
{ {
ent.offsets[1]=GENERIC_WRITE|GENERIC_READ; ent.offsets[1]=GENERIC_WRITE|GENERIC_READ;
ent.offsets[2]=OPEN_ALWAYS; ent.offsets[2]=OPEN_ALWAYS;
@ -5731,11 +5729,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
ent.which=EW_SETBRANDINGIMAGE; ent.which=EW_SETBRANDINGIMAGE;
for (int i = 1; i < line.getnumtokens(); i++) for (int i = 1; i < line.getnumtokens(); i++)
if (!strnicmp(line.gettoken_str(i),_T("/IMGID="),7)) { if (!_tcsncicmp(line.gettoken_str(i),_T("/IMGID="),7)) {
ent.offsets[1]=_ttoi(line.gettoken_str(i)+7); ent.offsets[1]=_ttoi(line.gettoken_str(i)+7);
SCRIPT_MSG(_T("/IMGID=%d "),ent.offsets[1]); SCRIPT_MSG(_T("/IMGID=%d "),ent.offsets[1]);
} }
else if (!stricmp(line.gettoken_str(i),_T("/RESIZETOFIT"))) { else if (!_tcsicmp(line.gettoken_str(i),_T("/RESIZETOFIT"))) {
ent.offsets[2]=1; // must be 1 or 0 ent.offsets[2]=1; // must be 1 or 0
SCRIPT_MSG(_T("/RESIZETOFIT ")); SCRIPT_MSG(_T("/RESIZETOFIT "));
} }
@ -5764,7 +5762,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
int a=1; int a=1;
if (!strcmpi(line.gettoken_str(1),_T("/GLOBAL"))) if (!_tcsicmp(line.gettoken_str(1),_T("/GLOBAL")))
{ {
a++; a++;
} }
@ -5797,7 +5795,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{ {
LANGID LangID=0; LANGID LangID=0;
int a = 1; int a = 1;
if (!strnicmp(line.gettoken_str(a),_T("/LANG="),6)) if (!_tcsncicmp(line.gettoken_str(a),_T("/LANG="),6))
LangID=_ttoi(line.gettoken_str(a++)+6); LangID=_ttoi(line.gettoken_str(a++)+6);
if (line.getnumtokens()!=a+2) PRINTHELP(); if (line.getnumtokens()!=a+2) PRINTHELP();
TCHAR *pKey = line.gettoken_str(a); TCHAR *pKey = line.gettoken_str(a);
@ -5938,7 +5936,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int i = 1; int i = 1;
int nounload = 0; int nounload = 0;
if (!strcmpi(line.gettoken_str(i), _T("/NOUNLOAD"))) { if (!_tcsicmp(line.gettoken_str(i), _T("/NOUNLOAD"))) {
i++; i++;
nounload++; nounload++;
} }
@ -5951,7 +5949,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
int w=parmst + (line.getnumtokens()-i - 1); int w=parmst + (line.getnumtokens()-i - 1);
ent.which=EW_PUSHPOP; ent.which=EW_PUSHPOP;
ent.offsets[0]=add_string(line.gettoken_str(w)); ent.offsets[0]=add_string(line.gettoken_str(w));
if (!strcmpi(line.gettoken_str(w), _T("/NOUNLOAD"))) nounloadmisused=1; if (!_tcsicmp(line.gettoken_str(w), _T("/NOUNLOAD"))) nounloadmisused=1;
ent.offsets[1]=0; ent.offsets[1]=0;
ent.offsets[2]=0; ent.offsets[2]=0;
ret=add_entry(&ent); ret=add_entry(&ent);
@ -6401,7 +6399,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser
if (tok && *tok) if (tok && *tok)
{ {
int toklen = _tcsclen(tok); int toklen = _tcsclen(tok);
while (*source_string && (ignCase?strnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++; while (*source_string && (ignCase?_tcsncicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++;
if (!*source_string) if (!*source_string)
{ {
@ -6425,7 +6423,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser
if (tok && *tok) if (tok && *tok)
{ {
int toklen = _tcsclen(tok); int toklen = _tcsclen(tok);
while (*source_string && (ignCase?strnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++; while (*source_string && (ignCase?_tcsncicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++;
maxlen = source_string - src_start; maxlen = source_string - src_start;
@ -6446,7 +6444,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser
if (maxlen < 0) ret->add(defout,src_start); if (maxlen < 0) ret->add(defout,src_start);
else else
{ {
TCHAR *p=strdup(src_start); TCHAR *p=_tcsdup(src_start);
if (p) if (p)
{ {
p[maxlen]=0; p[maxlen]=0;

View file

@ -290,7 +290,7 @@ void CEXEBuild::print_help(TCHAR *commandname)
int x; int x;
for (x = 0; x < TOK__LAST; x ++) for (x = 0; x < TOK__LAST; x ++)
{ {
if (!commandname || !stricmp(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("%s%s %s\n"),commandname?_T("Usage: "):_T(""),tokenlist[x].name,tokenlist[x].usage_str);
if (commandname) break; if (commandname) break;
@ -306,7 +306,7 @@ void CEXEBuild::print_help(TCHAR *commandname)
bool CEXEBuild::is_valid_token(TCHAR *s) bool CEXEBuild::is_valid_token(TCHAR *s)
{ {
for (int x = 0; x < TOK__LAST; x ++) for (int x = 0; x < TOK__LAST; x ++)
if (!stricmp(tokenlist[x].name,s)) if (!_tcsicmp(tokenlist[x].name,s))
return true; return true;
return false; return false;
} }
@ -315,7 +315,7 @@ int CEXEBuild::get_commandtoken(TCHAR *s, int *np, int *op, int *pos)
{ {
int x; int x;
for (x = 0; x < TOK__LAST; x ++) for (x = 0; x < TOK__LAST; x ++)
if (!stricmp(tokenlist[x].name,s)) if (!_tcsicmp(tokenlist[x].name,s))
{ {
*np=tokenlist[x].num_parms; *np=tokenlist[x].num_parms;
*op=tokenlist[x].opt_parms; *op=tokenlist[x].opt_parms;

View file

@ -13,7 +13,9 @@
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. * warranty.
*/ */
/* Unicode support by Jim Park -- 07/23/2007 */ /* Unicode support by Jim Park -- 07/23/2007 */
#include "Platform.h" #include "Platform.h"
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -24,6 +26,7 @@
#include "util.h" #include "util.h"
#include "strlist.h" #include "strlist.h"
#include "winchar.h" #include "winchar.h"
#ifndef _WIN32 #ifndef _WIN32
# include <ctype.h> # include <ctype.h>
# include <unistd.h> // for close(2) # include <unistd.h> // for close(2)