mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Compiler: Fix #elseif handling not working as expected.
Improted from Pawn 3.1.3636. -- Example #define VAR 1 #if VAR == 1 // code #elseif VAR == 2 // code #endif -- Returns error(38).
This commit is contained in:
parent
c4b233d094
commit
65c29cafa0
@ -911,11 +911,27 @@ static int command(void)
|
||||
if ((ifstack[iflevel-1] & PARSEMODE)==PARSEMODE) {
|
||||
/* there has been a parse mode already on this level, so skip the rest */
|
||||
ifstack[iflevel-1] |= (char)SKIPMODE;
|
||||
/* if we were already skipping this section, allow expressions with
|
||||
* undefined symbols; otherwise check the expression to catch errors
|
||||
*/
|
||||
if (tok==tpELSEIF) {
|
||||
if (skiplevel==iflevel)
|
||||
preproc_expr(&val,NULL); /* get, but ignore the expression */
|
||||
else
|
||||
lptr=strchr(lptr,'\0');
|
||||
} /* if */
|
||||
} else {
|
||||
/* previous conditions were all FALSE */
|
||||
if (tok==tpELSEIF) {
|
||||
/* get new expression */
|
||||
preproc_expr(&val,NULL); /* get value (or 0 on error) */
|
||||
/* if we were already skipping this section, allow expressions with
|
||||
* undefined symbols; otherwise check the expression to catch errors
|
||||
*/
|
||||
if (skiplevel==iflevel) {
|
||||
preproc_expr(&val,NULL); /* get value (or 0 on error) */
|
||||
} else {
|
||||
lptr=strchr(lptr,'\0');
|
||||
val=0;
|
||||
} /* if */
|
||||
ifstack[iflevel-1]=(char)(val ? PARSEMODE : SKIPMODE);
|
||||
} else {
|
||||
/* a simple #else, clear skip mode */
|
||||
|
Loading…
Reference in New Issue
Block a user