Skip to content

Commit

Permalink
Fixed #else preprocessor directive so it'll work with #elif.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 15, 2009
1 parent 30b6a51 commit 92498d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions mojoshader_internal.h
Expand Up @@ -380,6 +380,7 @@ typedef struct Conditional
Token type;
int linenum;
int skipping;
int chosen;
struct Conditional *next;
} Conditional;

Expand Down
6 changes: 4 additions & 2 deletions mojoshader_preprocessor.c
Expand Up @@ -789,6 +789,7 @@ static Conditional *_handle_pp_ifdef(Context *ctx, const Token type)
conditional->type = type;
conditional->linenum = state->line - 1;
conditional->skipping = skipping;
conditional->chosen = !skipping;
conditional->next = prev;
state->conditional_stack = conditional;
return conditional;
Expand Down Expand Up @@ -820,9 +821,10 @@ static inline void handle_pp_else(Context *ctx)
fail(ctx, "#else after #else");
else
{
// !!! FIXME: doesn't work for #elif
cond->type = TOKEN_PP_ELSE;
cond->skipping = !cond->skipping;
cond->skipping = cond->chosen;
if (!cond->chosen)
cond->chosen = 1;
} // else
} // handle_pp_else

Expand Down

0 comments on commit 92498d7

Please sign in to comment.