mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
Handle all possible subscript errors
This commit is contained in:
parent
1597f38f45
commit
7ea1033a43
1 changed files with 26 additions and 24 deletions
12
ftepp.c
12
ftepp.c
|
@ -411,15 +411,13 @@ static bool ftepp_define_body(ftepp_t *ftepp, ppmacro *macro)
|
|||
bool subscript = false;
|
||||
size_t index = 0;
|
||||
if (macro->variadic && !strcmp(ftepp_tokval(ftepp), "__VA_ARGS__")) {
|
||||
/* remember the token */
|
||||
if (ftepp_next(ftepp) == '#') {
|
||||
subscript = true;
|
||||
}
|
||||
subscript = !!(ftepp_next(ftepp) == '#');
|
||||
|
||||
if (subscript && ftepp_next(ftepp) != '#') {
|
||||
ftepp_error(ftepp, "expected `##` in __VA_ARGS__ for subscripting");
|
||||
return false;
|
||||
} else if (subscript && ftepp_next(ftepp) == '[') {
|
||||
} else if (subscript) {
|
||||
if (ftepp_next(ftepp) == '[') {
|
||||
if (ftepp_next(ftepp) != TOKEN_INTCONST) {
|
||||
ftepp_error(ftepp, "expected index for __VA_ARGS__ subscript");
|
||||
return false;
|
||||
|
@ -441,6 +439,10 @@ static bool ftepp_define_body(ftepp_t *ftepp, ppmacro *macro)
|
|||
ptok->constval.i = index;
|
||||
vec_push(macro->output, ptok);
|
||||
ftepp_next(ftepp);
|
||||
} else {
|
||||
ftepp_error(ftepp, "expected `[` for subscripting of __VA_ARGS__");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
int old = ftepp->token;
|
||||
ftepp->token = TOKEN_VA_ARGS;
|
||||
|
|
Loading…
Reference in a new issue