Fix bug#1086, don't parse non-branch instructions inside a !if 0 block

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6418 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-12-08 16:24:06 +00:00
parent c16bc083b5
commit 527cf2d7a4
4 changed files with 15 additions and 9 deletions

View file

@ -10,6 +10,8 @@ Released on ?
\b !include defaults to UTF-8 after \cw{Unicode True} \b !include defaults to UTF-8 after \cw{Unicode True}
\b Preprocessor does not parse all branches and will not validate code that is never executed (\W{http://sf.net/p/nsis/bugs/1086/}{bug #1086})
\S2{} Minor Changes \S2{} Minor Changes
\b FileRead in Unicode installers can handle DBCS, conversion output is limited to UCS-2. \b FileRead in Unicode installers can handle DBCS, conversion output is limited to UCS-2.

View file

@ -169,7 +169,7 @@ class CEXEBuild {
void update_exehead(const unsigned char *new_exehead, size_t new_size); void update_exehead(const unsigned char *new_exehead, size_t new_size);
// tokens.cpp // tokens.cpp
bool is_valid_token(TCHAR *s); bool is_ppbranch_token(TCHAR *s);
int get_commandtoken(TCHAR *s, int *np, int *op, int *pos); int get_commandtoken(TCHAR *s, int *np, int *op, int *pos);
const TCHAR* get_commandtoken_name(int tok); const TCHAR* get_commandtoken_name(int tok);

View file

@ -365,7 +365,7 @@ int CEXEBuild::doParse(const TCHAR *str)
{ {
bool ignore_line = cur_ifblock && (cur_ifblock->ignore || cur_ifblock->inherited_ignore); bool ignore_line = cur_ifblock && (cur_ifblock->ignore || cur_ifblock->inherited_ignore);
TCHAR first_char = *(TCHAR *) m_linebuild.get(); TCHAR first_char = *(TCHAR *) m_linebuild.get();
if (ignore_line && (first_char!=_T('!') || !is_valid_token(line.gettoken_str(0)))) if (ignore_line && (first_char!=_T('!') || !is_ppbranch_token(line.gettoken_str(0))))
{ {
m_linebuild.resize(0); m_linebuild.resize(0);
return PS_OK; return PS_OK;

View file

@ -326,18 +326,22 @@ void CEXEBuild::print_help(const TCHAR *commandname)
} }
bool CEXEBuild::is_valid_token(TCHAR *s) bool CEXEBuild::is_ppbranch_token(TCHAR *s)
{ {
for (int x = 0; x < TOK__LAST; x ++) int np, op, pos, tkid = get_commandtoken(s, &np, &op, &pos);
if (!_tcsicmp(tokenlist[x].name,s)) switch(tkid)
return true; {
return false; case TOK_P_IF: case TOK_P_ELSE: case TOK_P_ENDIF:
case TOK_P_IFDEF: case TOK_P_IFNDEF:
case TOK_P_IFMACRODEF: case TOK_P_IFMACRONDEF:
return true;
default: return false;
}
} }
int CEXEBuild::get_commandtoken(TCHAR *s, int *np, int *op, int *pos) int CEXEBuild::get_commandtoken(TCHAR *s, int *np, int *op, int *pos)
{ {
int x; for (int x = 0; x < TOK__LAST; x ++)
for (x = 0; x < TOK__LAST; x ++)
if (!_tcsicmp(tokenlist[x].name,s)) if (!_tcsicmp(tokenlist[x].name,s))
{ {
*np=tokenlist[x].num_parms; *np=tokenlist[x].num_parms;