[PATCH] Label verbosity levels.

max at mtew.isa-geek.net max at mtew.isa-geek.net
Fri Mar 18 22:24:53 CDT 2011


From: Max TenEyck Woodbury <max at mtew.isa-geek.net>

Th meaning of the various 'verbosity' levels is confusing.  This is
a first try and explaining their meaning. Again, this is _not_ a
functional change; just an attempt to make the code more understandable.

If someone else wants to change the labels and reassign the levels for
some items, they are more than welcome to do so. That should be easier
after this change. I'm just trying to figure out what is going on...
---
 tools/c2man.pl |  152 ++++++++++++++++++++++++--------------------------------
 1 files changed, 65 insertions(+), 87 deletions(-)

diff --git a/tools/c2man.pl b/tools/c2man.pl
index 3540911..60bd66c 100755
--- a/tools/c2man.pl
+++ b/tools/c2man.pl
@@ -45,6 +45,16 @@ my $EXPORT_EXPNAME  = 2;  # Export name.
 my $EXPORT_IMPNAME  = 3;  # Implementation name.
 my $EXPORT_FLAGS    = 4;  # Flags - see above.
 
+# Verbosity levels
+my $VERBOSE_QUIET   = 0;  # Quiet
+my $VERBOSE_INPUT   = 1;  # Trace input
+my $VERBOSE_ERROR   = 2;  # Errors
+my $VERBOSE_REPORT  = 3;  # Reports 
+my $VERBOSE_DETAILS = 4;  # Details
+my $VERBOSE_OUTPUT  = 5;  # Output
+my @VERBOSE_LEVELS = ('Quiet', 'Input Trace', 'Errors', 'Reports', 'Details',
+    'Output');
+
 # Options
 my $opt_output_directory = "man3w"; # All default options are for nroff (man pages)
 my $opt_manual_section = "3w";
@@ -53,7 +63,7 @@ my $opt_wine_root_dir = "";
 my $opt_output_format = "";         # '' = nroff, 'h' = html, 's' = sgml, 'x' = xml
 my $opt_output_empty = 0;           # Non-zero = Create 'empty' comments (for every implemented function)
 my $opt_fussy = 1;                  # Non-zero = Create only if we have a RETURNS section
-my $opt_verbose = 0;                # >0 = verbosity. Can be given multiple times (for debugging)
+my $opt_verbose = $VERBOSE_QUIET;   # >0 = verbosity. Can be given multiple times (for debugging)
 my @opt_header_file_list = ();
 my @opt_spec_file_list = ();
 my @opt_source_file_list = ();
@@ -123,10 +133,8 @@ sub process_spec_file($)
     CURRENT_EXTRA => [ ] ,
   };
 
-  if ($opt_verbose > 0)
-  {
-    print "Processing ".$spec_name."\n";
-  }
+  print "Processing ".$spec_name."\n"
+    if $opt_verbose >= $VERBOSE_INPUT;
 
   # We allow opening to fail just to cater for the peculiarities of
   # the Wine build system. This doesn't hurt, in any case
@@ -174,10 +182,9 @@ sub process_spec_file($)
         /^(extern)$/
                  && do { $spec_details->{NUM_FORWARDS}++; last; };
         /^stub$/ && do { $spec_details->{NUM_STUBS}++;    last; };
-        if ($opt_verbose > 0)
-        {
-          print "Warning: didn't recognise convention \'",$call_convention,"'\n";
-        }
+
+        print "Warning: didn't recognise convention \'",$call_convention,"'\n"
+          if $opt_verbose >= $VERBOSE_INPUT;
         last;
       }
 
@@ -246,10 +253,9 @@ sub process_source_file($)
   my $ignore_blank_lines = 1;
   my $extra_comment = 0; # 1 if this is an extra comment, i.e its not a .spec export
 
-  if ($opt_verbose > 0)
-  {
-    print "Processing ".$source_file."\n";
-  }
+  print "Processing ".$source_file."\n"
+    if $opt_verbose >= $VERBOSE_INPUT;
+
   open(SOURCE_FILE,"<$source_file")
   || (($opt_source_dir ne "")
       && open(SOURCE_FILE,"<$opt_source_dir/$source_file"))
@@ -279,20 +285,17 @@ sub process_source_file($)
       $contributor =~ s/ (for .*)/ \($1\)/;
       if ($contributor ne "")
       {
-        if ($opt_verbose > 3)
-        {
-          print "Info: Found contributor:'".$contributor."'\n";
-        }
+        print "Info: Found contributor:'".$contributor."'\n"
+          if $opt_verbose >= $VERBOSE_DETAILS;
+
         push (@{$source_details->{CONTRIBUTORS}},$contributor);
       }
     }
     elsif ( /WINE_DEFAULT_DEBUG_CHANNEL\(([A-Za-z]*)\)/ )
     {
       # Extract the debug channel to use
-      if ($opt_verbose > 3)
-      {
-        print "Info: Found debug channel:'".$1."'\n";
-      }
+      print "Info: Found debug channel:'".$1."'\n"
+        if $opt_verbose >= $VERBOSE_DETAILS;
       $source_details->{DEBUG_CHANNEL} = $1;
     }
 
@@ -377,10 +380,9 @@ sub process_source_file($)
         elsif (!/^\#/ && !/^ *$/ && !/^__ASM_GLOBAL_FUNC/)
         {
           # This isn't a well formatted comment: look for the next one
-          if ($opt_verbose > 1)
-          {
-            print "Info: Function '",$comment->{COMMENT_NAME},"' not followed by prototype.\n";
-          }
+          print "Info: Function '",$comment->{COMMENT_NAME},
+              "' not followed by prototype.\n"
+            if $opt_verbose >= $VERBOSE_ERROR;
           $parse_state = 0;
         }
       }
@@ -457,9 +459,10 @@ sub process_source_file($)
           process_comment($comment);
         }
       }
-      elsif ($opt_verbose > 1 && $opt_output_empty == 0)
+      elsif ($opt_verbose >= $VERBOSE_ERROR && $opt_output_empty == 0)
       {
-        print "Info: Function '",$comment->{COMMENT_NAME},"' has no documentation.\n";
+        print "Info: Function '",$comment->{COMMENT_NAME},
+            "' has no documentation.\n";
       }
       $parse_state = 0;
     }
@@ -586,11 +589,9 @@ sub process_comment($)
 
   if (!defined($spec_details))
   {
-    if ($opt_verbose > 2)
-    {
-      print "Warning: Function '".$comment->{COMMENT_NAME}."' belongs to '".
-            $comment->{DLL_NAME}."' (not passed with -w): not processing it.\n";
-    }
+    print "Warning: Function '".$comment->{COMMENT_NAME}."' belongs to '".
+        $comment->{DLL_NAME}."' (not passed with -w): not processing it.\n"
+      if $opt_verbose >= $VERBOSE_REPORT;
     return;
   }
 
@@ -627,11 +628,9 @@ sub process_comment($)
   if (!defined($export_index))
   {
     # This function doesn't appear to be exported. hmm.
-    if ($opt_verbose > 2)
-    {
-      print "Warning: Function '".$comment->{COMMENT_NAME}."' claims to belong to '".
-            $comment->{DLL_NAME}."' but is not exported by it: not processing it.\n";
-    }
+    print "Warning: Function '".$comment->{COMMENT_NAME}."' claims to belong to '".
+        $comment->{DLL_NAME}."' but is not exported by it: not processing it.\n"
+      if $opt_verbose >= $VERBOSE_REPORT;
     return;
   }
 
@@ -645,10 +644,8 @@ sub process_comment($)
     my $alt_index = $exported_names->{$1};
     if (defined($alt_index))
     {
-      if ($opt_verbose > 2)
-      {
-        print "Info: Found alternate name '",$1,"\n";
-      }
+      print "Info: Found alternate name '",$1,"\n"
+        if $opt_verbose >= $VERBOSE_REPORT;
       my $alt_export = @{$spec_details->{EXPORTS}}[$alt_index];
       @$alt_export[$EXPORT_FLAGS] |= $FLAG_DOCUMENTED;
       $spec_details->{NUM_DOCS}++;
@@ -663,10 +660,8 @@ sub process_comment($)
     my $current_name = $current_comment->{COMMENT_NAME};
     if ($comment->{COMMENT_NAME} =~ /^$current_name/ && $comment->{COMMENT_NAME} ne $current_name)
     {
-      if ($opt_verbose > 2)
-      {
-        print "Linking ",$comment->{COMMENT_NAME}," to $current_name\n";
-      }
+      print "Linking ",$comment->{COMMENT_NAME}," to $current_name\n"
+        if $opt_verbose >= $VERBOSE_REPORT;
       # Add a reference to this comment to our extra comment
       push (@{$current_comment->{TEXT}}, $comment->{COMMENT_NAME}."()","");
     }
@@ -772,10 +767,8 @@ sub process_comment($)
               }
               if (!defined($ascii_export_index))
               {
-                if ($opt_verbose > 2)
-                {
-                  print "Warning: Function '".$comment->{COMMENT_NAME}."' is not an A/W pair.\n";
-                }
+                print "Warning: Function '".$comment->{COMMENT_NAME}."' is not an A/W pair.\n"
+                  if $opt_verbose >= $VERBOSE_REPORT;
               }
               else
               {
@@ -810,11 +803,9 @@ sub process_comment($)
     }
     if ($found_returns == 0 || $found_description_text == 0)
     {
-      if ($opt_verbose > 2)
-      {
-        print "Info: Function '",$comment->{COMMENT_NAME},"' has no ",
-              "description and/or RETURNS section, skipping\n";
-      }
+      print "Info: Function '",$comment->{COMMENT_NAME},"' has no ",
+              "description and/or RETURNS section, skipping\n"
+        if $opt_verbose >= $VERBOSE_REPORT;
       $spec_details->{NUM_DOCS}--;
       @$export[$EXPORT_FLAGS] &= ~$FLAG_DOCUMENTED;
       return;
@@ -947,21 +938,17 @@ sub process_extra_comment($)
 
   if (!defined($spec_details))
   {
-    if ($opt_verbose > 2)
-    {
-      print "Warning: Extra comment '".$comment->{COMMENT_NAME}."' belongs to '".
-            $comment->{DLL_NAME}."' (not passed with -w): not processing it.\n";
-    }
+    print "Warning: Extra comment '".$comment->{COMMENT_NAME}."' belongs to '".
+            $comment->{DLL_NAME}."' (not passed with -w): not processing it.\n"
+      if $opt_verbose >= $VERBOSE_REPORT;
     return;
   }
 
   # Check first to see if this is documentation for the DLL.
   if ($comment->{COMMENT_NAME} eq $comment->{DLL_NAME})
   {
-    if ($opt_verbose > 2)
-    {
-      print "Info: Found DLL documentation\n";
-    }
+    print "Info: Found DLL documentation\n"
+      if $opt_verbose >= $VERBOSE_REPORT;
     for (@{$comment->{TEXT}})
     {
       push (@{$spec_details->{DESCRIPTION}}, $_);
@@ -991,19 +978,15 @@ sub process_extra_comment($)
     return;
   }
 
-  if ($opt_verbose > 0)
-  {
-    print "Processing ",$comment->{COMMENT_NAME},"\n";
-  }
+  print "Processing ",$comment->{COMMENT_NAME},"\n"
+    if $opt_verbose >= $VERBOSE_INPUT;
 
   if (@{$spec_details->{CURRENT_EXTRA}})
   {
     my $current_comment = ${$spec_details->{CURRENT_EXTRA}}[0];
 
-    if ($opt_verbose > 0)
-    {
-      print "Processing old current: ",$current_comment->{COMMENT_NAME},"\n";
-    }
+    print "Processing old current: ",$current_comment->{COMMENT_NAME},"\n"
+      if $opt_verbose >= $VERBOSE_INPUT;
     # Output the current comment
     process_comment_text($current_comment);
     output_open_api_file($current_comment->{COMMENT_NAME});
@@ -1014,10 +997,8 @@ sub process_extra_comment($)
     output_close_api_file();
   }
 
-  if ($opt_verbose > 2)
-  {
-    print "Setting current to ",$comment->{COMMENT_NAME},"\n";
-  }
+  print "Setting current to ",$comment->{COMMENT_NAME},"\n"
+    if $opt_verbose >= $VERBOSE_REPORT;
 
   my $comment_copy =
   {
@@ -1044,12 +1025,10 @@ sub output_comment($)
 {
   my $comment = shift;
 
-  if ($opt_verbose > 0)
-  {
-    print "Processing ",$comment->{COMMENT_NAME},"\n";
-  }
+  print "Processing ",$comment->{COMMENT_NAME},"\n"
+    if $opt_verbose >= $VERBOSE_INPUT;
 
-  if ($opt_verbose > 4)
+  if ($opt_verbose >= $VERBOSE_OUTPUT)
   {
     print "--PROTO--\n";
     for (@{$comment->{PROTOTYPE}})
@@ -1098,10 +1077,8 @@ sub output_spec($)
 {
   my $spec_details = shift;
 
-  if ($opt_verbose > 2)
-  {
-    print "Writing:",$spec_details->{DLL_NAME},"\n";
-  }
+  print "Writing:",$spec_details->{DLL_NAME},"\n"
+    if $opt_verbose >= $VERBOSE_REPORT;
 
   # Use the comment output functions for consistency
   my $comment =
@@ -1160,7 +1137,7 @@ sub output_spec($)
   undef %saw;
   @contributors = grep(!$saw{$_}++, @contributors);
 
-  if ($opt_verbose > 3)
+  if ($opt_verbose >= $VERBOSE_DETAILS)
   {
     print "Contributors:\n";
     for (@contributors)
@@ -2313,8 +2290,9 @@ while(defined($_ = shift @ARGV))
 my %htmp;
 @opt_header_file_list = grep(!$htmp{$_}++, @opt_header_file_list);
 
-if ($opt_verbose > 3)
+if ($opt_verbose >= $VERBOSE_DETAILS)
 {
+  print "Verbosity :'".$VERBOSE_LEVELS[$opt_verbose]."' (".$opt_verbose.")\n";
   print "Output dir:'".$opt_output_directory."'\n";
   print "Section   :'".$opt_manual_section."'\n";
   print "Format    :'".$opt_output_format."'\n";
@@ -2342,7 +2320,7 @@ while(my $spec_file = shift @opt_spec_file_list)
   process_spec_file($spec_file);
 }
 
-if ($opt_verbose > 3)
+if ($opt_verbose >= $VERBOSE_DETAILS)
 {
     foreach my $spec_file ( keys %spec_files )
     {
-- 
1.7.4




More information about the wine-patches mailing list