From c21579cf2a0f4e9da50b7e0cfdc52e15dddc016b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 23 Feb 2009 23:42:57 -0500 Subject: [PATCH] Preprocessor now traps newlines. --- mojoshader_preprocessor.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mojoshader_preprocessor.c b/mojoshader_preprocessor.c index 7661c49b..8ade0e48 100644 --- a/mojoshader_preprocessor.c +++ b/mojoshader_preprocessor.c @@ -1790,6 +1790,12 @@ static inline const char *_preprocessor_nexttoken(Preprocessor *_ctx, continue; // pushed the include_stack. } // else if + else if (token == ((Token) '\n')) + { + // preprocessor is line-oriented, nothing else gets newlines. + continue; // get the next thing. + } // else if + assert(!skipping); *_token = token; *_len = state->tokenlen; @@ -1947,10 +1953,7 @@ const MOJOSHADER_preprocessData *MOJOSHADER_preprocess(const char *filename, // It ignores newlines, and then inserts its own around certain // tokens. For example, after a semicolon. This allows HLSL code to // be mostly readable, instead of a stream of tokens. - if (token == ((Token) '\n')) - isnewline = nl; // this doesn't actually care about '\n' ... - - else if ( (token == ((Token) '}')) || (token == ((Token) ';')) ) + if ( (token == ((Token) '}')) || (token == ((Token) ';')) ) { if (!out_of_memory) {