| @@ -1960,6 +1960,9 @@ BufferedFile *tcc_open(TCCState *s1, const char *filename) · 1959 unmodified lines |
| 1960 | fd = 0, filename = "stdin"; | 1960 | fd = 0, filename = "stdin"; |
| 1961 | else | 1961 | else |
| 1962 | fd = open(filename, O_RDONLY | O_BINARY); | 1962 | fd = open(filename, O_RDONLY | O_BINARY); |
| | 1963 | if ((verbose == 2 && fd >= 0) || verbose == 3) |
| | 1964 | printf("%s %*s%s\n", fd < 0 ? "nf":"->", |
| | 1965 | (s1->include_stack_ptr - s1->include_stack), "", filename); |
| 1963 | if (fd < 0) | 1966 | if (fd < 0) |
| 1964 | return NULL; | 1967 | return NULL; |
| 1965 | bf = tcc_malloc(sizeof(BufferedFile)); | 1968 | bf = tcc_malloc(sizeof(BufferedFile)); |
| @@ -3033,6 +3036,11 @@ static void preprocess(int is_bof) · 1067 unmodified lines |
| 3033 | printf("%s: skipping %s\n", file->filename, buf); | 3036 | printf("%s: skipping %s\n", file->filename, buf); |
| 3034 | #endif | 3037 | #endif |
| 3035 | } else { | 3038 | } else { |
| | 3039 | if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE) |
| | 3040 | error("#include recursion too deep"); |
| | 3041 | /* push current file in stack */ |
| | 3042 | /* XXX: fix current line init */ |
| | 3043 | *s1->include_stack_ptr++ = file; |
| 3036 | if (c == '\"') { | 3044 | if (c == '\"') { |
| 3037 | /* first search in current dir if "header.h" */ | 3045 | /* first search in current dir if "header.h" */ |
| 3038 | size = tcc_basename(file->filename) - file->filename; | 3046 | size = tcc_basename(file->filename) - file->filename; |
| @@ -3049,8 +3057,6 @@ static void preprocess(int is_bof) · 10 unmodified lines |
| 3049 | goto found; | 3057 | goto found; |
| 3050 | } | 3058 | } |
| 3051 | } | 3059 | } |
| 3052 | if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE) | | |
| 3053 | error("#include recursion too deep"); | | |
| 3054 | /* now search in all the include paths */ | 3060 | /* now search in all the include paths */ |
| 3055 | n = s1->nb_include_paths + s1->nb_sysinclude_paths; | 3061 | n = s1->nb_include_paths + s1->nb_sysinclude_paths; |
| 3056 | for(i = 0; i < n; i++) { | 3062 | for(i = 0; i < n; i++) { |
| @@ -3070,17 +3076,15 @@ static void preprocess(int is_bof) · 13 unmodified lines |
| 3070 | goto found; | 3076 | goto found; |
| 3071 | } | 3077 | } |
| 3072 | } | 3078 | } |
| | 3079 | --s1->include_stack_ptr; |
| 3073 | error("include file '%s' not found", buf); | 3080 | error("include file '%s' not found", buf); |
| 3074 | f = NULL; | 3081 | break; |
| 3075 | found: | 3082 | found: |
| 3076 | #ifdef INC_DEBUG | 3083 | #ifdef INC_DEBUG |
| 3077 | printf("%s: including %s\n", file->filename, buf1); | 3084 | printf("%s: including %s\n", file->filename, buf1); |
| 3078 | #endif | 3085 | #endif |
| 3079 | f->inc_type = c; | 3086 | f->inc_type = c; |
| 3080 | pstrcpy(f->inc_filename, sizeof(f->inc_filename), buf); | 3087 | pstrcpy(f->inc_filename, sizeof(f->inc_filename), buf); |
| 3081 | /* push current file in stack */ | | |
| 3082 | /* XXX: fix current line init */ | | |
| 3083 | *s1->include_stack_ptr++ = file; | | |
| 3084 | file = f; | 3088 | file = f; |
| 3085 | /* add include file debug info */ | 3089 | /* add include file debug info */ |
| 3086 | if (do_debug) { | 3090 | if (do_debug) { |
| @@ -10566,7 +10570,7 @@ void help(void) · 7479 unmodified lines |
| 10566 | " [-static] [infile1 infile2...] [-run infile args...]\n" | 10570 | " [-static] [infile1 infile2...] [-run infile args...]\n" |
| 10567 | "\n" | 10571 | "\n" |
| 10568 | "General options:\n" | 10572 | "General options:\n" |
| 10569 | " -v display current version\n" | 10573 | " -v display current version, increase verbosity\n" |
| 10570 | " -c compile only - generate an object file\n" | 10574 | " -c compile only - generate an object file\n" |
| 10571 | " -o outfile set output filename\n" | 10575 | " -o outfile set output filename\n" |
| 10572 | " -Bdir set tcc internal library path\n" | 10576 | " -Bdir set tcc internal library path\n" |
| @@ -10671,7 +10675,7 @@ static const TCCOption tcc_options[] = { · 98 unmodified lines |
| 10671 | { "nostdinc", TCC_OPTION_nostdinc, 0 }, | 10675 | { "nostdinc", TCC_OPTION_nostdinc, 0 }, |
| 10672 | { "nostdlib", TCC_OPTION_nostdlib, 0 }, | 10676 | { "nostdlib", TCC_OPTION_nostdlib, 0 }, |
| 10673 | { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, | 10677 | { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, |
| 10674 | { "v", TCC_OPTION_v, 0 }, | 10678 | { "v", TCC_OPTION_v, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 10675 | { "w", TCC_OPTION_w, 0 }, | 10679 | { "w", TCC_OPTION_w, 0 }, |
| 10676 | { "pipe", TCC_OPTION_pipe, 0}, | 10680 | { "pipe", TCC_OPTION_pipe, 0}, |
| 10677 | { "E", TCC_OPTION_E, 0}, | 10681 | { "E", TCC_OPTION_E, 0}, |
| @@ -10723,10 +10727,12 @@ int parse_args(TCCState *s, int argc, char **argv) · 45 unmodified lines |
| 10723 | optind = 0; | 10727 | optind = 0; |
| 10724 | while (1) { | 10728 | while (1) { |
| 10725 | if (optind >= argc) { | 10729 | if (optind >= argc) { |
| 10726 | if (nb_files == 0 && !print_search_dirs) | 10730 | if (nb_files == 0 && !print_search_dirs) { |
| | 10731 | if (verbose) |
| | 10732 | exit(0); |
| 10727 | goto show_help; | 10733 | goto show_help; |
| 10728 | else | 10734 | } |
| 10729 | break; | 10735 | break; |
| 10730 | } | 10736 | } |
| 10731 | r = argv[optind++]; | 10737 | r = argv[optind++]; |
| 10732 | if (r[0] != '-' || r[1] == '\0') { | 10738 | if (r[0] != '-' || r[1] == '\0') { |
| @@ -10864,8 +10870,11 @@ int parse_args(TCCState *s, int argc, char **argv) · 131 unmodified lines |
| 10864 | } | 10870 | } |
| 10865 | break; | 10871 | break; |
| 10866 | case TCC_OPTION_v: | 10872 | case TCC_OPTION_v: |
| 10867 | printf("tcc version %s\n", TCC_VERSION); | 10873 | do { |
| 10868 | exit(0); | 10874 | if (0 == verbose++) |
| | 10875 | printf("tcc version %s\n", TCC_VERSION); |
| | 10876 | } while (*optarg++ == 'v'); |
| | 10877 | break; |
| 10869 | case TCC_OPTION_f: | 10878 | case TCC_OPTION_f: |
| 10870 | if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported) | 10879 | if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported) |
| 10871 | goto unsupported_option; | 10880 | goto unsupported_option; |
| @@ -11020,6 +11029,8 @@ int main(int argc, char **argv) · 148 unmodified lines |
| 11020 | if (tcc_add_library(s, filename + 2) < 0) | 11029 | if (tcc_add_library(s, filename + 2) < 0) |
| 11021 | error("cannot find %s", filename); | 11030 | error("cannot find %s", filename); |
| 11022 | } else { | 11031 | } else { |
| | 11032 | if (1 == verbose) |
| | 11033 | printf("-> %s\n", filename); |
| 11023 | if (tcc_add_file(s, filename) < 0) | 11034 | if (tcc_add_file(s, filename) < 0) |
| 11024 | ret = 1; | 11035 | ret = 1; |
| 11025 | } | 11036 | } |