From 9a3f4e0cb1a9396a019eed3e33a5f6970dcb4871 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sun, 20 Nov 2011 18:51:35 +0000 Subject: [PATCH] !verbose varargs support (Ex: !verbose push 3) git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6183 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/script.cpp | 70 ++++++++++++++++++++++++++++------------------- Source/tokens.cpp | 2 +- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Source/script.cpp b/Source/script.cpp index 255cf35e..cc091498 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -3397,54 +3397,68 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) case TOK_P_VERBOSE: { extern int g_display_errors; - int k=line.gettoken_enum(1,_T("push\0pop\0")); - int v; - if (k < 0) - // just set - v=line.gettoken_int(1); - else + for(int argi=1; argi 4 ) { - v=((int*)verbose_stack.get())[(l/sizeof(int))-1]; - verbose_stack.resize(l-sizeof(int)); + // < 2.47 would reset level to 0 without warning! + ERROR_MSG("!verbose: Invalid verbose level\n"); + return PS_ERROR; } - else - return PS_OK; } else { - // push - v=0; - if (display_errors) + if (k) { - v++; - if (display_warnings) + // pop + int l=verbose_stack.getlen(); + if (l) + { + v=((int*)verbose_stack.get())[(l/sizeof(int))-1]; + verbose_stack.resize(l-sizeof(int)); + } + else + { + warning_fl("!verbose: Pop failed, stack is empty"); + continue; // Pop failed, should still process the next parameter + } + } + else + { + // push + v=0; + if (display_errors) { v++; - if (display_info) + if (display_warnings) { v++; - if (display_script) + if (display_info) { v++; + if (display_script) + { + v++; + } } } } + verbose_stack.add(&v,sizeof(int)); + continue; } - verbose_stack.add(&v,sizeof(int)); - return PS_OK; } + display_script=v>3; + display_info=v>2; + display_warnings=v>1; + display_errors=v>0; + g_display_errors=display_errors; } - display_script=v>3; - display_info=v>2; - display_warnings=v>1; - display_errors=v>0; - g_display_errors=display_errors; } return PS_OK; diff --git a/Source/tokens.cpp b/Source/tokens.cpp index c1a8a790..66534a5e 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -258,7 +258,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_P_WARNING,_T("!warning"),0,1,_T("[warning_message]"),TP_ALL}, {TOK_P_ERROR,_T("!error"),0,1,_T("[error_message]"),TP_ALL}, -{TOK_P_VERBOSE,_T("!verbose"),1,0,_T("verbose_level | push | pop"),TP_ALL}, +{TOK_P_VERBOSE,_T("!verbose"),1,-1,_T("(verbose_level | push | pop) [...]"),TP_ALL}, {TOK_P_MACRO,_T("!macro"),1,-1,_T("macroname [parms ...]"),TP_ALL}, {TOK_P_MACROEND,_T("!macroend"),0,0,_T(""),TP_ALL},