- Fixed ComponentText without InstTypes

- Made it impossible to install to non-existing drives/removable drives with no media
- Fixed a crash caused by using a LangString in InstallDir
- No more Windows error message when a registered DLL dependency can't be found


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2957 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-09-23 19:01:19 +00:00
parent 3988e924f7
commit 6d63dd3a58
6 changed files with 68 additions and 70 deletions

View file

@ -1892,7 +1892,11 @@ again:
p->parms[1] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1, NLF_UCOMP_SUBTEXT1)); p->parms[1] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1, NLF_UCOMP_SUBTEXT1));
if (!p->parms[2]) if (!p->parms[2])
p->parms[2] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT2, NLF_UCOMP_SUBTEXT2)); p->parms[2] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT2, NLF_UCOMP_SUBTEXT2));
if (!p->parms[4]) if (!p->parms[3] && !uninstall_mode && HasUserDefined(NLF_COMP_SUBTEXT1))
p->parms[3] = p->parms[1];
if (!p->parms[4] && !uninstall_mode && HasUserDefined(NLF_COMP_SUBTEXT2))
p->parms[4] = p->parms[2];
else if (!p->parms[4])
p->parms[4] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1_NO_INST_TYPES, NLF_UCOMP_SUBTEXT1_NO_INST_TYPES)); p->parms[4] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1_NO_INST_TYPES, NLF_UCOMP_SUBTEXT1_NO_INST_TYPES));
DefineInnerLangString(NLF_SPACE_REQ); DefineInnerLangString(NLF_SPACE_REQ);

View file

@ -110,6 +110,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
if (cmdline[0] != '/') break; if (cmdline[0] != '/') break;
cmdline++; cmdline++;
// this only works with spaces because they have just one bit on
#define END_OF_ARG(c) (((c)|' ')==' ') #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)

View file

@ -171,6 +171,8 @@ int NSISCALL ui_doinstall(void)
static WNDCLASS wc; // richedit subclassing and bgbg creation static WNDCLASS wc; // richedit subclassing and bgbg creation
g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE;
set_language();
if (!is_valid_instpath(state_install_directory)) if (!is_valid_instpath(state_install_directory))
{ {
if (header->install_reg_key_ptr) if (header->install_reg_key_ptr)
@ -201,8 +203,9 @@ int NSISCALL ui_doinstall(void)
d=GetFileAttributes(p); d=GetFileAttributes(p);
if (d == (DWORD)-1 || !(d&FILE_ATTRIBUTE_DIRECTORY)) if (d == (DWORD)-1 || !(d&FILE_ATTRIBUTE_DIRECTORY))
{ {
e=scanendslash(p); // if there is no back-slash, the string will become empty, but that's ok because
if (e>=p) *e=0; // it would make an invalid instdir anyway
trimslashtoend(p);
} }
} }
} }
@ -224,8 +227,6 @@ int NSISCALL ui_doinstall(void)
} }
#endif #endif
set_language();
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED);
#ifdef NSIS_SUPPORT_BGBG #ifdef NSIS_SUPPORT_BGBG
@ -790,6 +791,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START) if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START)
{ {
static char s[NSIS_MAX_STRLEN]; static char s[NSIS_MAX_STRLEN];
char *p;
int is_valid_path; int is_valid_path;
int x; int x;
int total=0, available=-1; int total=0, available=-1;
@ -799,16 +801,9 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
is_valid_path=is_valid_instpath(dir); is_valid_path=is_valid_instpath(dir);
mystrcpy(s,dir); mystrcpy(s,dir);
if (s[1] == ':') s[3]=0; p=skip_root(s);
else if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path if (p)
{ *p=0;
char *p = mystrstr(s+2,"\\");
if (p) {
p = mystrstr(p+1,"\\");
if (p) *p = 0;
}
addtrailingslash(s);
}
if (GetDiskFreeSpace(s,&spc,&bps,&fc,&tc)) if (GetDiskFreeSpace(s,&spc,&bps,&fc,&tc))
{ {

View file

@ -229,21 +229,12 @@ static int NSISCALL ExecuteEntry(entry *entry_)
char *buf1=GetStringFromParm(-0x10); char *buf1=GetStringFromParm(-0x10);
log_printf3("CreateDirectory: \"%s\" (%d)",buf1,parm1); log_printf3("CreateDirectory: \"%s\" (%d)",buf1,parm1);
{ {
char *tp=CharNext(buf1);
char *p=buf1; char *p=buf1;
char c='c'; char c='c';
if (*p) { if (*p) {
if (*(WORD*)tp == CHAR2_TO_WORD(':','\\')) p=tp+2; p = skip_root(buf1);
else if (*(WORD*)p == CHAR2_TO_WORD('\\','\\')) if (!p)
{ break;
int x=4;
while (x--)
{
while (*p != '\\' && *p) p=CharNext(p); // skip host then share
p=CharNext(p);
}
}
else break;
while (c) while (c)
{ {
WIN32_FIND_DATA *fd; WIN32_FIND_DATA *fd;
@ -767,8 +758,8 @@ static int NSISCALL ExecuteEntry(entry *entry_)
0, 0,
GetStringFromParm(0x00), GetStringFromParm(0x00),
IMAGE_BITMAP, IMAGE_BITMAP,
parm2?r.right:0, parm2*r.right,
parm2?r.bottom:0, parm2*r.bottom,
LR_LOADFROMFILE LR_LOADFROMFILE
); );
hImage = (HANDLE)SendMessage( hImage = (HANDLE)SendMessage(
@ -924,6 +915,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
case EW_REGISTERDLL: case EW_REGISTERDLL:
{ {
exec_error++; exec_error++;
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
if (SUCCEEDED(g_hres)) if (SUCCEEDED(g_hres))
{ {
HANDLE h; HANDLE h;
@ -978,6 +970,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
update_status_text(LANG_NOOLE,buf1); update_status_text(LANG_NOOLE,buf1);
log_printf("Error registering DLL: Could not initialize OLE"); log_printf("Error registering DLL: Could not initialize OLE");
} }
SetErrorMode(0);
} }
break; break;
#endif #endif

View file

@ -133,24 +133,15 @@ char *NSISCALL addtrailingslash(char *str)
void NSISCALL trimslashtoend(char *buf) void NSISCALL trimslashtoend(char *buf)
{ {
char *p=scanendslash(buf); char *p = CharPrev(buf, buf + mystrlen(buf));
if (p<buf) p=buf; do
*p=0;
}
char * NSISCALL scanendslash(const char *str)
{
char *s=CharPrev(str,str+mystrlen(str));
if (!*str) return (char*)str-1;
for (;;)
{ {
char *t; if (*p == '\\')
if ('\\' == *s) return s; break;
t=CharPrev(str,s); p = CharPrev(buf, p);
if (t==s) return (char*)str-1; } while (p > buf);
s=t;
} *p = 0;
} }
int NSISCALL validpathspec(char *ubuf) int NSISCALL validpathspec(char *ubuf)
@ -158,34 +149,48 @@ int NSISCALL validpathspec(char *ubuf)
return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (ubuf[0] && *CharNext(ubuf)==':')); return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (ubuf[0] && *CharNext(ubuf)==':'));
} }
int NSISCALL is_valid_instpath(char *s) char * NSISCALL skip_root(char *path)
{ {
int ivp=0; char *p = CharNext(path);
// if CH_FLAGS_NO_ROOT_DIR is set, req is 0, which means rootdirs are not allowed. char *p2 = CharNext(p);
int req=!(g_flags&CH_FLAGS_NO_ROOT_DIR);
if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path if (*path && *(WORD*)p == CHAR2_TO_WORD(':', '\\'))
{ {
if (lastchar(s)!='\\') ivp++; return CharNext(p2);
while (*s) }
else if (*(WORD*)path == CHAR2_TO_WORD('\\','\\'))
{
// skip host and share name
int x = 2;
while (x--)
{ {
if (*s == '\\') ivp++; while (*p2 != '\\')
s=CharNext(s); {
if (!*p2)
return NULL;
p2 = CharNext(p2);
}
p2 = CharNext(p2);
} }
ivp/=5-req;
return p2;
} }
else else
return NULL;
}
int NSISCALL is_valid_instpath(char *s)
{
int ret = 0;
char *p = skip_root(s);
if (p && ((*p && *p != '\\') || !(g_flags & CH_FLAGS_NO_ROOT_DIR)))
{ {
if (*s) char pb = *p;
{ *p = 0;
s=CharNext(s); ret = GetFileAttributes(s) != (DWORD)-1;
if (*(WORD*)s == CHAR2_TO_WORD(':','\\')) *p = pb;
{
s+=2;
if (req || (*s && *s != '\\')) ivp++;
}
}
} }
return ivp; return ret;
} }
char * NSISCALL mystrstr(char *a, char *b) char * NSISCALL mystrstr(char *a, char *b)
@ -674,13 +679,13 @@ char * NSISCALL validate_filename(char *in) {
char *out; char *out;
char *out_save; char *out_save;
while (*in == ' ') in=CharNext(in); while (*in == ' ') in=CharNext(in);
if (in[0] && in[1] && in[2]) { if (in[0] == '\\' && in[1] == '\\' && in[2] == '?' && in[3] == '\\') {
// at least four bytes // at least four bytes
if (*(DWORD*)in == CHAR4_TO_DWORD('\\', '\\', '?', '\\')) in += 4; in += 4;
} }
if (*in) { if (*in) {
// at least two bytes // at least two bytes
if (in[0] && validpathspec(in)) in += 2; if (validpathspec(in)) in += 2;
} }
out = out_save = in; out = out_save = in;
while (*(char*)&cur_char = *in) { while (*(char*)&cur_char = *in) {

View file

@ -56,7 +56,7 @@ char * NSISCALL addtrailingslash(char *str);
//char NSISCALL lastchar(const char *str); //char NSISCALL lastchar(const char *str);
#define lastchar(str) *CharPrev(str,str+mystrlen(str)) #define lastchar(str) *CharPrev(str,str+mystrlen(str))
void NSISCALL trimslashtoend(char *buf); void NSISCALL trimslashtoend(char *buf);
char * NSISCALL scanendslash(const char *str); char * NSISCALL skip_root(char *path);
int NSISCALL is_valid_instpath(char *s); int NSISCALL is_valid_instpath(char *s);
char * NSISCALL validate_filename(char *fn); char * NSISCALL validate_filename(char *fn);
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew); void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);