changelog shortlog tags files raw bz2 zip gz

changeset: Add -v option (and -v -v, and -v -v -v).

changeset 523: d72f42753974
parent 522:a6abef04cb53
child 524:5e8699ff4a69
author: Rob Landley <rob@landley.net>
date: Wed Dec 05 14:49:28 2007 -0600 (4 years ago)
files: tcc.c tcc.h
description: Add -v option (and -v -v, and -v -v -v).
       1--- a/tcc.c	Wed Dec 05 05:33:59 2007 -0600
       2+++ b/tcc.c	Wed Dec 05 14:49:28 2007 -0600
       3@@ -2017,6 +2017,9 @@
       4             n = s1->include_paths.len + s1->sysinclude_paths.len;
       5             for(i = 0; i < n; i++) {
       6                 const char *path;
       7+                int verbose = s1->verbose;
       8+
       9+                verbose -= (s1->include_stack_ptr != s1->include_stack);
      10                 if (i < s1->include_paths.len)
      11                     path = s1->include_paths.data[i];
      12                 else
      13@@ -2025,6 +2028,8 @@
      14                 pstrcat(buf1, sizeof(buf1), "/");
      15                 pstrcat(buf1, sizeof(buf1), buf);
      16                 f = tcc_open(s1, buf1);
      17+                if (verbose > !f)
      18+                    printf("#%s '%s'\n", f ? "include" : "checked", buf1);
      19                 if (f) {
      20                     if (tok == TOK_INCLUDE_NEXT)
      21                         tok = TOK_INCLUDE;
      22@@ -8941,6 +8946,8 @@
      23     /* open the file */
      24     saved_file = file;
      25     file = tcc_open(s1, filename);
      26+    if (s1->verbose > !file)
      27+        printf("%s file '%s'\n", file ? "Read" : "Tried", filename);
      28     if (!file) {
      29         if (flags & AFF_PRINT_ERROR) {
      30             error_noabort("file '%s' not found", filename);
      31@@ -9259,15 +9266,21 @@
      32 #endif
      33 }
      34 
      35-void help(void)
      36-{
      37-    printf("tinycc version " TINYCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n"
      38+void show_version(void)
      39+{
      40+    printf("tinycc version " TINYCC_VERSION "\n");
      41+}
      42+
      43+void help(TCCState *s)
      44+{
      45+    show_version();
      46+    printf("Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard, 2007 Rob Landley\n"
      47            "usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n"
      48            "           [-Wwarn] [-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-static]\n"
      49            "           [infile1 infile2...] [-run infile args...]\n"
      50            "\n"
      51            "General options:\n"
      52-           "  -v          display current version\n"
      53+           "  -v          Verbose compile, repeat for more verbosity\n"
      54            "  -c          compile only - generate an object file\n"
      55            "  -o outfile  set output filename\n"
      56            "  -Bdir       set tcc internal library path\n"
      57@@ -9420,10 +9433,10 @@
      58     optind = 0;
      59     while (1) {
      60         if (optind >= argc) {
      61-            if (nb_files == 0 && !print_search_dirs)
      62-                goto show_help;
      63-            else
      64-                break;
      65+            if (nb_files == 0 && !print_search_dirs) {
      66+                if (!s->verbose) help(s);
      67+                exit(1);
      68+            } else break;
      69         }
      70         r = argv[optind++];
      71         if (r[0] != '-') {
      72@@ -9462,15 +9475,16 @@
      73                     optarg = argv[optind++];
      74                 }
      75             } else {
      76-                if (*r1 != '\0')
      77-                    goto show_help;
      78+                if (*r1 != '\0') {
      79+                    help(s);
      80+                    exit(1);
      81+                }
      82                 optarg = NULL;
      83             }
      84                 
      85             switch(popt->index) {
      86             case TCC_OPTION_HELP:
      87-            show_help:
      88-                help();
      89+                help(s);
      90                 exit(1);
      91             case TCC_OPTION_I:
      92                 add_dynarray_path(s, optarg, &(s->include_paths));
      93@@ -9560,8 +9574,8 @@
      94                 }
      95                 break;
      96             case TCC_OPTION_v:
      97-                printf("tinycc version %s\n", TINYCC_VERSION);
      98-                exit(0);
      99+                if (!s->verbose++) show_version();
     100+                break;
     101             case TCC_OPTION_f:
     102                 if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported)
     103                     goto unsupported_option;
     1.1--- a/tcc.h	Wed Dec 05 05:33:59 2007 -0600
     1.2+++ b/tcc.h	Wed Dec 05 14:49:28 2007 -0600
     1.3@@ -363,6 +363,9 @@
     1.4 
     1.5     /* if true, all symbols are exported */
     1.6     int rdynamic;
     1.7+
     1.8+    /* if true, describe each room as you enter it, unless it contains a grue */
     1.9+    int verbose;
    1.10 
    1.11     /* if true, only link in referenced objects from archive */
    1.12     int alacarte_link;