]> thyrsus.com Git - comparator.git/commitdiff
A step towards passing the regression.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 14 Sep 2003 15:11:09 +0000 (15:11 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 14 Sep 2003 15:11:09 +0000 (15:11 +0000)
main.c

diff --git a/main.c b/main.c
index 6cb1fd46b2f4a51e5baa771e7d3777b29e40a658..b3a34269d3b0de6df8585ed0a4ab98d392031670 100644 (file)
--- a/main.c
+++ b/main.c
@@ -94,6 +94,22 @@ void extend_current_chunk(void)
        sort_buffer[sort_count-1].hash.end++;
 }
 
+static void write_options(char *buf)
+/* dump a Nirmalization line representing current options */
+{
+    buf[0] = '\0';
+    if (remove_whitespace)
+       strcat(buf, "remove-whitespace, ");
+    if (remove_comments)
+       strcat(buf, "remove-comments, ");
+    if (remove_braces)
+       strcat(buf, "remove-braces, ");
+    if (buf[0])
+       buf[strlen(buf)-2] = '\0';
+    else
+       strcpy(buf, "none");
+}
+
 static void write_scf(const char *tree, FILE *ofp)
 /* generate shred file for given tree */
 {
@@ -107,17 +123,7 @@ static void write_scf(const char *tree, FILE *ofp)
     fputs("#SCF-A 1.1\n", ofp);
     fputs("Generator-Program: comparator 1.0\n", ofp);
     fputs("Hash-Method: MD5\n", ofp);
-    buf[0] = '\0';
-    if (remove_whitespace)
-       strcat(buf, "remove-whitespace,");
-    if (remove_comments)
-       strcat(buf, "remove-comments,");
-    if (remove_braces)
-       strcat(buf, "remove-braces,");
-    if (buf[0])
-       buf[strlen(buf)-1] = '\0';
-    else
-       strcpy(buf, "none");
+    write_options(buf);
     fprintf(ofp, "Normalization: %s\n", buf);
     fprintf(ofp, "Shred-Size: %d\n", shredsize);
     fputs("%%\n", ofp);
@@ -319,17 +325,7 @@ static void init_scf(char *file, struct scf_t *scf, const int readfile)
        char    buf[BUFSIZ];
 
        scf->hash_method = "MD5";
-       buf[0] = '\0';
-       if (remove_whitespace)
-           strcat(buf, "remove-whitespace, ");
-       if (remove_comments)
-           strcat(buf, "remove-comments, ");
-       if (remove_braces)
-           strcat(buf, "remove-braces, ");
-       if (buf[0])
-           buf[strlen(buf)-1] = '\0';
-       else
-           strcpy(buf, "none");
+       write_options(buf);
        scf->normalization = strdup(buf);
        scf->shred_size = shredsize;
        scf->generator_program = "comparator " VERSION;