History

added verbosity levels (-vv -vvv)

grischka committed 18 years ago

Commit a327c7a1 parent 4d9aaac3 files · +27 −14Browse files

Unified · Split

3 files
  1. tcc-doc.texi +1 −1
  2. tcc.c +24 −13
  3. tccelf.c +2 −0
tcc-doc.texi+1−1
@@ -153,7 +153,7 @@ General Options: · 152 unmodified lines
153153 @c man begin OPTIONS
154154 @table @option
155155 @item -v
156−Display current TCC version.
156+Display current TCC version, increase verbosity.
157157
158158 @item -c
159159 Generate an object file (@option{-o} option must also be given).
tcc.c+24−13
@@ -1960,6 +1960,9 @@ BufferedFile *tcc_open(TCCState *s1, const char *filename) · 1959 unmodified lines
19601960 fd = 0, filename = "stdin";
19611961 else
19621962 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);
19631966 if (fd < 0)
19641967 return NULL;
19651968 bf = tcc_malloc(sizeof(BufferedFile));
@@ -3033,6 +3036,11 @@ static void preprocess(int is_bof) · 1067 unmodified lines
30333036 printf("%s: skipping %s\n", file->filename, buf);
30343037 #endif
30353038 } 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;
30363044 if (c == '\"') {
30373045 /* first search in current dir if "header.h" */
30383046 size = tcc_basename(file->filename) - file->filename;
@@ -3049,8 +3057,6 @@ static void preprocess(int is_bof) · 10 unmodified lines
30493057 goto found;
30503058 }
30513059 }
3052− if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
3053− error("#include recursion too deep");
30543060 /* now search in all the include paths */
30553061 n = s1->nb_include_paths + s1->nb_sysinclude_paths;
30563062 for(i = 0; i < n; i++) {
@@ -3070,17 +3076,15 @@ static void preprocess(int is_bof) · 13 unmodified lines
30703076 goto found;
30713077 }
30723078 }
3079+ --s1->include_stack_ptr;
30733080 error("include file '%s' not found", buf);
3074− f = NULL;
3081+ break;
30753082 found:
30763083 #ifdef INC_DEBUG
30773084 printf("%s: including %s\n", file->filename, buf1);
30783085 #endif
30793086 f->inc_type = c;
30803087 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;
30843088 file = f;
30853089 /* add include file debug info */
30863090 if (do_debug) {
@@ -10566,7 +10570,7 @@ void help(void) · 7479 unmodified lines
1056610570 " [-static] [infile1 infile2...] [-run infile args...]\n"
1056710571 "\n"
1056810572 "General options:\n"
10569− " -v display current version\n"
10573+ " -v display current version, increase verbosity\n"
1057010574 " -c compile only - generate an object file\n"
1057110575 " -o outfile set output filename\n"
1057210576 " -Bdir set tcc internal library path\n"
@@ -10671,7 +10675,7 @@ static const TCCOption tcc_options[] = { · 98 unmodified lines
1067110675 { "nostdinc", TCC_OPTION_nostdinc, 0 },
1067210676 { "nostdlib", TCC_OPTION_nostdlib, 0 },
1067310677 { "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 },
1067510679 { "w", TCC_OPTION_w, 0 },
1067610680 { "pipe", TCC_OPTION_pipe, 0},
1067710681 { "E", TCC_OPTION_E, 0},
@@ -10723,10 +10727,12 @@ int parse_args(TCCState *s, int argc, char **argv) · 45 unmodified lines
1072310727 optind = 0;
1072410728 while (1) {
1072510729 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);
1072710733 goto show_help;
10728− else
10729− break;
10734+ }
10735+ break;
1073010736 }
1073110737 r = argv[optind++];
1073210738 if (r[0] != '-' || r[1] == '\0') {
@@ -10864,8 +10870,11 @@ int parse_args(TCCState *s, int argc, char **argv) · 131 unmodified lines
1086410870 }
1086510871 break;
1086610872 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;
1086910878 case TCC_OPTION_f:
1087010879 if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported)
1087110880 goto unsupported_option;
@@ -11020,6 +11029,8 @@ int main(int argc, char **argv) · 148 unmodified lines
1102011029 if (tcc_add_library(s, filename + 2) < 0)
1102111030 error("cannot find %s", filename);
1102211031 } else {
11032+ if (1 == verbose)
11033+ printf("-> %s\n", filename);
1102311034 if (tcc_add_file(s, filename) < 0)
1102411035 ret = 1;
1102511036 }
tccelf.c+2−0
@@ -1664,6 +1664,8 @@ int tcc_output_file(TCCState *s1, const char *filename) · 1663 unmodified lines
16641664 goto fail;
16651665 }
16661666 f = fdopen(fd, "wb");
1667+ if (verbose)
1668+ printf("<- %s\n", filename);
16671669
16681670 #ifdef TCC_TARGET_COFF
16691671 if (s1->output_format == TCC_OUTPUT_FORMAT_COFF) {

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