From 92498d710e65c7560323034d6f835c76309ac70d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 15 Feb 2009 01:53:08 -0500 Subject: [PATCH] Fixed #else preprocessor directive so it'll work with #elif. --- mojoshader_internal.h | 1 + mojoshader_preprocessor.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mojoshader_internal.h b/mojoshader_internal.h index dee31f1d..6e1a11e8 100644 --- a/mojoshader_internal.h +++ b/mojoshader_internal.h @@ -380,6 +380,7 @@ typedef struct Conditional Token type; int linenum; int skipping; + int chosen; struct Conditional *next; } Conditional; diff --git a/mojoshader_preprocessor.c b/mojoshader_preprocessor.c index 26e5d2f1..878e09c5 100644 --- a/mojoshader_preprocessor.c +++ b/mojoshader_preprocessor.c @@ -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; @@ -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