Skip to content

Commit

Permalink
Only turn on whitespace/comment reporting when not in a preprocessor …
Browse files Browse the repository at this point in the history
…handler.

Things like "#define" handling need to manipulate that lexer state directly.
  • Loading branch information
icculus committed Feb 15, 2013
1 parent 00f25f8 commit 2dcd52d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mojoshader_preprocessor.c
Expand Up @@ -546,10 +546,6 @@ static int push_source(Context *ctx, const char *fname, const char *source,
} // if
} // if

#if !MATCH_MICROSOFT_PREPROCESSOR
state->report_comments = 1;
#endif

state->close_callback = close_callback;
state->source_base = source;
state->source = source;
Expand Down Expand Up @@ -732,10 +728,6 @@ static inline void pushback(IncludeState *state)

static Token lexer(IncludeState *state)
{
#if !MATCH_MICROSOFT_PREPROCESSOR
state->report_whitespace = 1;
#endif

if (!state->pushedback)
return preprocessor_lexer(state);
state->pushedback = 0;
Expand Down Expand Up @@ -2022,8 +2014,18 @@ static inline const char *_preprocessor_nexttoken(Preprocessor *_ctx,
const Conditional *cond = state->conditional_stack;
const int skipping = ((cond != NULL) && (cond->skipping));

#if !MATCH_MICROSOFT_PREPROCESSOR
state->report_whitespace = 1;
state->report_comments = 1;
#endif

const Token token = lexer(state);

#if !MATCH_MICROSOFT_PREPROCESSOR
state->report_whitespace = 0;
state->report_comments = 0;
#endif

if (token != TOKEN_IDENTIFIER)
ctx->recursion_count = 0;

Expand Down

0 comments on commit 2dcd52d

Please sign in to comment.