]> thyrsus.com Git - comparator.git/commitdiff
More C normalization.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 07:13:27 +0000 (07:13 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 07:13:27 +0000 (07:13 +0000)
main.c
scf-standard.xml
shred.h
shredtree.c

diff --git a/main.c b/main.c
index e1be40d202e75e7f2978c85187525e15671f7a8a..f5c0f3b622da0de797d2439132b90d643f6d17de 100644 (file)
--- a/main.c
+++ b/main.c
@@ -84,10 +84,10 @@ static void write_scf(const char *tree, FILE *ofp)
     fputs("Generator-Program: comparator 1.0\n", ofp);
     fputs("Hash-Method: MD5\n", ofp);
     buf[0] = '\0';
-    if (rws)
+    if (remove_whitespace)
        strcat(buf, "remove-whitespace,");
-    if (c_normalization)
-       strcat(buf, "c-normalization,");
+    if (remove_braces)
+       strcat(buf, "remove-braces,");
     if (buf[0])
        buf[strlen(buf)-1] = '\0';
     else
@@ -361,7 +361,7 @@ main(int argc, char *argv[])
            break;
 
        case 'C':
-           c_normalization = 1;
+           remove_braces = 1;
            break;
 
        case 'd':
@@ -377,7 +377,7 @@ main(int argc, char *argv[])
            break;
 
        case 'w':
-           rws = 1;
+           remove_whitespace = 1;
            break;
 
        case 'x':
@@ -475,8 +475,19 @@ main(int argc, char *argv[])
     /* if there were no SCFs, create a dummy one */
     if (scf_head == &dummy_scf)
     {
+       char    buf[BUFSIZ];
+
        dummy_scf.hash_method = "MD5";
-       dummy_scf.normalization = rws ? "remove_whitespace" : "none";
+       buf[0] == '\0';
+       if (remove_whitespace)
+           strcat(buf, "remove-whitespace,");
+       if (remove_braces)
+           strcat(buf, "remove-braces,");
+       if (buf[0])
+           buf[strlen(buf)-1] = '\0';
+       else
+           strcpy(buf, "none");
+       dummy_scf.normalization = strdup(buf);
        dummy_scf.shred_size = shredsize;
        dummy_scf.generator_program = "comparator 1.0";
     }
index e46df9b82aa0d5b85d8741e55a7ede3e6280ba7b..402fc6e867c8dc6596f8efd11f15f735ec3cf23b 100644 (file)
   </affiliation>
 </author>
 
-<revhistory>
+<revhistory> 
    <revision>
+      <revnumber>1.1</revnumber>
+      <date>2003-10-07</date>
+      <authorinitials>esr</authorinitials>
+       <revremark>
+        Added remove-braces.
+       </revremark>
+   </revision>
+  <revision>
       <revnumber>1.0</revnumber>
       <date>2003-09-07</date>
       <authorinitials>esr</authorinitials>
@@ -200,11 +208,11 @@ may include the following:</para>
 (spaces, tabs, and linefeeds) has been stripped out.</para>
 </listitem>
 
-<!--
 <listitem>
 <para><emphasis>remove-braces</emphasis>: Remove { and }.</para>
 </listitem>
 
+<!--
 <listitem>
 <para><emphasis>remove-C-comments</emphasis>: Remove /* and */</para>
 </listitem>
diff --git a/shred.h b/shred.h
index dd811b9b614243c34a7ebc6cdba5a0b7361d31b3..548d5caae553ffa03a6d1bfb0d0d0cb858c824ea 100644 (file)
--- a/shred.h
+++ b/shred.h
@@ -31,8 +31,8 @@ struct sorthash_t
 };
 
 /* control bits, meant to be set at startup */
-extern int c_normalization;
-extern int rws;
+extern int remove_braces;
+extern int remove_whitespace;
 extern int debug;
 extern int shredsize;
 
index 871df66da074c2e595109222e2e7f0a5fefe2dd0..2842de50a2dc51a615b174e7c24a5963654f9b65 100644 (file)
@@ -11,8 +11,8 @@
 #include "shred.h"
 
 /* control bits, meant to be set at startup */
-int c_normalization = 0;
-int rws = 0;
+int remove_braces = 0;
+int remove_whitespace = 0;
 int shredsize = 3;
 
 struct item
@@ -68,7 +68,7 @@ static int eligible(const char *file)
 static int normalize(char *buf)
 /* normalize a buffer in place, return 0 if it should be skipped */
 {
-    if (rws)           /* strip whitespace, ignore blank lines */
+    if (remove_whitespace)     /* strip whitespace, ignore blank lines */
     {
        char *tp, *sp;
 
@@ -77,7 +77,7 @@ static int normalize(char *buf)
                *tp++ = *sp;
        *tp = '\0';
     }
-    if (c_normalization)       /* strip whitespace, ignore blank lines */
+    if (remove_braces)         /* strip C statement brackets */
     {
        char *tp, *sp;