From 02433b23aa3108d6726fcc8b127f09bf42e1ebf5 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 27 Oct 2004 23:51:52 +0000 Subject: [PATCH] Support for # and ## git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@379 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_lex.c | 41 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index c3744fe45..d35874107 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -1696,6 +1696,7 @@ char *monthnames[] = int QCC_PR_CheakCompConst(void) { char *oldpr_file_p = pr_file_p; + int whitestart; CompilerConstant_t *c; @@ -1780,9 +1781,9 @@ int QCC_PR_CheakCompConst(void) oldpr_file_p = pr_file_p; pr_file_p = c->value; - do + for(;;) { - p = strlen(buffer); + whitestart = p = strlen(buffer); while(*pr_file_p <= ' ') //copy across whitespace { if (!*pr_file_p) @@ -1791,6 +1792,40 @@ int QCC_PR_CheakCompConst(void) } buffer[p] = 0; + if (*pr_file_p == '#') //if you ask for #a##b you will be shot. use #a #b instead. + { + if (pr_file_p[1] == '#') + { //concatinate (srip out whitespace) + buffer[whitestart] = '\0'; + pr_file_p+=2; + } + else + { //stringify + pr_file_p++; + pr_file_p = QCC_COM_Parse(pr_file_p); + if (!pr_file_p) + break; + + for (p = 0; p < param; p++) + { + if (!STRCMP(qcc_token, c->params[p])) + { + strcat(buffer, "\""); + strcat(buffer, paramoffset[p]); + strcat(buffer, "\""); + break; + } + } + if (p == param) + { + strcat(buffer, "#"); + strcat(buffer, qcc_token); + QCC_PR_ParseWarning(0, "Stingification ignored"); + } + continue; //already did this one + } + } + pr_file_p = QCC_COM_Parse(pr_file_p); if (!pr_file_p) break; @@ -1805,7 +1840,7 @@ int QCC_PR_CheakCompConst(void) } if (p == param) strcat(buffer, qcc_token); - } while(1); + } for (p = 0; p < param-1; p++) paramoffset[p][strlen(paramoffset[p])] = ',';