!if/!else/!endif problems should be solved now

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1943 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-12-12 19:00:34 +00:00
parent fe2a23d116
commit be1b083fc3

View file

@ -50,6 +50,7 @@ int CEXEBuild::doParse(const char *str, FILE *fp, const char *curfilename, int *
{ {
static int ignore; static int ignore;
static int ignored_if_count; static int ignored_if_count;
static int wait_for_endif;
LineParser line; LineParser line;
int res; int res;
@ -142,11 +143,23 @@ parse_again:
if (line.getnumtokens() == 1) PRINTHELP() if (line.getnumtokens() == 1) PRINTHELP()
if (!v) tkid = TOK_P_IFDEF; if (!v) tkid = TOK_P_IFDEF;
else tkid = TOK_P_IFNDEF; else tkid = TOK_P_IFNDEF;
ignore=0; // process the ifdef if (ignore && !wait_for_endif) {
ignore=0; // process the ifdef
}
else {
// don't process the if(n)def because the else code shouldn't be executed
// one if was already executed
ignore=1;
wait_for_endif=1;
}
} }
if (tkid == TOK_P_IFNDEF || tkid == TOK_P_IFDEF) if (tkid == TOK_P_IFNDEF || tkid == TOK_P_IFDEF)
{ {
if (wait_for_endif) {
ERROR_MSG("waiting for !endif\n");
return PS_OK;
}
if (ignore) { if (ignore) {
ignored_if_count++; ignored_if_count++;
return PS_OK; return PS_OK;
@ -182,7 +195,10 @@ parse_again:
if (tkid == TOK_P_ENDIF) { if (tkid == TOK_P_ENDIF) {
if (ignore) { if (ignore) {
if (ignored_if_count) ignored_if_count--; if (ignored_if_count) ignored_if_count--;
else ignore=0; else {
wait_for_endif=0;
ignore=0;
}
} }
return PS_OK; return PS_OK;
} }