Use TOK_PPNUM/TOK_PPSTR instead of TOK_CINT/TOK_STR
I noticed that '#line 0x20' worked. So use the preprocessor macros.
This commit is contained in:
parent
999ec460a6
commit
f6385c0530
1 changed files with 11 additions and 7 deletions
18
tccpp.c
18
tccpp.c
|
@ -1929,31 +1929,35 @@ ST_FUNC void preprocess(int is_bof)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_LINE:
|
case TOK_LINE:
|
||||||
|
parse_flags &= ~PARSE_FLAG_TOK_NUM;
|
||||||
next();
|
next();
|
||||||
if (tok != TOK_CINT) {
|
parse_flags |= PARSE_FLAG_TOK_NUM;
|
||||||
|
if (tok != TOK_PPNUM) {
|
||||||
_line_err:
|
_line_err:
|
||||||
tcc_error("wrong #line format");
|
tcc_error("wrong #line format");
|
||||||
}
|
}
|
||||||
n = tokc.i;
|
|
||||||
goto _line_num;
|
goto _line_num;
|
||||||
case TOK_PPNUM:
|
case TOK_PPNUM:
|
||||||
if (parse_flags & PARSE_FLAG_ASM_FILE)
|
if (parse_flags & PARSE_FLAG_ASM_FILE)
|
||||||
goto ignore;
|
goto ignore;
|
||||||
|
_line_num:
|
||||||
for (n = 0, q = tokc.str.data; *q; ++q) {
|
for (n = 0, q = tokc.str.data; *q; ++q) {
|
||||||
if (!isnum(*q))
|
if (!isnum(*q))
|
||||||
goto _line_err;
|
goto _line_err;
|
||||||
n = n * 10 + *q - '0';
|
n = n * 10 + *q - '0';
|
||||||
}
|
}
|
||||||
_line_num:
|
parse_flags &= ~PARSE_FLAG_TOK_STR;
|
||||||
next();
|
next();
|
||||||
if (tok == TOK_STR) {
|
parse_flags |= PARSE_FLAG_TOK_STR;
|
||||||
tccpp_putfile(tokc.str.data);
|
if (tok == TOK_PPSTR && tokc.str.data[0] == '"') {
|
||||||
|
tokc.str.data[tokc.str.size - 2] = 0;
|
||||||
|
tccpp_putfile(tokc.str.data + 1);
|
||||||
n--;
|
n--;
|
||||||
|
if (macro_ptr && *macro_ptr == 0)
|
||||||
|
macro_stack->save_line_num = n;
|
||||||
}
|
}
|
||||||
else if (tok != TOK_LINEFEED)
|
else if (tok != TOK_LINEFEED)
|
||||||
goto _line_err;
|
goto _line_err;
|
||||||
if (macro_ptr && *macro_ptr == 0)
|
|
||||||
macro_stack->save_line_num = n;
|
|
||||||
if (file->fd > 0)
|
if (file->fd > 0)
|
||||||
total_lines += file->line_num - n;
|
total_lines += file->line_num - n;
|
||||||
file->line_ref += file->line_num - n;
|
file->line_ref += file->line_num - n;
|
||||||
|
|
Loading…
Add table
Reference in a new issue