mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-28 04:00:06 +08:00
fix for the #include_next, v2
A more correct fix. This one don't break old logic. But if include file is not found, we try to search again with the new compare rule. A description of the problem: http://permalink.gmane.org/gmane.comp.compilers.tinycc.devel/2769
This commit is contained in:
parent
ad524bb6c7
commit
6b9490b6ff
16
tccpp.c
16
tccpp.c
@ -1528,6 +1528,7 @@ ST_FUNC void preprocess(int is_bof)
|
||||
int i, c, n, saved_parse_flags;
|
||||
char buf[1024], *q;
|
||||
Sym *s;
|
||||
int include_next_first_try = 1;
|
||||
|
||||
saved_parse_flags = parse_flags;
|
||||
parse_flags = PARSE_FLAG_PREPROCESS
|
||||
@ -1617,6 +1618,7 @@ ST_FUNC void preprocess(int is_bof)
|
||||
/* store current file in stack, but increment stack later below */
|
||||
*s1->include_stack_ptr = file;
|
||||
|
||||
search_again:
|
||||
n = s1->nb_include_paths + s1->nb_sysinclude_paths;
|
||||
for (i = -2; i < n; ++i) {
|
||||
char buf1[sizeof file->filename];
|
||||
@ -1650,14 +1652,22 @@ ST_FUNC void preprocess(int is_bof)
|
||||
|
||||
pstrcat(buf1, sizeof(buf1), buf);
|
||||
|
||||
if (tok == TOK_INCLUDE_NEXT)
|
||||
if (tok == TOK_INCLUDE_NEXT) {
|
||||
for (f = s1->include_stack_ptr; f >= s1->include_stack; --f)
|
||||
if (include_next_first_try) {
|
||||
if (0 == PATHCMP((*f)->filename, buf1)) {
|
||||
#ifdef INC_DEBUG
|
||||
printf("%s: #include_next skipping %s\n", file->filename, buf1);
|
||||
#endif
|
||||
include_next_first_try++;
|
||||
goto include_trynext;
|
||||
}
|
||||
} else {
|
||||
if (0 == PATHCMP(file->filename, buf1)) {
|
||||
goto include_trynext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e = search_cached_include(s1, buf1);
|
||||
if (e && (define_find(e->ifndef_macro) || e->ifndef_macro == TOK_once)) {
|
||||
@ -1688,6 +1698,10 @@ include_trynext:
|
||||
ch = file->buf_ptr[0];
|
||||
goto the_end;
|
||||
}
|
||||
if (include_next_first_try > 1) {
|
||||
include_next_first_try = 0;
|
||||
goto search_again;
|
||||
}
|
||||
tcc_error("include file '%s' not found", buf);
|
||||
include_done:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user