History

tcc_preprocess: add gcc-style include-depth flags

# 1 "main.c" # 1 "include/stdio.h" 1 # 123 "include/stdio.h" 3 # 10 "main.c" 2

grischka committed 17 years ago

Commit e4ae77c1 parent 956b4be1 file · +22 −7Browse files

Unified · Split

tccpp.c+22−7
@@ -2895,8 +2895,9 @@ void preprocess_new() · 2894 unmodified lines
2895static int tcc_preprocess(TCCState *s1)2895static int tcc_preprocess(TCCState *s1)
2896{2896{
2897 Sym *define_start;2897 Sym *define_start;
2898 BufferedFile *file_ref;2898 BufferedFile *file_ref, **iptr, **iptr_new;
2899 int token_seen, line_ref;2899 int token_seen, line_ref, d;
2900 const char *s;
2900 2901
2901 preprocess_init(s1);2902 preprocess_init(s1);
2902 define_start = define_stack;2903 define_start = define_stack;
@@ -2908,24 +2909,38 @@ static int tcc_preprocess(TCCState *s1) · 5 unmodified lines
2908 line_ref = 0;2909 line_ref = 0;
2909 file_ref = NULL;2910 file_ref = NULL;
2910 2911
2912 iptr = s1->include_stack_ptr;
2911 for (;;) {2913 for (;;) {
2912 next();2914 next();
2913 if (tok == TOK_EOF) {2915 if (tok == TOK_EOF) {
2914 break;2916 break;
2917 } else if (file != file_ref) {
2918 goto print_line;
2915 } else if (tok == TOK_LINEFEED) {2919 } else if (tok == TOK_LINEFEED) {
2916 if (!token_seen)2920 if (!token_seen)
2917 continue;2921 continue;
2918 ++line_ref;2922 ++line_ref;
2919 token_seen = 0;2923 token_seen = 0;
2920 } else if (!token_seen) {2924 } else if (!token_seen) {
2921 int d = file->line_num - line_ref;2925 d = file->line_num - line_ref;
2922 if (file != file_ref || d < 0 || d >= 8)2926 if (file != file_ref || d < 0 || d >= 8) {
2923 fprintf(s1->outfile, "# %d \"%s\"\n", file->line_num, file->filename);2927print_line:
2924 else2928 iptr_new = s1->include_stack_ptr;
2929 s = iptr_new > iptr ? " 1"
2930 : iptr_new < iptr ? " 2"
2931 : iptr_new > s1->include_stack ? " 3"
2932 : ""
2933 ;
2934 iptr = iptr_new;
2935 fprintf(s1->outfile, "# %d \"%s\"%s\n", file->line_num, file->filename, s);
2936 } else {
2925 while (d)2937 while (d)
2926 fputs("\n", s1->outfile), --d;2938 fputs("\n", s1->outfile), --d;
2939 }
2927 line_ref = (file_ref = file)->line_num;2940 line_ref = (file_ref = file)->line_num;
2928 token_seen = 1;2941 token_seen = tok != TOK_LINEFEED;
2942 if (!token_seen)
2943 continue;
2929 }2944 }
2930 fputs(get_tok_str(tok, &tokc), s1->outfile);2945 fputs(get_tok_str(tok, &tokc), s1->outfile);
2931 }2946 }

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