Added !macroundef

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6177 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2011-11-17 18:54:49 +00:00
parent 20e4aa0787
commit 3d9c850bb5
4 changed files with 45 additions and 0 deletions

View file

@ -141,6 +141,12 @@ Creates a macro named 'macro_name'. All lines between the !macro and the !macroe
Ends a macro that was started with !macro.
\S1{macroundef} !macroundef
\c macro_name
Deletes a macro.
\S1{searchparse} !searchparse
\c [/ignorecase] [/noerrors] [/file] source_string_or_file substring_start OUTPUTSYMBOL1 [substring [OUTPUTSYMBOL2 [substring ...]]]

View file

@ -1112,6 +1112,43 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_P_MACROEND:
ERROR_MSG(_T("!macroend: no macro currently open.\n"));
return PS_ERROR;
case TOK_P_MACROUNDEF:
{
const TCHAR* mname=line.gettoken_str(1);
if (!mname[0]) PRINTHELP()
TCHAR *t=(TCHAR *)m_macros.get(), *mbeg, *mend=0, *mbufb=t;
while (t && *t)
{
const bool foundit = !_tcsicmp((mbeg=t),mname);
t+=_tcslen(t)+1;
// advance over parameters
while (*t) t+=_tcslen(t)+1;
t++;
// advance over data
while (*t) t+=_tcslen(t)+1;
if (foundit)
{
mend=t;
break;
}
if (t-mbufb >= m_macros.getlen()-1)
break;
t++;
}
if (!mend)
{
ERROR_MSG(_T("!macroundef: \"%s\" does not exist!\n"),mname);
return PS_ERROR;
}
const unsigned int mcb=mend-mbeg, mbufcb=m_macros.getlen();
memmove(mbeg,mend+1,mbufcb-(mcb+(mbeg-mbufb)));
m_macros.resize(mbufcb-(mcb+1));
SCRIPT_MSG(_T("!macroundef: %s\n"),mname);
}
return PS_OK;
case TOK_P_INSERTMACRO:
{
if (!line.gettoken_str(1)[0]) PRINTHELP()

View file

@ -262,6 +262,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_MACRO,_T("!macro"),1,-1,_T("macroname [parms ...]"),TP_ALL},
{TOK_P_MACROEND,_T("!macroend"),0,0,_T(""),TP_ALL},
{TOK_P_MACROUNDEF,_T("!macroundef"),1,0,_T("macroname"),TP_ALL},
{TOK_P_INSERTMACRO,_T("!insertmacro"),1,-1,_T("macroname [parms ...]"),TP_ALL},
{TOK_P_IFMACRODEF,_T("!ifmacrodef"),1,-1,_T("macro [| macro2 [& macro3 [...]]]"),TP_ALL},
{TOK_P_IFMACRONDEF,_T("!ifmacrondef"),1,-1,_T("macro [| macro2 [& macro3 [...]]]"),TP_ALL},

View file

@ -116,6 +116,7 @@ enum
TOK_P_MACRO,
TOK_P_MACROEND,
TOK_P_MACROUNDEF,
TOK_P_INSERTMACRO,
TOK_P_IFMACRODEF,
TOK_P_IFMACRONDEF,