From 645d4c9f497c60414ef05ed1bce0d036a405a09e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 13 Feb 2009 23:55:10 -0500 Subject: [PATCH] Fix line numbers in #error preprocessor directives. --- mojoshader_preprocessor.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mojoshader_preprocessor.c b/mojoshader_preprocessor.c index dddc917c..375e2d91 100644 --- a/mojoshader_preprocessor.c +++ b/mojoshader_preprocessor.c @@ -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; @@ -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);