diff options
-rw-r--r-- | makefile | 1 | ||||
-rw-r--r-- | options.ggo | 1 | ||||
-rw-r--r-- | src/log.c | 4 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/tree.c | 3 |
5 files changed, 12 insertions, 3 deletions
@@ -33,6 +33,7 @@ compile: $(BUILD) $(OBJS) $(BUILD)/bloc clean: @rm -rf $(BUILD)/* + @rm -f $(SRC)/cmdline.* install: @install -m 755 $(BUILD)/bloc $(DESTDIR)$(PREFIX)/bin/ diff --git a/options.ggo b/options.ggo index 4e275c7..7c11c19 100644 --- a/options.ggo +++ b/options.ggo @@ -8,4 +8,5 @@ option "verbose" v "enable debug logging output" flag off option "from-blc" b "convert from BLC to BLoC" flag off option "from-bloc" B "convert from BLoC to BLC" flag off option "dump" d "dump bloc file" dependon="from-bloc" flag off +option "min-size" m "minimum term size for deduplication" default="10" long optional option "test" t "compare BLC with generated BLoC" dependon="from-blc" flag off @@ -14,7 +14,7 @@ void debug(const char *format, ...) if (!debug_enabled) return; - fprintf(stderr, "[DEBUG] "); + fprintf(stderr, "[DEBUG] BLoC: "); va_list ap; va_start(ap, format); @@ -29,7 +29,7 @@ void debug_enable(int enable) void fatal(const char *format, ...) { - fprintf(stderr, "[FATAL] "); + fprintf(stderr, "[FATAL] BLoC: "); va_list ap; va_start(ap, format); @@ -17,6 +17,9 @@ // automatically generated using gengetopt #include "cmdline.h" +// min size for a term to be considered for deduplication +size_t min_size = 0; + #define BUF_SIZE 1024 static char *read_stdin(void) { @@ -179,6 +182,9 @@ int main(int argc, char **argv) if (!input) return 1; + min_size = args.min_size_arg; + debug("min tree size: %lu\n", min_size); + if (args.test_flag && args.from_blc_flag && !args.from_bloc_flag) { test(input); return 0; @@ -55,6 +55,7 @@ static int hash_compare(const void *_a, const void *_b) // applies the hash function to the tree's elements (similar to merkle trees) // also creates a set of lists with deduplication candidates // TODO: as above: rethink hash choice +extern size_t min_size; static struct tree *build_tree(struct term *term, void **set) { struct tree *tree = malloc(sizeof(*tree)); @@ -90,7 +91,7 @@ static struct tree *build_tree(struct term *term, void **set) fatal("invalid type %d\n", term->type); } - if (tree->size < 10) // not suitable for deduplication + if (tree->size < min_size) // not suitable for deduplication return tree; struct hash_to_list *element = malloc(sizeof(*element)); |