mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-21 18:30:52 +00:00
Don't expand frame macros when they don't have a $ prefix
This commit is contained in:
parent
e00c8da849
commit
3b9a6b3ace
2 changed files with 14 additions and 9 deletions
|
@ -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");
|
||||
};
|
||||
|
|
21
lexer.c
21
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue