From a13e18bb9f564767652f73f2daa94a31f4aa124d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 12 Sep 2003 08:49:49 +0000 Subject: [PATCH] init_scf now sets defaults. --- main.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/main.c b/main.c index 7c1fc41..0f5aece 100644 --- a/main.c +++ b/main.c @@ -245,6 +245,8 @@ static int merge_tree(char *tree) static void init_scf(char *file, struct scf_t *scf) /* add to the in-core list of sorthash structures from a SCF file */ { + if (file) + { char buf[BUFSIZ]; /* read in the SCF metadata block and add it to the in-core list */ @@ -279,6 +281,27 @@ static void init_scf(char *file, struct scf_t *scf) else if (!strcmp(buf, "Generator-Program")) scf->generator_program = strdup(value); } + } + else + { + 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"); + scf->normalization = strdup(buf); + scf->shred_size = shredsize; + scf->generator_program = "comparator " VERSION; + } } static void dump_array(struct sorthash_t *obarray, @@ -497,25 +520,7 @@ main(int argc, char *argv[]) /* if there were no SCFs, create a dummy one */ if (scflist == &dummy_scf) - { - char buf[BUFSIZ]; - - scflist->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"); - scflist->normalization = strdup(buf); - scflist->shred_size = shredsize; - scflist->generator_program = "comparator " VERSION; - } + init_scf(NULL, &dummy_scf); else { /* consistency checks on the SCFs */ -- 2.43.0