]> thyrsus.com Git - comparator.git/commitdiff
We can now ignore shell comments.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 17:22:16 +0000 (17:22 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 17:22:16 +0000 (17:22 +0000)
comparator.xml
shredtree.c

index 054a26c1ce9f52a06b49905f72cf885be738cb40..8eb58e9689d7c7790cb7053ebc0f6856997fe153 100644 (file)
@@ -29,6 +29,8 @@
   <command>filterator</command>
   <arg choice='opt'>-d <replaceable>dir</replaceable></arg>
   <arg choice='opt'>-n</arg>
+  <arg choice='opt'>-s <replaceable>minsize</replaceable></arg>
+  <arg choice='opt'>-x</arg>
 </cmdsynopsis>
 
 </refsynopsisdiv>
@@ -101,10 +103,11 @@ removed.  This is recommended for comparing C code; it prevents the
 comparison from being fooled by differences in indent style.</para>
 
 <para>The <option>-r</option> option removes comments.  This is only
-effective in conjunction with <option>-C</option>. All // comments,
+effective in conjunction with <option>-C</option>. In C files, ll // comments,
 but only "winged" /* comments with the start and end of comment on the
-same line are ignored.  Block /* comments are retained, but the
-beginning /* and ending */ are ignored, </para>
+same line are ignored; also, block /* comments are retained, but the
+beginning /* and ending */ are ignored, In other files, all #
+comments are removed.</para>
 
 <para>The <option>-x</option> enables some debugging output.  It
 is for developers; if you need to understand it, read the code.</para>
@@ -121,14 +124,18 @@ percentage of printable characters near the front of the file is above
 <para><application>filterator</application> is a postprocessor for the
 SCF-B output of <application>comparator</application> that produces an
 actual code listing.  By default, it throws away ranges that appear to
-be noise.  The noise test is to throw away whitespace, C syntax,
+be noise.  The noise test for C files is to throw away whitespace, C syntax,
 #include lines and a few common macros and see if anything is left.
-The <option>-n</option> suppresses noise filtering.  The
+The noise test for shell files throws away Bourne-shell keywords</para>
+
+<para>The <option>-n</option> suppresses noise filtering.  The
 <option>-d</option> acts as it does for
 <application>comparator</application>.  The <option>-s</option> option
 sets the minimum size of overlap to be reported; setting this to a
-slightly larger number than the <application>comparator</application> shred
-size may be a useful way to filter out spurious matches.</para>
+slightly larger number than the <application>comparator</application>
+shred size may be a useful way to filter out spurious matches. The
+<option>-x</option> enables some debugging output.  It is for
+developers; if you need to understand it, read the code.</para>
 
 <para>Occasionally the <application>filterator</application> output
 looks as through the code has failed to properly merge two or more
index 951d28aab821313303a974031c7f5b65e26ab5eb..b361eb7e05c82046add8b3a9e230922791850c0a 100644 (file)
@@ -70,24 +70,33 @@ static int eligible(const char *file)
 static int normalize(char *buf)
 /* normalize a buffer in place, return 0 if it should be skipped */
 {
-    if (remove_comments && remove_braces)      /* remove_c_comments */
-    {
-       char    *ss = strstr(buf, "//");
-
-       if (ss)
-           *ss = '\0';
+    if (remove_comments)
+       if (remove_braces)      /* remove C comments */
+       {
+           char        *ss = strstr(buf, "//");
+
+           if (ss)
+               *ss = '\0';
+           else
+           {
+               char *start = strstr(buf, "/*"), *end = strstr(buf, "*/");
+
+               if (start && end && start < end)
+                   strcpy(start, end+2);
+               else if (start && !end)
+                   *start = '\0';
+               else if (end && !start)
+                   *end = '\0';
+           }
+       }
        else
        {
-           char *start = strstr(buf, "/*"), *end = strstr(buf, "*/");
-
-           if (start && end && start < end)
-               strcpy(start, end+2);
-           else if (start && !end)
-               *start = '\0';
-           else if (end && !start)
-               *end = '\0';
+           char        *ss = strchr(buf, '#');
+
+           if (ss)
+               *ss = '\0';
        }
-    }
+
     if (remove_whitespace)     /* strip whitespace, ignore blank lines */
     {
        char *tp, *sp;