History

#include_next support (Bernhard Fischer)

bellard committed 21 years ago

Commit 8f2d5191 parent 98250112 files · +14 −4Browse files

Unified · Split

2 files
  1. tcc.c +13 −4
  2. tcctok.h +1 −0
tcc.c+13−4
@@ -2731,6 +2731,7 @@ static void preprocess(int is_bof) · 2730 unmodified lines
27312731 define_undef(s);
27322732 break;
27332733 case TOK_INCLUDE:
2734+ case TOK_INCLUDE_NEXT:
27342735 ch = file->buf_ptr[0];
27352736 /* XXX: incorrect if comments : use next_nomacro with a special mode */
27362737 skip_spaces();
@@ -2807,8 +2808,12 @@ static void preprocess(int is_bof) · 70 unmodified lines
28072808 buf1[size] = '\0';
28082809 pstrcat(buf1, sizeof(buf1), buf);
28092810 f = tcc_open(s1, buf1);
2810− if (f)
2811− goto found;
2811+ if (f) {
2812+ if (tok == TOK_INCLUDE_NEXT)
2813+ tok = TOK_INCLUDE;
2814+ else
2815+ goto found;
2816+ }
28122817 }
28132818 if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
28142819 error("#include recursion too deep");
@@ -2824,8 +2829,12 @@ static void preprocess(int is_bof) · 9 unmodified lines
28242829 pstrcat(buf1, sizeof(buf1), "/");
28252830 pstrcat(buf1, sizeof(buf1), buf);
28262831 f = tcc_open(s1, buf1);
2827− if (f)
2828− goto found;
2832+ if (f) {
2833+ if (tok == TOK_INCLUDE_NEXT)
2834+ tok = TOK_INCLUDE;
2835+ else
2836+ goto found;
2837+ }
28292838 }
28302839 error("include file '%s' not found", buf);
28312840 f = NULL;
tcctok.h+1−0
@@ -64,6 +64,7 @@ · 63 unmodified lines
6464 /* preprocessor only */
6565 DEF(TOK_DEFINE, "define")
6666 DEF(TOK_INCLUDE, "include")
67+ DEF(TOK_INCLUDE_NEXT, "include_next")
6768 DEF(TOK_IFDEF, "ifdef")
6869 DEF(TOK_IFNDEF, "ifndef")
6970 DEF(TOK_ELIF, "elif")

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