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