diff --git a/Docs/src/defines.but b/Docs/src/defines.but index dbc5b06e..b2ed8f50 100644 --- a/Docs/src/defines.but +++ b/Docs/src/defines.but @@ -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 ...]]] diff --git a/Source/script.cpp b/Source/script.cpp index 87320a53..255cf35e 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -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() diff --git a/Source/tokens.cpp b/Source/tokens.cpp index aa20fcd2..4c398fea 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -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}, diff --git a/Source/tokens.h b/Source/tokens.h index f0b98173..2e0638c5 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -116,6 +116,7 @@ enum TOK_P_MACRO, TOK_P_MACROEND, + TOK_P_MACROUNDEF, TOK_P_INSERTMACRO, TOK_P_IFMACRODEF, TOK_P_IFMACRONDEF,