diff --git a/Source/build.cpp b/Source/build.cpp index 2b5c6d43..1a0cd917 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -985,18 +985,11 @@ int CEXEBuild::resolve_instruction(const char *fn, const char *str, entry *w, in if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1; if (resolve_jump_int(fn,&w->offsets[2],offs,start,end)) return 1; } - else if (w->which == EW_IFERRORS) + else if (w->which == EW_IFFLAG) { if (resolve_jump_int(fn,&w->offsets[0],offs,start,end)) return 1; if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1; } -#ifdef NSIS_SUPPORT_REBOOT - else if (w->which == EW_IFREBOOTFLAG) - { - if (resolve_jump_int(fn,&w->offsets[0],offs,start,end)) return 1; - if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1; - } -#endif #ifdef NSIS_SUPPORT_STROPTS else if (w->which == EW_STRCMP) { @@ -2309,7 +2302,7 @@ again: ret=add_entry_direct(EW_CREATEDIR, zero_offset); if (ret != PS_OK) return ret; // IfErrors Initialize_____Plugins_error - detect errors - ret=add_entry_direct(EW_IFERRORS, ns_label.add("Initialize_____Plugins_error",0)); + ret=add_entry_direct(EW_IFFLAG, ns_label.add("Initialize_____Plugins_error",0), 0, FIELD_OFFSET(installer_flags, exec_error)); if (ret != PS_OK) return ret; // Copy $0 to $PLUGINSDIR ret=add_entry_direct(EW_PLUGINCOMMANDPREP); diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index cc2adc04..43c72c5a 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -79,7 +79,7 @@ int num_sections; #define WM_TREEVIEW_KEYHACK (WM_USER+0x13) -static int m_page=-1,m_abort,m_retcode,m_delta=1; +static int m_page=-1,m_retcode,m_delta=1; #define NOTIFY_BYE_BYE 'x' @@ -631,7 +631,7 @@ nextPage: } if (id == IDCANCEL) { - if (m_abort) + if (g_flags.abort) { #ifdef NSIS_SUPPORT_CODECALLBACKS ExecuteCodeSegment(g_inst_cmnheader->code_onInstFailed,NULL); @@ -1332,20 +1332,20 @@ static DWORD WINAPI install_thread(LPVOID p) #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT if (g_is_uninstaller) { - if (ExecuteCodeSegment(g_inst_uninstheader->code,g_progresswnd)) m_abort++; + if (ExecuteCodeSegment(g_inst_uninstheader->code,g_progresswnd)) g_flags.abort++; } else { #endif int m_inst_sec=0; - while (m_inst_secoffsets[!g_flags.flags[parm2]]; + g_flags.flags[parm2]&=parm3; + return f; + } case EW_CHDETAILSVIEW: if (insthwndbutton) ShowWindow(insthwndbutton,parm1); if (insthwnd) ShowWindow(insthwnd,parm0); @@ -274,12 +280,6 @@ static int NSISCALL ExecuteEntry(entry *entry_) log_printf3("IfFileExists: file \"%s\" does not exist, jumping %d",buf0,parm2); } return parm2; - case EW_IFERRORS: - { - int f=entry_->offsets[!g_flags.exec_error]; - g_flags.exec_error=0; - return f; - } #ifdef NSIS_SUPPORT_RENAME case EW_RENAME: { @@ -1110,7 +1110,6 @@ static int NSISCALL ExecuteEntry(entry *entry_) FreeLibrary(h); } break; - case EW_IFREBOOTFLAG: return entry_->offsets[!g_flags.exec_reboot]; #endif//NSIS_SUPPORT_REBOOT #ifdef NSIS_SUPPORT_INIFILES case EW_WRITEINI: diff --git a/Source/exehead/exec.h b/Source/exehead/exec.h index 8571e0b6..f18ebc97 100644 --- a/Source/exehead/exec.h +++ b/Source/exehead/exec.h @@ -1,17 +1,7 @@ #ifndef _EXEC_H_ #define _EXEC_H_ -extern union flags { - struct { - int autoclose; - int all_user_var; - int exec_error; -#ifdef NSIS_SUPPORT_REBOOT - int exec_reboot; -#endif - }; - int flags[1]; -} g_flags; +extern union installer_flags g_flags; int NSISCALL ExecuteCodeSegment(int pos, HWND hwndProgress); // returns 0 on success diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index b4997c67..d6b9ea40 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -45,8 +45,8 @@ enum EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes] EW_CREATEDIR, // Create directory: 2, [path, ?update$INSTDIR] EW_IFFILEEXISTS, // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists] - EW_IFERRORS, // IfErrors: 2 [jump if error, jump if not error] EW_SETFLAG, // Sets a flag: 2 [id, data] + EW_IFFLAG, // If a flag: 4 [on, off, id, new value mask] #ifdef NSIS_SUPPORT_RENAME EW_RENAME, // Rename: 3 [old, new, rebootok] #endif @@ -513,5 +513,17 @@ DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove, DWORD dwMoveMethod); #define VAR_CODES_START (256 - 36) #endif +union installer_flags { + struct { + int autoclose; + int all_user_var; + int exec_error; + int abort; +#ifdef NSIS_SUPPORT_REBOOT + int exec_reboot; +#endif + }; + int flags[1]; +}; #endif //_FILEFORM_H_ diff --git a/Source/script.cpp b/Source/script.cpp index b6afe129..b87ba616 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -356,6 +356,8 @@ int CEXEBuild::process_jump(LineParser &line, int wt, int *offs) return 0; } +#define FLAG_OFFSET(flag) (FIELD_OFFSET(installer_flags, flag)/sizeof(int)) + int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char *curfilename, int *lineptr) { int linecnt = *lineptr; @@ -2470,7 +2472,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char return add_entry(&ent); case TOK_SETSHELLVARCONTEXT: ent.which=EW_SETFLAG; - ent.offsets[0]=1; + ent.offsets[0]=FLAG_OFFSET(all_user_var); ent.offsets[1]=line.gettoken_enum(1,"current\0all\0"); if (ent.offsets[1]<0) PRINTHELP() SCRIPT_MSG("SetShellVarContext: %s\n",line.gettoken_str(1)); @@ -3248,26 +3250,35 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char return add_entry(&ent); case TOK_SETAUTOCLOSE: ent.which=EW_SETFLAG; - ent.offsets[0]=0; + ent.offsets[0]=FLAG_OFFSET(autoclose); ent.offsets[1]=line.gettoken_enum(1,"false\0true\0"); if (ent.offsets[1] < 0) PRINTHELP() SCRIPT_MSG("SetAutoClose: %s\n",line.gettoken_str(1)); return add_entry(&ent); case TOK_IFERRORS: - ent.which=EW_IFERRORS; + ent.which=EW_IFFLAG; if (process_jump(line,1,&ent.offsets[0]) || process_jump(line,2,&ent.offsets[1])) PRINTHELP() + ent.offsets[2]=FLAG_OFFSET(exec_error); + ent.offsets[3]=0;//new value mask - clean error SCRIPT_MSG("IfErrors ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2)); + case TOK_IFABORT: + ent.which=EW_IFFLAG; + if (process_jump(line,1,&ent.offsets[0]) || + process_jump(line,2,&ent.offsets[1])) PRINTHELP() + ent.offsets[2]=FLAG_OFFSET(abort); + ent.offsets[3]=(int)~0;//new value mask - keep flag + SCRIPT_MSG("IfAbort ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); case TOK_CLEARERRORS: ent.which=EW_SETFLAG; - ent.offsets[0]=2; + ent.offsets[0]=FLAG_OFFSET(exec_error); ent.offsets[1]=0; SCRIPT_MSG("ClearErrors\n"); return add_entry(&ent); case TOK_SETERRORS: ent.which=EW_SETFLAG; - ent.offsets[0]=2; + ent.offsets[0]=FLAG_OFFSET(exec_error); ent.offsets[1]=1; SCRIPT_MSG("SetErrors\n"); return add_entry(&ent); @@ -3997,14 +4008,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG("Reboot! (WOW)\n"); return add_entry(&ent); case TOK_IFREBOOTFLAG: - ent.which=EW_IFREBOOTFLAG; + ent.which=EW_IFFLAG; if (process_jump(line,1,&ent.offsets[0]) || process_jump(line,2,&ent.offsets[1])) PRINTHELP() + ent.offsets[2]=FLAG_OFFSET(exec_reboot); + ent.offsets[3]=(int)~0;//new value mask - keep flag SCRIPT_MSG("IfRebootFlag ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); case TOK_SETREBOOTFLAG: ent.which=EW_SETFLAG; - ent.offsets[0]=3; + ent.offsets[0]=FLAG_OFFSET(exec_reboot); ent.offsets[1]=line.gettoken_enum(1,"false\0true\0"); if (ent.offsets[1] < 0) PRINTHELP() return add_entry(&ent); diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 53849bf1..527f2671 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -80,6 +80,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_GETWINTEXT,"GetWindowText",2,0,"$(user_var: handle output) hwnd"}, {TOK_HIDEWINDOW,"HideWindow",0,0,""}, {TOK_ICON,"Icon",1,0,"local_icon.ico"}, +{TOK_IFABORT,"IfAbort",1,1,"label_to_goto_if_abort [label_to_goto_if_no_abort]"}, {TOK_IFERRORS,"IfErrors",1,1,"label_to_goto_if_errors [label_to_goto_if_no_errors]"}, {TOK_IFFILEEXISTS,"IfFileExists",2,1,"filename label_to_goto_if_file_exists [label_to_goto_otherwise]"}, {TOK_IFREBOOTFLAG,"IfRebootFlag",1,1,"jump_if_set [jump_if_not_set]"}, diff --git a/Source/tokens.h b/Source/tokens.h index 07b7daca..7a9873e4 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -144,6 +144,7 @@ enum TOK_IFERRORS, TOK_CLEARERRORS, TOK_SETERRORS, + TOK_IFABORT, TOK_STRCPY, TOK_STRCMP, TOK_GETTEMPFILENAME,