From 8cde6958a8dab936f8a158eb839954203db47552 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sun, 13 Nov 2011 17:31:14 +0000 Subject: [PATCH] Added ${__MACRO__} git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6171 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/compiler.but | 4 ++++ Source/build.cpp | 2 ++ Source/build.h | 1 + Source/script.cpp | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/Docs/src/compiler.but b/Docs/src/compiler.but index ce23f4e5..ce9422c0 100644 --- a/Docs/src/compiler.but +++ b/Docs/src/compiler.but @@ -334,6 +334,10 @@ Defined in \R{ssection}{section}, \R{ffunction}{function} or \R{pageex}{PageEx} \c \c FunctionEnd +\S2{} $\{__MACRO__\} + +Defined as the name of the current macro. + \S0{compenvvarread} Read environment variables \S1{compenvvar} $%envVarName% diff --git a/Source/build.cpp b/Source/build.cpp index 065354fc..db86da36 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -256,6 +256,8 @@ CEXEBuild::CEXEBuild() : no_space_texts=false; + m_currentmacroname=NULL; + #ifdef NSIS_CONFIG_PLUGIN_SUPPORT build_plugin_unload=0; plugins_processed=0; diff --git a/Source/build.h b/Source/build.h index 23252061..cb77a175 100644 --- a/Source/build.h +++ b/Source/build.h @@ -433,6 +433,7 @@ class CEXEBuild { int sectiongroup_open_cnt; FastStringList m_warnings; + const TCHAR* m_currentmacroname; GrowBuf m_macros; StringList m_macro_entry; diff --git a/Source/script.cpp b/Source/script.cpp index 2f3c900a..c62b8f71 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -1178,6 +1178,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int npos=m_macro_entry.add(line.gettoken_str(1),0); wsprintf(str,_T("macro:%s"),line.gettoken_str(1)); + const TCHAR* oldmacroname=m_currentmacroname; + m_currentmacroname=line.gettoken_str(1); + definedlist.del(_T("__MACRO__")); + definedlist.add(_T("__MACRO__"),m_currentmacroname); while (*t) { lp++; @@ -1212,6 +1216,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) p+=_tcslen(p)+1; } } + definedlist.del(_T("__MACRO__")); + m_currentmacroname = oldmacroname; + if (oldmacroname) definedlist.add(_T("__MACRO__"),oldmacroname); SCRIPT_MSG(_T("!insertmacro: end of %s\n"),line.gettoken_str(1)); } return PS_OK;