From 8c6dccbb705cf6b2b823ae8d3a2b4c3ba5c6ce83 Mon Sep 17 00:00:00 2001 From: Lance Date: Sat, 26 Jan 2008 18:32:41 +0000 Subject: [PATCH] BlackHC's patch to add support for \ (backslash) in macros git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2879 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_comp.c | 10 +++++++--- engine/qclib/qcc_pr_lex.c | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 9aafee2fc..f4e606e38 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -8673,10 +8673,14 @@ pbool QCC_PR_CompileFile (char *string, char *filename) pr_file_p = string; pr_source_line = 0; - - QCC_PR_NewLine (false); - QCC_PR_Lex (); // read first token + if( setjmp( pr_parse_abort ) ) { + // dont count it as error + } else { + QCC_PR_NewLine (false); + + QCC_PR_Lex (); // read first token + } memcpy(&oldjb, &pr_parse_abort, sizeof(oldjb)); while (pr_token_type != tt_eof) diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index b6519abf1..e40223d84 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -1924,16 +1924,22 @@ void QCC_PR_ConditionCompilation(void) s++; while(1) { - if (*s == '\r' || *s == '\n' || *s == '\0') + if( *s == '\\' ) { - if (s[-1] == '\\') + // read over a newline if necessary + if( s[1] == '\n' || s[1] == '\r' ) { + s++; + *d++ = *s++; + if( s[-1] == '\r' && s[0] == '\n' ) + { + *d++ = *s++; + } } - else if (s[-2] == '\\' && s[-1] == '\r' && s[0] == '\n') - { - } - else - break; + } + else if(*s == '\r' || *s == '\n' || *s == '\0') + { + break; } if (!quote && s[0]=='/'&&(s[1]=='/'||s[1]=='*')) @@ -1960,6 +1966,8 @@ void QCC_PR_ConditionCompilation(void) else QCC_PR_ParseWarning(WARN_IDENTICALPRECOMPILER, "Identical precompiler definition of %s", pr_token); } + + pr_file_p = s; } int QCC_PR_CheakCompConst(void) @@ -2107,7 +2115,7 @@ int QCC_PR_CheakCompConst(void) { strcat(buffer, "#"); strcat(buffer, qcc_token); - QCC_PR_ParseWarning(0, "Stingification ignored"); + QCC_PR_ParseWarning(0, "Stringification ignored"); } continue; //already did this one }