History

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

seyko committed 11 years ago

Commit 6b9490b1 parent ad524bb1 file · +15 −1Browse files

Unified · Split

tccpp.c+15−1
@@ -1528,6 +1528,7 @@ ST_FUNC void preprocess(int is_bof) · 1527 unmodified lines
15281528 int i, c, n, saved_parse_flags;
15291529 char buf[1024], *q;
15301530 Sym *s;
1531+ int include_next_first_try = 1;
15311532
15321533 saved_parse_flags = parse_flags;
15331534 parse_flags = PARSE_FLAG_PREPROCESS
@@ -1617,6 +1618,7 @@ ST_FUNC void preprocess(int is_bof) · 83 unmodified lines
16171618 /* store current file in stack, but increment stack later below */
16181619 *s1->include_stack_ptr = file;
16191620
1621+ search_again:
16201622 n = s1->nb_include_paths + s1->nb_sysinclude_paths;
16211623 for (i = -2; i < n; ++i) {
16221624 char buf1[sizeof file->filename];
@@ -1650,14 +1652,22 @@ ST_FUNC void preprocess(int is_bof) · 27 unmodified lines
16501652
16511653 pstrcat(buf1, sizeof(buf1), buf);
16521654
1653− if (tok == TOK_INCLUDE_NEXT)
1655+ if (tok == TOK_INCLUDE_NEXT) {
16541656 for (f = s1->include_stack_ptr; f >= s1->include_stack; --f)
1657+ if (include_next_first_try) {
16551658 if (0 == PATHCMP((*f)->filename, buf1)) {
16561659 #ifdef INC_DEBUG
16571660 printf("%s: #include_next skipping %s\n", file->filename, buf1);
16581661 #endif
1662+ include_next_first_try++;
16591663 goto include_trynext;
16601664 }
1665+ } else {
1666+ if (0 == PATHCMP(file->filename, buf1)) {
1667+ goto include_trynext;
1668+ }
1669+ }
1670+ }
16611671
16621672 e = search_cached_include(s1, buf1);
16631673 if (e && (define_find(e->ifndef_macro) || e->ifndef_macro == TOK_once)) {
@@ -1688,6 +1698,10 @@ include_trynext: · 24 unmodified lines
16881698 ch = file->buf_ptr[0];
16891699 goto the_end;
16901700 }
1701+ if (include_next_first_try > 1) {
1702+ include_next_first_try = 0;
1703+ goto search_again;
1704+ }
16911705 tcc_error("include file '%s' not found", buf);
16921706 include_done:
16931707 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t