From bf8eed727e2df34eb18ebba888f1bc7b9da283dc Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 30 Oct 2008 11:10:58 +0000 Subject: [PATCH] Reject double dots in macro names (fred.4 is allowed but fred..4 is not). This allows Hexen2 code to compile again. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3050 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_lex.c | 51 +++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 170115140..504e4aad1 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -1697,6 +1697,43 @@ pbool QCC_PR_SimpleGetToken (void) return i!=0; } +pbool QCC_PR_LexMacroName(void) +{ + int c; + int i; + + pr_token[0] = 0; + +// skip whitespace + while ( (c = *pr_file_p) <= ' ') + { + if (c=='\n' || c == 0) + return false; + pr_file_p++; + } + if (pr_file_p[0] == '/') + { + if (pr_file_p[1] == '/') + { //comment alert + while(*pr_file_p && *pr_file_p != '\n') + pr_file_p++; + return false; + } + if (pr_file_p[1] == '*') + return false; + } + + i = 0; + while ( (c = *pr_file_p) > ' ' && c != ',' && c != ';' && c != ')' && c != '(' && c != ']' && !(pr_file_p[0] == '.' && pr_file_p[1] == '.')) + { + pr_token[i] = c; + i++; + pr_file_p++; + } + pr_token[i] = 0; + return i!=0; +} + void QCC_PR_MacroFrame(char *name, int value) { int i; @@ -1726,7 +1763,7 @@ void QCC_PR_MacroFrame(char *name, int value) void QCC_PR_ParseFrame (void) { - while (QCC_PR_SimpleGetToken ()) + while (QCC_PR_LexMacroName ()) { QCC_PR_MacroFrame(pr_token, pr_macrovalue++); } @@ -1746,7 +1783,7 @@ void QCC_PR_LexGrab (void) // QCC_PR_ParseError ("hanging $"); if (*pr_file_p <= ' ') QCC_PR_ParseError (ERR_BADFRAMEMACRO, "hanging $"); - QCC_PR_SimpleGetToken(); + QCC_PR_LexMacroName(); if (!*pr_token) QCC_PR_ParseError (ERR_BADFRAMEMACRO, "hanging $"); @@ -1764,27 +1801,27 @@ void QCC_PR_LexGrab (void) || !STRCMP (pr_token, "scale") || !STRCMP (pr_token, "skin") ) { // skip to end of line - while (QCC_PR_SimpleGetToken ()) + while (QCC_PR_LexMacroName ()) ; QCC_PR_Lex (); } else if (!STRCMP (pr_token, "flush")) { QCC_PR_ClearGrabMacros(); - while (QCC_PR_SimpleGetToken ()) + while (QCC_PR_LexMacroName ()) ; QCC_PR_Lex (); } else if (!STRCMP (pr_token, "framevalue")) { - QCC_PR_SimpleGetToken (); + QCC_PR_LexMacroName (); pr_macrovalue = atoi(pr_token); QCC_PR_Lex (); } else if (!STRCMP (pr_token, "framerestore")) { - QCC_PR_SimpleGetToken (); + QCC_PR_LexMacroName (); QCC_PR_ExpandMacro(); pr_macrovalue = (int)pr_immediate._float; @@ -1793,7 +1830,7 @@ void QCC_PR_LexGrab (void) else if (!STRCMP (pr_token, "modelname")) { int i; - QCC_PR_SimpleGetToken (); + QCC_PR_LexMacroName (); if (*pr_framemodelname) QCC_PR_MacroFrame(pr_framemodelname, pr_macrovalue);