From: Wolfgang (Blub) Bumiller Date: Thu, 16 Aug 2012 18:49:58 +0000 (+0200) Subject: Don't expand frame macros when they don't have a $ prefix X-Git-Tag: 0.1-rc1~237 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3b9a6b3ace8b7358eee5ecdfdd2b998a7fbacfb0;p=xonotic%2Fgmqcc.git Don't expand frame macros when they don't have a $ prefix --- diff --git a/data/parsing.qc b/data/parsing.qc index 5c61f8c..f75a136 100644 --- a/data/parsing.qc +++ b/data/parsing.qc @@ -62,5 +62,5 @@ void() main = { print3("memb = ", ftos(pawn.memb), "\n"); pawn.memb += -1; print3("memb = ", ftos(pawn.memb), "\n"); - print3("Frame stand3 is ", ftos(stand3), " wooh\n"); + print3("Frame stand3 is ", ftos($stand3), " wooh\n"); }; diff --git a/lexer.c b/lexer.c index c35a88c..5042c03 100644 --- a/lexer.c +++ b/lexer.c @@ -542,6 +542,8 @@ int lex_do(lex_file *lex) /* modelgen / spiritgen commands */ if (ch == '$') { const char *v; + size_t frame; + ch = lex_getch(lex); if (!isident_start(ch)) { lexerror(lex, "hanging '$' modelgen/spritegen command line"); @@ -618,6 +620,16 @@ int lex_do(lex_file *lex) ch = lex_getch(lex); return lex_do(lex); } + + for (frame = 0; frame < lex->frames_count; ++frame) { + if (!strcmp(v, lex->frames[frame].name)) { + lex->tok->constval.i = lex->frames[frame].value; + return (lex->tok->ttype = TOKEN_INTCONST); + } + } + + lexerror(lex, "invalid frame macro"); + return lex_do(lex); } /* single-character tokens */ @@ -738,7 +750,7 @@ int lex_do(lex_file *lex) if (isident_start(ch)) { const char *v; - size_t frame; + if (!lex_tokench(lex, ch)) return (lex->tok->ttype = TOKEN_FATAL); if (!lex_finish_ident(lex)) { @@ -778,13 +790,6 @@ int lex_do(lex_file *lex) !strcmp(v, "const")) lex->tok->ttype = TOKEN_KEYWORD; - for (frame = 0; frame < lex->frames_count; ++frame) { - if (!strcmp(v, lex->frames[frame].name)) { - lex->tok->constval.i = lex->frames[frame].value; - return (lex->tok->ttype = TOKEN_INTCONST); - } - } - return lex->tok->ttype; }