diff -X /usr/src/excl -ruNp upstream/tinycc/tcc.c tinycc.b/tcc.c --- upstream/tinycc/tcc.c 2004-12-16 23:19:28.000000000 +0100 +++ tinycc.b/tcc.c 2005-03-31 18:28:51.867904128 +0200 @@ -2716,7 +2716,9 @@ static void preprocess(int is_bof) if (s) define_undef(s); break; + case TOK_INCLUDE_NEXT: case TOK_INCLUDE: + ch = file->buf_ptr[0]; /* XXX: incorrect if comments : use next_nomacro with a special mode */ skip_spaces(); @@ -2778,14 +2780,14 @@ static void preprocess(int is_bof) /* no need to parse the include because the 'ifndef macro' is defined */ #ifdef INC_DEBUG - printf("%s: skipping %s\n", file->filename, buf); + printf("%s: skipping known include %s\n", file->filename, buf); #endif } else { if (c == '\"') { /* first search in current dir if "header.h" */ size = 0; p = strrchr(file->filename, '/'); - if (p) + if (p) size = p + 1 - file->filename; if (size > sizeof(buf1) - 1) size = sizeof(buf1) - 1; @@ -2793,8 +2795,17 @@ static void preprocess(int is_bof) buf1[size] = '\0'; pstrcat(buf1, sizeof(buf1), buf); f = tcc_open(s1, buf1); - if (f) + if (f) { + if (tok == TOK_INCLUDE_NEXT) { +#ifdef INC_NEXT_DEBUG + /* #include_next, so skip this one and take the next */ + printf("%s: skipping include_next \"%s\"\n", + file->filename, buf); +#endif + tok = TOK_INCLUDE; + } else goto found; + } } if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE) error("#include recursion too deep"); @@ -2806,12 +2817,24 @@ static void preprocess(int is_bof) path = s1->include_paths[i]; else path = s1->sysinclude_paths[i - s1->nb_include_paths]; +#ifdef INC_NEXT_DEBUG + printf("%s: looking in %s\n", file->filename, path); +#endif pstrcpy(buf1, sizeof(buf1), path); pstrcat(buf1, sizeof(buf1), "/"); pstrcat(buf1, sizeof(buf1), buf); f = tcc_open(s1, buf1); - if (f) + if (f) { + if (tok == TOK_INCLUDE_NEXT) { +#ifdef INC_NEXT_DEBUG + /* #include_next, so skip this one and take the next */ + printf("%s: skipping include_next <%s>\n", + file->filename, buf); +#endif + tok = TOK_INCLUDE; + } else goto found; + } } error("include file '%s' not found", buf); f = NULL; diff -X /usr/src/excl -ruNp upstream/tinycc/tcctok.h tinycc.b/tcctok.h --- upstream/tinycc/tcctok.h 2004-10-30 01:55:13.000000000 +0200 +++ tinycc.b/tcctok.h 2005-03-31 14:59:19.918131000 +0200 @@ -64,6 +64,7 @@ /* preprocessor only */ DEF(TOK_DEFINE, "define") DEF(TOK_INCLUDE, "include") + DEF(TOK_INCLUDE_NEXT, "include_next") DEF(TOK_IFDEF, "ifdef") DEF(TOK_IFNDEF, "ifndef") DEF(TOK_ELIF, "elif")