more simple TCHARs fixes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6047 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-04-12 16:00:17 +00:00
parent a92fad7347
commit 64a0f32e52
38 changed files with 1831 additions and 1961 deletions

View file

@ -2,7 +2,6 @@ target = 'makensisw'
files = Split("""
makensisw.cpp
noclib.cpp
toolbar.cpp
utils.cpp
version.cpp
@ -34,6 +33,7 @@ libs = Split("""
user32
gdi32
shell32
shlwapi
comdlg32
comctl32
wsock32
@ -45,6 +45,7 @@ docs = Split("""
""")
Import('BuildUtil')
Import('_tWinMain')
BuildUtil(
target,
@ -52,7 +53,7 @@ BuildUtil(
libs,
res = res,
resources = resources,
entry = 'WinMain',
entry = _tWinMain,
defines = ['RELEASE=2.3'],
docs = docs,
root_util = True

View file

@ -24,9 +24,9 @@
#include "makensisw.h"
#include <windowsx.h>
#include <shlwapi.h>
#include <stdio.h>
#include "resource.h"
#include "noclib.h"
#include "toolbar.h"
#include "update.h"
@ -41,9 +41,9 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int
int status;
HACCEL haccel;
my_memset(&g_sdata,0,sizeof(NSCRIPTDATA));
my_memset(&g_resize,0,sizeof(NRESIZEDATA));
my_memset(&g_find,0,sizeof(NFINDREPLACE));
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
memset(&g_resize,0,sizeof(NRESIZEDATA));
memset(&g_find,0,sizeof(NFINDREPLACE));
g_sdata.hInstance=GetModuleHandle(0);
g_sdata.symbols = NULL;
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, _T("makensis win32 signint event"));
@ -130,10 +130,10 @@ void ProcessCommandLine()
if (argc > 1) {
for (i = 1; i < argc; i++)
{
if (!lstrncmpi(argv[i], _T("/XSetCompressor "), lstrlen(_T("/XSetCompressor "))))
if (!StrCmpNI(argv[i], _T("/XSetCompressor "), lstrlen(_T("/XSetCompressor "))))
{
TCHAR *p = argv[i] + lstrlen(_T("/XSetCompressor "));
if(!lstrncmpi(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
if(!StrCmpNI(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
{
p += lstrlen(_T("/FINAL "));
}
@ -481,7 +481,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (g_sdata.input_script) {
TCHAR str[MAX_PATH],*str2;
lstrcpy(str,g_sdata.input_script);
str2=my_strrchr(str,_T('\\'));
str2=_tcsrchr(str,_T('\\'));
if(str2!=NULL) *(str2+1)=0;
ShellExecute(g_sdata.hwnd,_T("open"),str,NULL,NULL,SW_SHOWNORMAL);
}
@ -656,7 +656,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case IDM_FIND:
{
if (!g_find.uFindReplaceMsg) g_find.uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
my_memset(&g_find.fr, 0, sizeof(FINDREPLACE));
memset(&g_find.fr, 0, sizeof(FINDREPLACE));
g_find.fr.lStructSize = sizeof(FINDREPLACE);
g_find.fr.hwndOwner = hwndDlg;
g_find.fr.Flags = FR_NOUPDOWN;
@ -743,7 +743,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
char szBuf[1024];
TCHAR szBuf[1024];
DWORD dwRead = 1;
DWORD dwExit = !STILL_ACTIVE;
while (dwExit == STILL_ACTIVE || dwRead) {
@ -986,7 +986,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if(n > 0) {
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
if(my_strstr(buf,_T(" ")) || my_strstr(buf,_T("\t"))) {
if(_tcsstr(buf,_T(" ")) || _tcsstr(buf,_T("\t"))) {
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
GlobalFree(buf);
break;
@ -1028,7 +1028,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if(n > 0) {
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
TCHAR *p = my_strstr(buf,_T("="));
TCHAR *p = _tcsstr(buf,_T("="));
if(p) {
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
*p=0;

View file

@ -1,72 +0,0 @@
/*
Copyright (c) 2002 Robert Rainwater
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <windows.h>
#include "noclib.h"
// kickik's clib methods
char *my_strrchr(const char *string, int c) {
for (int i=lstrlen(string); i>=0; i--)
if (string[i]==c) return (char*)&string[i];
return 0;
}
char *my_strstr(char *i, char *s) {
if (lstrlen(i)>=lstrlen(s)) while (i[lstrlen(s)-1]) {
int l=lstrlen(s)+1;
char *ii=i;
char *is=s;
while (--l>0) {
if (*ii != *is) break;
ii++;
is++;
}
if (l==0) return i;
i++;
}
return NULL;
}
void *my_memset(void *dest, int c, size_t count) {
for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
return dest;
}
// iceman_k's clib methods
int lstrncmp(char *s1, const char *s2, int chars)
{
while ((chars > 0) && (*s1) && (*s2) && (*(s1) == *(s2))) chars--, s1++, s2++;
if ((chars == 0) || (*s1 == *s2)) return 0;
return (*s1 - *s2);
}
int lstrncmpi(char *s1, const char *s2, int chars)
{
while (chars-- && *s1 && *s2)
{
char ss1=*s1++;
char ss2=*s2++;
if (ss1>='a' && ss1 <= 'z') ss1+='A'-'a';
if (ss2>='a' && ss2 <= 'z') ss2+='A'-'a';
if (ss1 != ss2) return ss1-ss2;
}
return 0;
}

View file

@ -1,33 +0,0 @@
/*
Copyright (c) 2002 Robert Rainwater
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef NOCLIB_H
#define NOCLIB_H
// kickik's clib methods
char *my_strstr(char *i, char *s);
char *my_strrchr(const char *string, int c);
void *my_memset(void *dest, int c, size_t count);
// iceman_k's clib methods
int lstrncmp(char *s1, const char *s2, int chars);
int lstrncmpi(char *s1, const char *s2, int chars);
#endif

View file

@ -25,7 +25,6 @@
#include "makensisw.h"
#include "resource.h"
#include "noclib.h"
#include "toolbar.h"
#include "../ExDLL/nsis_tchar.h"
@ -133,7 +132,7 @@ void UpdateToolBarCompressorButton()
TCHAR temp[64]; // increased to 64. Hit limit 08/20/2007 -- Jim Park.
TOOLINFO ti;
my_memset(&ti, 0, sizeof(TOOLINFO));
memset(&ti, 0, sizeof(TOOLINFO));
if(g_sdata.compressor >= COMPRESSOR_SCRIPT && g_sdata.compressor <= COMPRESSOR_BEST) {
iBitmap = compressor_bitmaps[(int)g_sdata.compressor];
@ -146,7 +145,7 @@ void UpdateToolBarCompressorButton()
IDS_COMPRESSOR,
temp,
COUNTOF(temp));
my_memset(szBuffer, 0, sizeof(szBuffer));
memset(szBuffer, 0, sizeof(szBuffer));
lstrcat(szBuffer,temp);
lstrcat(szBuffer,_T(" ["));
LoadString(g_sdata.hInstance,
@ -174,7 +173,7 @@ void AddToolBarButtonTooltip(int id, int iString)
TCHAR szBuffer[64];
RECT rect;
my_memset(&ti, 0, sizeof(TOOLINFO));
memset(&ti, 0, sizeof(TOOLINFO));
SendMessage(g_toolbar.hwnd, TB_GETITEMRECT, id, (LPARAM) (LPRECT) &rect);

View file

@ -2,7 +2,6 @@
#include "makensisw.h"
#include "update.h"
#include "noclib.h"
#include "jnetlib/httpget.h"
#include "../ExDLL/nsis_tchar.h"
@ -62,14 +61,14 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
if (getProxyInfo(pbuf))
{
p=my_strstr(pbuf,"http=");
p=strstr(pbuf,"http=");
if (!p) p=pbuf;
else {
p+=5;
}
char *tp=my_strstr(p,";");
char *tp=strstr(p,";");
if (tp) *tp=0;
char *p2=my_strstr(p,"=");
char *p2=strstr(p,"=");
if (p2) p=0; // we found the wrong proxy
}
@ -140,7 +139,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
void Update() {
DWORD dwThreadId;
if (my_strstr(g_sdata.brandingv,_T("cvs")))
if (_tcsstr(g_sdata.brandingv,_T("cvs")))
{
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
return;

View file

@ -25,7 +25,7 @@
#include "makensisw.h"
#include "resource.h"
#include "toolbar.h"
#include "noclib.h"
#include <shlwapi.h>
#ifdef _countof
#define COUNTOF _countof
@ -60,13 +60,13 @@ int SetArgv(const TCHAR *cmdLine, int *argc, TCHAR ***argv)
}
}
argSpaceSize = size * sizeof(TCHAR *) + lstrlen(cmdLine) + 1;
argSpaceSize = size * sizeof(TCHAR *) + (lstrlen(cmdLine) + 1) * sizeof(TCHAR);
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
if (!argSpace)
return 0;
*argv = (TCHAR **) argSpace;
argSpace += size * sizeof(TCHAR *);
argSpace = (TCHAR *) ((*argv)+size);
size--;
p = cmdLine;
@ -241,13 +241,13 @@ void SetCompressorStats()
DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT);
lstrcat(g_sdata.compressor_stats,buf);
if(!lstrncmp(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
if(!StrCmpN(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
break;
}
}
else {
DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT);
if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
if(!StrCmpN(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
found = true;
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
lstrcat(g_sdata.compressor_stats,buf);
@ -622,7 +622,7 @@ int InitBranding() {
void InitTooltips(HWND h) {
if (h == NULL) return;
my_memset(&g_tip,0,sizeof(NTOOLTIP));
memset(&g_tip,0,sizeof(NTOOLTIP));
g_tip.tip_p = h;
INITCOMMONCONTROLSEX icx;
icx.dwSize = sizeof(icx);
@ -668,7 +668,7 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
void ShowDocs() {
TCHAR pathf[MAX_PATH],*path;
GetModuleFileName(NULL,pathf,sizeof(pathf));
path=my_strrchr(pathf,_T('\\'));
path=_tcsrchr(pathf,_T('\\'));
if(path!=NULL) *path=0;
lstrcat(pathf,LOCALDOCS);
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
@ -749,7 +749,7 @@ void PushMRUFile(TCHAR* fname)
return;
}
my_memset(full_file_name,0,sizeof(full_file_name));
memset(full_file_name,0,sizeof(full_file_name));
rv = GetFullPathName(fname,COUNTOF(full_file_name),full_file_name,NULL);
if (rv == 0) {
return;
@ -783,19 +783,19 @@ void BuildMRUMenus()
for(i = 0; i < MRU_LIST_SIZE; i++) {
if(g_mru_list[i][0]) {
my_memset(buf,0,sizeof(buf));
my_memset(&mii, 0, sizeof(mii));
memset(buf,0,sizeof(buf));
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = IDM_MRU_FILE+i;
mii.fType = MFT_STRING;
wsprintf(buf, _T("&%d "), i + 1);
if(lstrlen(g_mru_list[i]) > MRU_DISPLAY_LENGTH) {
TCHAR *p = my_strrchr(g_mru_list[i],_T('\\'));
TCHAR *p = _tcsrchr(g_mru_list[i],_T('\\'));
if(p) {
p++;
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
my_memset(buf2,0,sizeof(buf2));
memset(buf2,0,sizeof(buf2));
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
lstrcat(buf2,_T("..."));
@ -833,7 +833,7 @@ void BuildMRUMenus()
}
hMenu = g_sdata.toolsSubmenu;
my_memset(&mii, 0, sizeof(mii));
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;

View file

@ -21,11 +21,12 @@
Unicode support by Jim Park -- 08/17/2007
*/
#include "makensisw.h"
#define REALSTR(x) #x
#define STR(x) REALSTR(x)
#ifdef RELEASE
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
const TCHAR *NSISW_VERSION = _T("MakeNSISW ") _T(STR(RELEASE)) _T(" (NSIS Compiler Interface)");
#else
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
const TCHAR *NSISW_VERSION = _T("MakeNSISW ") __TDATE__;
#endif