Fixed !macroundef of last defined macro bug
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6998 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
565386c71f
commit
b278e8975d
3 changed files with 46 additions and 10 deletions
|
@ -14,6 +14,8 @@ Released on ??? ??th, 20??
|
||||||
|
|
||||||
\b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203})
|
\b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203})
|
||||||
|
|
||||||
|
\b Fixed !macroundef of last defined macro bug
|
||||||
|
|
||||||
\S2{} Translations
|
\S2{} Translations
|
||||||
|
|
||||||
\b Fixed minor Spanish bug (\W{http://sf.net/p/nsis/bugs/1205}{bug #1205})
|
\b Fixed minor Spanish bug (\W{http://sf.net/p/nsis/bugs/1205}{bug #1205})
|
||||||
|
|
|
@ -107,6 +107,39 @@ this shouldn't be compiled
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
|
|
||||||
|
; test macros
|
||||||
|
!macro TM_0
|
||||||
|
!macroend
|
||||||
|
!macro TM_1
|
||||||
|
!error "Wrong TM_1"
|
||||||
|
!macroend
|
||||||
|
!macro TM_2
|
||||||
|
!error "Wrong TM_2"
|
||||||
|
!macroend
|
||||||
|
!macroundef TM_2 ; Undefine the last macro
|
||||||
|
!macro TM_2
|
||||||
|
!if 0
|
||||||
|
!endif
|
||||||
|
!macroend
|
||||||
|
!ifmacrodef TM_1
|
||||||
|
!macroundef TM_1 ; Undefine "in the middle" macro
|
||||||
|
!endif
|
||||||
|
!macro TM_1
|
||||||
|
!macroend
|
||||||
|
!insertmacro TM_1
|
||||||
|
!insertmacro TM_2
|
||||||
|
|
||||||
|
!macro TM_Recursion def
|
||||||
|
!if '${${def}}' < 42
|
||||||
|
!define /redef /math ${def} '${${def}}' + 1
|
||||||
|
!insertmacro ${__MACRO__} ${def}
|
||||||
|
!endif
|
||||||
|
!macroend
|
||||||
|
!define /redef OUT1 0
|
||||||
|
!insertmacro TM_Recursion OUT1
|
||||||
|
${ASSERT} '${OUT1} = 42'
|
||||||
|
|
||||||
|
|
||||||
; testing of two math functions and a macro hack :)
|
; testing of two math functions and a macro hack :)
|
||||||
!define increase "!insertmacro increase"
|
!define increase "!insertmacro increase"
|
||||||
!macro increase DEFINE
|
!macro increase DEFINE
|
||||||
|
@ -194,6 +227,7 @@ SectionEnd
|
||||||
|
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
|
!insertmacro TEST_SCOPE "macro" __MACRO__ y
|
||||||
!insertmacro TEST_SCOPES "global" y n n n n
|
!insertmacro TEST_SCOPES "global" y n n n n
|
||||||
|
|
||||||
Section test
|
Section test
|
||||||
|
|
|
@ -235,15 +235,17 @@ void CEXEBuild::del_date_time_predefines()
|
||||||
TCHAR* CEXEBuild::GetMacro(const TCHAR *macroname, TCHAR**macroend /*= 0*/)
|
TCHAR* CEXEBuild::GetMacro(const TCHAR *macroname, TCHAR**macroend /*= 0*/)
|
||||||
{
|
{
|
||||||
TCHAR *t = (TCHAR*)m_macros.get(), *mbeg, *mbufbeg = t;
|
TCHAR *t = (TCHAR*)m_macros.get(), *mbeg, *mbufbeg = t;
|
||||||
|
size_t cbAll = m_macros.getlen(), cchAll = cbAll / sizeof(TCHAR);
|
||||||
for (; t && *t; ++t)
|
for (; t && *t; ++t)
|
||||||
{
|
{
|
||||||
mbeg = t;
|
mbeg = t;
|
||||||
|
if (t-mbufbeg >= cchAll) break;
|
||||||
const bool foundit = !_tcsicmp(mbeg, macroname);
|
const bool foundit = !_tcsicmp(mbeg, macroname);
|
||||||
t += _tcslen(t) + 1; // advance over macro name
|
t += _tcslen(t) + 1; // advance over macro name
|
||||||
|
|
||||||
// advance over parameters
|
// advance over parameters
|
||||||
while (*t) t += _tcslen(t) + 1;
|
while (*t) t += _tcslen(t) + 1;
|
||||||
t++;
|
t++; // Separator between parameters and data
|
||||||
|
|
||||||
// advance over data
|
// advance over data
|
||||||
while (*t) t += _tcslen(t) + 1;
|
while (*t) t += _tcslen(t) + 1;
|
||||||
|
@ -253,15 +255,13 @@ TCHAR* CEXEBuild::GetMacro(const TCHAR *macroname, TCHAR**macroend /*= 0*/)
|
||||||
if (macroend) *macroend = ++t;
|
if (macroend) *macroend = ++t;
|
||||||
return mbeg;
|
return mbeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t-mbufbeg >= m_macros.getlen()-1) break;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEXEBuild::pp_macro(LineParser&line)
|
int CEXEBuild::pp_macro(LineParser&line)
|
||||||
{
|
{
|
||||||
const TCHAR*const macroname = line.gettoken_str(1);
|
const TCHAR*const macroname = line.gettoken_str(1), *tokstr;
|
||||||
if (!macroname[0]) PRINTHELP()
|
if (!macroname[0]) PRINTHELP()
|
||||||
if (MacroExists(macroname))
|
if (MacroExists(macroname))
|
||||||
{
|
{
|
||||||
|
@ -272,22 +272,22 @@ int CEXEBuild::pp_macro(LineParser&line)
|
||||||
|
|
||||||
for (int pc=2; pc < line.getnumtokens(); pc++)
|
for (int pc=2; pc < line.getnumtokens(); pc++)
|
||||||
{
|
{
|
||||||
if (!line.gettoken_str(pc)[0])
|
if (!(tokstr = line.gettoken_str(pc))[0])
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("!macro: macro parameter %d is empty, not valid!\n"), pc-1);
|
ERROR_MSG(_T("!macro: macro parameter %d is empty, not valid!\n"), pc-1);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
for (int a = 2; a < pc; a++)
|
for (int a = 2; a < pc; a++)
|
||||||
{
|
{
|
||||||
if (!_tcsicmp(line.gettoken_str(pc), line.gettoken_str(a)))
|
if (!_tcsicmp(tokstr, line.gettoken_str(a)))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("!macro: macro parameter named %") NPRIs _T(" is used multiple times!\n"), line.gettoken_str(pc));
|
ERROR_MSG(_T("!macro: macro parameter named %") NPRIs _T(" is used multiple times!\n"), tokstr);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_macros.add(line.gettoken_str(pc), (int)(_tcslen(line.gettoken_str(pc))+1)*sizeof(TCHAR));
|
m_macros.add(tokstr, (int)(_tcslen(tokstr)+1)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
m_macros.add(_T(""), sizeof(_T("")));
|
m_macros.add(_T(""), sizeof(_T(""))); // Separator between parameters and data
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,7 @@ int CEXEBuild::pp_macro(LineParser&line)
|
||||||
else m_macros.add(_T(" "), sizeof(_T(" ")));
|
else m_macros.add(_T(" "), sizeof(_T(" ")));
|
||||||
linecnt++;
|
linecnt++;
|
||||||
}
|
}
|
||||||
m_macros.add(_T(""), sizeof(_T("")));
|
m_macros.add(_T(""), sizeof(_T(""))); // End of data
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue