diff mbox

gengtype improvements for plugins. patch 2/N [verbosity]

Message ID 1283063995.3067.63.camel@glinka
State New
Headers show

Commit Message

Basile Starynkevitch Aug. 29, 2010, 6:39 a.m. UTC
The second part of our series of patches add verbosity to gengtype. When
passed the -v flag (which can be given more than once), the gengtype
generator shows changed files (and also unchanged output files if passed
twice). 

The attached file relpatch02to01ter-verbosity.diff is a patch relative
to the latest patch we did send, that is to
http://gcc.gnu.org/ml/gcc-patches/2010-08/msg02058.html

This relative patch was obtained by 
diff -u -p -b gcc/gengtype.c gcc/gengtype.h \
     --from-file ../gcc-gengtype-01/

The corresponding gcc/ChangeLog entry is attached as
relpatch02to01ter-verbosity.ChangeLog

For convenience, I am also attaching the entire cumulated patch to trunk
r163612. It is not for reviewers, but for people wanting to test all our
patches at once quickly. The cumulated patch is against trunk r163612 as
an attached gzipped file all-patches-r163612-up-to-02.diff.gz

Ok for trunk?

Cheers.

Comments

Laurynas Biveinis Sept. 3, 2010, 8:08 a.m. UTC | #1
> --- ../gcc-gengtype-01/gengtype.h	2010-08-29 08:16:56.000000000 +0200
> +++ gcc/gengtype.h	2010-08-29 08:17:58.000000000 +0200
> @@ -145,6 +145,9 @@ enum {
>  };
>
>
> +/* Level for verbose messages, e.g. output file generation... */
> +extern int verbosity_level;
> +

/* Verbosity level for gengtype output */ <- again, this is a very
subjective suggestion.

I assume some later patch uses verbosity_level outside of gengtype.c,
is that correct?

+	  printf ("gengtype write #%-3d %s\n", nbwrittenfiles, of->name);

"writes" I guess.

+	  printf ("gengtype keep %s\n", of->name);

keeps


I cannot approve, but the patch looks OK to me with comments addressed.
diff mbox

Patch

--- ../gcc-gengtype-01/gengtype.c	2010-08-29 08:16:56.000000000 +0200
+++ gcc/gengtype.c	2010-08-29 08:17:58.000000000 +0200
@@ -163,6 +163,9 @@  char *write_state_filename;
 int do_dump;
 int do_debug;
 
+/* For verbose messages. */
+int verbosity_level;
+
 static outf_p create_file (const char *, const char *);
 
 static const char * get_file_basename (const char *);
@@ -1841,6 +1844,7 @@  static void
 close_output_files (void)
 {
   outf_p of;
+  int nbwrittenfiles = 0;
 
   for (of = output_files; of; of = of->next)
     {
@@ -1854,11 +1858,22 @@  close_output_files (void)
           fatal ("writing output file %s: %s", of->name, xstrerror (errno));
         if (fclose (newfile) != 0)
           fatal ("closing output file %s: %s", of->name, xstrerror (errno));
+	nbwrittenfiles++;
+	if (verbosity_level >= 1)
+	  printf ("gengtype write #%-3d %s\n", nbwrittenfiles, of->name);
+      }
+      else { 
+	/* output file remains unchanged. */
+	if (verbosity_level >= 2)
+	  printf ("gengtype keep %s\n", of->name);
       }
       free(of->buf);
       of->buf = NULL;
       of->bufused = of->buflength = 0;
-    }
+    };
+  
+  if (verbosity_level >= 1)
+    printf ("gengtype wrote %d files.\n", nbwrittenfiles);
 }
 
 struct flist {
@@ -4215,6 +4230,7 @@  static const struct option gengtype_long
 {
     { "help",      no_argument, NULL, 'h' },
     { "version",   no_argument, NULL, 'V' },
+    { "verbose",   no_argument, NULL, 'v' },
     { "dump",      no_argument, NULL, 'd' },
     { "debug",     no_argument, NULL, 'D' },
     { "plugin",    required_argument, NULL, 'P' },
@@ -4231,6 +4247,7 @@  print_usage (void)
 {
     printf ("Usage: %s\n", progname);
     printf ("\t -h | --help  \t# Give this help.\n");
+    printf ("\t -v | --verbose  \t# Increase verbosity. Can be given several times.\n");
     printf ("\t -D | --debug  \t# Lots of debug output to debug gengtype itself.\n");
     printf ("\t -V | --version  \t# Give version information.\n");
     printf ("\t -d | --dump  \t# Dump state for debugging.\n");
@@ -4267,6 +4284,9 @@  parse_program_options (int argc, char**a
 	case 'd': /* --dump */
 	    do_dump = 1;
 	    break;
+	case 'v': /* --verbose */
+	    verbosity_level++;
+	    break;
 	case 'D': /* --debug */
 	    do_debug = 1;
 	    break;
--- ../gcc-gengtype-01/gengtype.h	2010-08-29 08:16:56.000000000 +0200
+++ gcc/gengtype.h	2010-08-29 08:17:58.000000000 +0200
@@ -145,6 +145,9 @@  enum {
 };
 
 
+/* Level for verbose messages, e.g. output file generation... */
+extern int verbosity_level;
+
 /* For debugging purposes of gengtype itself!  */
 extern int do_dump;
 extern int do_debug;