mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +00:00
fixup line counting in #pragmas
This commit is contained in:
parent
79619fbf50
commit
9898ab5316
1 changed files with 7 additions and 2 deletions
9
lexer.c
9
lexer.c
|
@ -353,10 +353,13 @@ static bool lex_try_pragma(lex_file *lex)
|
||||||
char *pragma = NULL;
|
char *pragma = NULL;
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
char *param = NULL;
|
char *param = NULL;
|
||||||
|
size_t line;
|
||||||
|
|
||||||
if (lex->flags.preprocessing)
|
if (lex->flags.preprocessing)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
line = lex->line;
|
||||||
|
|
||||||
ch = lex_getch(lex);
|
ch = lex_getch(lex);
|
||||||
if (ch != '#') {
|
if (ch != '#') {
|
||||||
lex_ungetch(lex, ch);
|
lex_ungetch(lex, ch);
|
||||||
|
@ -393,7 +396,7 @@ static bool lex_try_pragma(lex_file *lex)
|
||||||
if (!strcmp(command, "push")) {
|
if (!strcmp(command, "push")) {
|
||||||
if (!strcmp(param, "line")) {
|
if (!strcmp(param, "line")) {
|
||||||
lex->push_line++;
|
lex->push_line++;
|
||||||
lex->line--;
|
--line;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto unroll;
|
goto unroll;
|
||||||
|
@ -402,7 +405,6 @@ static bool lex_try_pragma(lex_file *lex)
|
||||||
if (!strcmp(param, "line")) {
|
if (!strcmp(param, "line")) {
|
||||||
if (lex->push_line)
|
if (lex->push_line)
|
||||||
lex->push_line--;
|
lex->push_line--;
|
||||||
lex->line--;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto unroll;
|
goto unroll;
|
||||||
|
@ -412,6 +414,7 @@ static bool lex_try_pragma(lex_file *lex)
|
||||||
|
|
||||||
while (ch != '\n')
|
while (ch != '\n')
|
||||||
ch = lex_getch(lex);
|
ch = lex_getch(lex);
|
||||||
|
lex->line = line;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
unroll:
|
unroll:
|
||||||
|
@ -440,6 +443,8 @@ unroll:
|
||||||
vec_free(pragma);
|
vec_free(pragma);
|
||||||
}
|
}
|
||||||
lex_ungetch(lex, '#');
|
lex_ungetch(lex, '#');
|
||||||
|
|
||||||
|
lex->line = line;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue