From 323c9af32079c97d85352056928a6cfc6939cfaf Mon Sep 17 00:00:00 2001 From: ramon18 Date: Tue, 8 Jul 2003 23:18:47 +0000 Subject: [PATCH] Fixed QUIT problem inside custom pages, user-variables activated and command "Dim" changed to "Var", language strings inside other strings are replaced git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2704 212acab6-be3b-0410-9dea-997c60f758d6 --- Examples/UserVars.nsi | 6 +++--- Source/exehead/Main.c | 33 ++++++++++++++++++++++++++------- Source/exehead/Ui.c | 3 ++- Source/exehead/config.h | 4 ++-- Source/exehead/exec.c | 13 ------------- Source/exehead/util.c | 13 +++++++++++++ Source/exehead/util.h | 1 + Source/tokens.cpp | 2 +- 8 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Examples/UserVars.nsi b/Examples/UserVars.nsi index 06076946..2fb40bd9 100644 --- a/Examples/UserVars.nsi +++ b/Examples/UserVars.nsi @@ -33,9 +33,9 @@ ;-------------------------------- ; Declaration of User Variables with command DIM, allowed charaters for variables names : [a-z][A-Z][0-9] and '_' - DIM "un.Info" ; this one can only be used in uninstaller methods - DIM "Name" - DIM "Serial" + Var "un.Info" ; this one can only be used in uninstaller methods + Var "Name" + Var "Serial" ;-------------------------------- ;Installer Sections diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index 50defde6..849a5e01 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -102,19 +102,37 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, char *realcmds; char seekchar=' '; char *cmdline; -#ifdef NSIS_SUPPORT_NAMED_USERVARS - g_usrvars = (NSIS_STRING*)my_GlobalAlloc(USER_VARS_COUNT*sizeof(NSIS_STRING)); -#endif + //WIN32_FIND_DATA *pfd; InitCommonControls(); + + mystrcpy(g_caption,_LANG_GENERIC_ERROR); GetTempPath(sizeof(state_temp_dir), state_temp_dir); - CreateDirectory(state_temp_dir,NULL); + validate_filename(state_temp_dir); + + // This is not so effective...!!??! + // The perfect way is: + // - Test Access for filewrite + // - Test Access for folder creation (needed for plugins) + // - And if one of the above tests fail, change to "$WINDIR\TEMP" and re-test + // but this will take to much size in exehead and is unreliable too + /* + pfd = file_exists(state_temp_dir); + if (!pfd || !(pfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + // Setup temp dir to "$WINDIR\TEMP" + mystrcpy(state_temp_dir+GetWindowsDirectory(state_temp_dir, sizeof(state_temp_dir)), "\\Temp"); + if ( !file_exists(state_temp_dir) || !CreateDirectory(state_temp_dir, NULL) ) + { + m_Err = _LANG_ERRORWRITINGTEMP; + goto end; + } + } + */ lstrcpyn(state_command_line,GetCommandLine(),NSIS_MAX_STRLEN); - mystrcpy(g_caption,_LANG_GENERIC_ERROR); - g_hInstance=GetModuleHandle(NULL); GetModuleFileName(g_hInstance,state_exe_directory,NSIS_MAX_STRLEN); @@ -304,7 +322,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, for (x = 0; x < 26; x ++) { - static char s[]="A~NSISu_.exe"; + // File name need slash before coz temp dir was changed by validate_filename(...) + static char s[]="\\A~NSISu_.exe"; static char buf2[NSIS_MAX_STRLEN*2]; static char ibuf[NSIS_MAX_STRLEN]; diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index c8a7ddde..2e6f6d79 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -395,7 +395,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_page>=0) { #ifdef NSIS_SUPPORT_CODECALLBACKS // Call leave function. If Abort used don't move to the next page. - if (m_delta==1) if (ExecuteCodeSegment(this_page->leavefunc,NULL)) return 1; + // But if quit called we must exit now + if (m_delta==1) if (ExecuteCodeSegment(this_page->leavefunc,NULL)) return !g_quit_flag; #endif // if the last page was a custom page, wait for it to finish by itself. diff --git a/Source/exehead/config.h b/Source/exehead/config.h index c24dcfdd..b9082402 100644 --- a/Source/exehead/config.h +++ b/Source/exehead/config.h @@ -196,14 +196,14 @@ // Added by ramon 3 jun 2003 // NSIS_SUPPORT_NAMED_USERVARS enables support for user variables -//#define NSIS_SUPPORT_NAMED_USERVARS +#define NSIS_SUPPORT_NAMED_USERVARS // Added by ramon 5 jun 2003 // NSIS_SUPPORT_VERSION_INFO enables support for version information on final exe #define NSIS_SUPPORT_VERSION_INFO // NSIS_SUPPORT_LANG_IN_STRINGS enables support for language strings inside other strings -//#define NSIS_SUPPORT_LANG_IN_STRINGS +#define NSIS_SUPPORT_LANG_IN_STRINGS // NSIS_FIX_DEFINES_IN_STRINGS fix defines inside defines and handles chars $ perfectly //#define NSIS_FIX_DEFINES_IN_STRINGS diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 35af1e32..363e70f2 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -26,19 +26,6 @@ static stack_t *g_st; union installer_flags g_flags; -static WIN32_FIND_DATA * NSISCALL file_exists(char *buf) -{ - HANDLE h; - static WIN32_FIND_DATA fd; - h = FindFirstFile(buf,&fd); - if (h != INVALID_HANDLE_VALUE) - { - FindClose(h); - return &fd; - } - return NULL; -} - #ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS // based loosely on code from Tim Kosse // in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys), diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 420235fb..a57184bb 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -704,3 +704,16 @@ void NSISCALL log_write(int close) } } #endif + +WIN32_FIND_DATA * NSISCALL file_exists(char *buf) +{ + HANDLE h; + static WIN32_FIND_DATA fd; + h = FindFirstFile(buf,&fd); + if (h != INVALID_HANDLE_VALUE) + { + FindClose(h); + return &fd; + } + return NULL; +} diff --git a/Source/exehead/util.h b/Source/exehead/util.h index ced2271e..8846f7f3 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -13,6 +13,7 @@ void NSISCALL myitoa(char *s, int d); char * NSISCALL mystrcpy(char *out, const char *in); int NSISCALL mystrlen(const char *in); char * NSISCALL mystrstr(char *a, char *b); +WIN32_FIND_DATA * NSISCALL file_exists(char *buf); //BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); #define my_SetWindowText SetWindowText diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 5eecc84b..fcc86851 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -228,7 +228,7 @@ static tokenType tokenlist[TOK__LAST] = // Added by ramon 23 May 2003 {TOK_ALLOWSKIPFILES,"AllowSkipFiles",1,0,"(off|on)"}, // Added by ramon 3 jun 2003 -{TOK_DEFVAR,"dim",1,0,"VarName"}, +{TOK_DEFVAR,"Var",1,0,"VarName"}, // Added by ramon 6 jun 2003 {TOK_VI_ADDKEY,"VIAddVersionKey", 2, 1, "[/LANG=lang_id] keyname value"}, {TOK_VI_SETPRODUCTVERSION,"VIProductVersion", 1, 0, "[version_string_X.X.X.X]"},