Fixed line numbers when a preprocessor directive fails.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 15 Feb 2009 02:03:24 -0500
changeset 626 95d97e613112
parent 625 bfb4016d9404
child 627 166c4ad7126b
Fixed line numbers when a preprocessor directive fails.
mojoshader_preprocessor.c
--- a/mojoshader_preprocessor.c	Sun Feb 15 01:53:08 2009 -0500
+++ b/mojoshader_preprocessor.c	Sun Feb 15 02:03:24 2009 -0500
@@ -553,12 +553,12 @@
 static int require_newline(IncludeState *state)
 {
     const char *source = state->source;
+    const unsigned int linenum = state->line;
     const Token token = preprocessor_internal_lexer(state);
+    state->source = source;  // rewind no matter what.
+    state->line = linenum;
     if (token == TOKEN_INCOMPLETE_COMMENT)
-    {
-        state->source = source;  // pick this up later.
-        return 1;  // call it an eol.
-    } // if
+        return 1; // call it an eol.
     return ( (token == ((Token) '\n')) || (token == TOKEN_EOI) );
 } // require_newline