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
This commit is contained in:
Lance 2008-01-26 18:32:41 +00:00
parent 3d44f91d3a
commit 8c6dccbb70
2 changed files with 23 additions and 11 deletions

View file

@ -8674,9 +8674,13 @@ pbool QCC_PR_CompileFile (char *string, char *filename)
pr_source_line = 0; pr_source_line = 0;
if( setjmp( pr_parse_abort ) ) {
// dont count it as error
} else {
QCC_PR_NewLine (false); QCC_PR_NewLine (false);
QCC_PR_Lex (); // read first token QCC_PR_Lex (); // read first token
}
memcpy(&oldjb, &pr_parse_abort, sizeof(oldjb)); memcpy(&oldjb, &pr_parse_abort, sizeof(oldjb));
while (pr_token_type != tt_eof) while (pr_token_type != tt_eof)

View file

@ -1924,15 +1924,21 @@ void QCC_PR_ConditionCompilation(void)
s++; s++;
while(1) 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 }
else if(*s == '\r' || *s == '\n' || *s == '\0')
{
break; break;
} }
@ -1960,6 +1966,8 @@ void QCC_PR_ConditionCompilation(void)
else else
QCC_PR_ParseWarning(WARN_IDENTICALPRECOMPILER, "Identical precompiler definition of %s", pr_token); QCC_PR_ParseWarning(WARN_IDENTICALPRECOMPILER, "Identical precompiler definition of %s", pr_token);
} }
pr_file_p = s;
} }
int QCC_PR_CheakCompConst(void) int QCC_PR_CheakCompConst(void)
@ -2107,7 +2115,7 @@ int QCC_PR_CheakCompConst(void)
{ {
strcat(buffer, "#"); strcat(buffer, "#");
strcat(buffer, qcc_token); strcat(buffer, qcc_token);
QCC_PR_ParseWarning(0, "Stingification ignored"); QCC_PR_ParseWarning(0, "Stringification ignored");
} }
continue; //already did this one continue; //already did this one
} }