80 bytes saved
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1153 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
e350836d8d
commit
ef61466ef0
4 changed files with 37 additions and 33 deletions
|
@ -121,15 +121,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
if (cmdline[0] != '/') break;
|
if (cmdline[0] != '/') break;
|
||||||
cmdline++;
|
cmdline++;
|
||||||
|
|
||||||
|
#define END_OF_ARG(c) (((c)|' ')==' ')
|
||||||
|
|
||||||
#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] == 'S' && (cmdline[1] == ' ' || !cmdline[1])) silent++;
|
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1])) silent++;
|
||||||
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
|
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
|
||||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||||
if (*(int*)cmdline == *(int*)"NCRC" && (cmdline[4] == ' ' || !cmdline[4])) no_crc++;
|
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) no_crc++;
|
||||||
#endif//NSIS_CONFIG_CRC_SUPPORT
|
#endif//NSIS_CONFIG_CRC_SUPPORT
|
||||||
|
|
||||||
if (*(short*)cmdline == *(short*)"D=")
|
if (*(WORD*)cmdline == CHAR2_TO_WORD('D','='))
|
||||||
{
|
{
|
||||||
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
|
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
|
||||||
mystrcpy(state_install_directory,cmdline+2);
|
mystrcpy(state_install_directory,cmdline+2);
|
||||||
|
@ -138,7 +139,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip over our parm
|
// skip over our parm
|
||||||
while (*cmdline && *cmdline != ' ') cmdline=CharNext(cmdline);
|
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
|
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
|
||||||
|
@ -273,7 +274,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
if (g_is_uninstaller)
|
if (g_is_uninstaller)
|
||||||
{
|
{
|
||||||
char *p=cmdline;
|
char *p=cmdline;
|
||||||
while (*p) p++;
|
while (*p) p++;
|
||||||
|
|
||||||
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
|
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
|
||||||
|
|
||||||
|
|
|
@ -146,16 +146,15 @@ static HWND NSISCALL GetUIItem(HWND defhw, WORD def, WORD custom) {
|
||||||
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||||
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam)
|
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam)
|
||||||
static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
BOOL ret=0;
|
|
||||||
if (uMsg == WM_CTLCOLORSTATIC) {
|
if (uMsg == WM_CTLCOLORSTATIC) {
|
||||||
COLORREF color = GetWindowLong((HWND)lParam, GWL_USERDATA);
|
COLORREF color = GetWindowLong((HWND)lParam, GWL_USERDATA);
|
||||||
if (color) {
|
if (color) {
|
||||||
LOGBRUSH b={BS_SOLID, color-1, 0};
|
LOGBRUSH b={BS_SOLID, color-1, 0};
|
||||||
SetBkColor((HDC)wParam, b.lbColor);
|
SetBkColor((HDC)wParam, b.lbColor);
|
||||||
ret=(BOOL)CreateBrushIndirect(&b);
|
return (BOOL)CreateBrushIndirect(&b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
#else//NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
#else//NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||||
#define HandleStaticBkColor() 0
|
#define HandleStaticBkColor() 0
|
||||||
|
@ -405,9 +404,7 @@ int NSISCALL ui_doinstall(void)
|
||||||
static char str2[]="RichEdit20A";
|
static char str2[]="RichEdit20A";
|
||||||
if (!LoadLibrary(str1))
|
if (!LoadLibrary(str1))
|
||||||
{
|
{
|
||||||
((short*)str1)[3]=*(short*)"32";
|
*(WORD*)(str1+6) = CHAR2_TO_WORD('3','2');
|
||||||
//str1[6]='3';
|
|
||||||
//str1[7]='2';
|
|
||||||
LoadLibrary(str1);
|
LoadLibrary(str1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,7 +859,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
mini_memcpy(s,state_install_directory,NSIS_MAX_STRLEN);
|
mini_memcpy(s,state_install_directory,NSIS_MAX_STRLEN);
|
||||||
s[sizeof(s)-1]=0;
|
s[sizeof(s)-1]=0;
|
||||||
if (s[1] == ':') s[3]=0;
|
if (s[1] == ':') s[3]=0;
|
||||||
else if (s[0] == '\\' && s[1] == '\\') // \\ path
|
else if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path
|
||||||
{
|
{
|
||||||
addtrailingslash(s);
|
addtrailingslash(s);
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1043,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
tv.item.state=INDEXTOSTATEIMAGEMASK(l);
|
tv.item.state=INDEXTOSTATEIMAGEMASK(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps_tmpbuf[0] == '!' || (ps_tmpbuf[0] == '-' && ps_tmpbuf[1] == '!'))
|
if (ps_tmpbuf[0] == '!' || *(WORD*)ps_tmpbuf == CHAR2_TO_WORD('-','!'))
|
||||||
{
|
{
|
||||||
tv.item.pszText++;
|
tv.item.pszText++;
|
||||||
tv.item.stateMask|=TVIS_BOLD;
|
tv.item.stateMask|=TVIS_BOLD;
|
||||||
|
@ -1236,13 +1233,13 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
TVITEM tv;
|
TVITEM tv;
|
||||||
int l=1;
|
int l=1;
|
||||||
|
|
||||||
if (t->default_state & (1<<m_whichcfg))
|
if (t->default_state & (1<<m_whichcfg))
|
||||||
{
|
{
|
||||||
l++;
|
l++;
|
||||||
t->default_state|=DFS_SET;
|
t->default_state|=DFS_SET;
|
||||||
}
|
}
|
||||||
else t->default_state&=~DFS_SET;
|
else t->default_state&=~DFS_SET;
|
||||||
|
|
||||||
// this can't happen because of the above if()
|
// this can't happen because of the above if()
|
||||||
//if (t->default_state & DFS_RO) l+=3;
|
//if (t->default_state & DFS_RO) l+=3;
|
||||||
|
|
||||||
|
@ -1513,8 +1510,8 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
// -2 to allow for CR/LF
|
// -2 to allow for CR/LF
|
||||||
ListView_GetItemText(insthwnd,i,0,ptr,(endPtr-2)-ptr);
|
ListView_GetItemText(insthwnd,i,0,ptr,(endPtr-2)-ptr);
|
||||||
while (*ptr) ptr++;
|
while (*ptr) ptr++;
|
||||||
*ptr++ = '\r';
|
*(WORD*)ptr = CHAR2_TO_WORD('\r','\n');
|
||||||
*ptr++ = '\n';
|
ptr+=2;
|
||||||
}
|
}
|
||||||
*ptr++ = 0;
|
*ptr++ = 0;
|
||||||
GlobalUnlock(memory);
|
GlobalUnlock(memory);
|
||||||
|
|
|
@ -121,7 +121,7 @@ char * NSISCALL scanendslash(const char *str)
|
||||||
|
|
||||||
int NSISCALL validpathspec(char *ubuf)
|
int NSISCALL validpathspec(char *ubuf)
|
||||||
{
|
{
|
||||||
return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *CharNext(ubuf)==':'));
|
return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (ubuf[0] && *CharNext(ubuf)==':'));
|
||||||
}
|
}
|
||||||
|
|
||||||
int NSISCALL is_valid_instpath(char *s)
|
int NSISCALL is_valid_instpath(char *s)
|
||||||
|
@ -129,7 +129,7 @@ int NSISCALL is_valid_instpath(char *s)
|
||||||
int ivp=0;
|
int ivp=0;
|
||||||
// if 8 is set, req is 0, which means rootdirs are not allowed.
|
// if 8 is set, req is 0, which means rootdirs are not allowed.
|
||||||
int req=!(g_inst_cmnheader->misc_flags&8);
|
int req=!(g_inst_cmnheader->misc_flags&8);
|
||||||
if (s[0] == '\\' && s[1] == '\\') // \\ path
|
if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path
|
||||||
{
|
{
|
||||||
if (lastchar(s)!='\\') ivp++;
|
if (lastchar(s)!='\\') ivp++;
|
||||||
while (*s)
|
while (*s)
|
||||||
|
@ -144,14 +144,10 @@ int NSISCALL is_valid_instpath(char *s)
|
||||||
if (*s)
|
if (*s)
|
||||||
{
|
{
|
||||||
s=CharNext(s);
|
s=CharNext(s);
|
||||||
if (*s == ':')
|
if (*(WORD*)s == CHAR2_TO_WORD(':','\\'))
|
||||||
{
|
{
|
||||||
s=CharNext(s);
|
s+=2;
|
||||||
if (*s == '\\')
|
if (req || (*s && *s != '\\')) ivp++;
|
||||||
{
|
|
||||||
s=CharNext(s);
|
|
||||||
if (req || (*s && *s != '\\')) ivp++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,8 +293,8 @@ void NSISCALL recursive_create_directory(char *directory)
|
||||||
while (*p == ' ') p=CharNext(p);
|
while (*p == ' ') p=CharNext(p);
|
||||||
if (!*p) return;
|
if (!*p) return;
|
||||||
tp=CharNext(p);
|
tp=CharNext(p);
|
||||||
if (*tp == ':' && tp[1] == '\\') p=tp+2;
|
if (*(WORD*)tp == CHAR2_TO_WORD(':','\\')) p=tp+2;
|
||||||
else if (p[0] == '\\' && p[1] == '\\')
|
else if (*(WORD*)p == CHAR2_TO_WORD('\\','\\'))
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; x < 2; x ++)
|
for (x = 0; x < 2; x ++)
|
||||||
|
@ -399,14 +395,13 @@ int NSISCALL myatoi(char *s)
|
||||||
{
|
{
|
||||||
int c=*s++;
|
int c=*s++;
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= '0' && c <= '9') c-='0';
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') c = (c & 7) + 9;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
else if (*s == '0' && s[1] >= '0' && s[1] <= '7')
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -424,8 +419,9 @@ int NSISCALL myatoi(char *s)
|
||||||
if (*s == '-') { s++; sign++; }
|
if (*s == '-') { s++; sign++; }
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*s++ - '0';
|
int c=*s++;
|
||||||
if (c < 0 || c > 9) break;
|
if (c >= '0' && c <= '9') c-='0';
|
||||||
|
else break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,3 +54,13 @@ char * NSISCALL scanendslash(const char *str);
|
||||||
int NSISCALL is_valid_instpath(char *s);
|
int NSISCALL is_valid_instpath(char *s);
|
||||||
BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
||||||
void * NSISCALL mini_memcpy(void *out, const void *in, int len);
|
void * NSISCALL mini_memcpy(void *out, const void *in, int len);
|
||||||
|
|
||||||
|
// Turn a pair of chars into a word
|
||||||
|
// Turn four chars into a dword
|
||||||
|
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
||||||
|
#define CHAR2_TO_WORD(a,b) (((WORD)(b))|((a)<<8))
|
||||||
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16))
|
||||||
|
#else
|
||||||
|
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
||||||
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue