Skip to content

Commit

Permalink
Fix line numbers in #error preprocessor directives.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 14, 2009
1 parent db73da9 commit 645d4c9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mojoshader_preprocessor.c
Expand Up @@ -639,18 +639,17 @@ static void handle_pp_error(Context *ctx)
const char *data = NULL;
int done = 0;

const char *source = NULL;
while (!done)
{
const char *source = state->source;
source = state->source;
const Token token = preprocessor_internal_lexer(state);
switch (token)
{
case TOKEN_INCOMPLETE_COMMENT:
state->source = source; // move back so we catch this later.
done = 1;
break;

case ((Token) '\n'):
state->line--; // make sure error is on the right line.
// fall through!
case TOKEN_INCOMPLETE_COMMENT:
case TOKEN_EOI:
done = 1;
break;
Expand All @@ -662,6 +661,8 @@ static void handle_pp_error(Context *ctx)
} // switch
} // while

state->source = source; // move back so we catch this later.

const char *prefix = "#error ";
const size_t prefixlen = strlen(prefix);
const int len = (int) (state->source - data);
Expand Down

0 comments on commit 645d4c9

Please sign in to comment.