From 39ad0db84adecfeb8ec2e2c7628b9d55a3fe0894 Mon Sep 17 00:00:00 2001 From: Dirk Engling <erdgeist@erdgeist.org> Date: Thu, 7 Mar 2019 16:29:02 +0100 Subject: Build all postprocess tools with make --- Makefile | 14 ++++++++++---- src/postprocess/merge_entries.c | 20 ++++++++++++-------- src/postprocess/sort_plz.c | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 691675e..836af77 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -BINARIES=bin/extract_version_1 bin/extract_version_2 bin/extract_version_3 bin/extract_version_4 bin/split_version_2 bin/split_version_3 bin/map_coords bin/map_branches_v3 bin/map_branches_v4 bin/convert_coords bin/join -CFLAGS += -W -Wall -Wextra -O3 # -Weverything -Wno-cast-align -Wno-padded +BINARIES=bin/extract_version_1 bin/extract_version_2 bin/extract_version_3 bin/extract_version_4 bin/split_version_2 bin/split_version_3 bin/map_coords bin/map_branches_v3 bin/map_branches_v4 bin/convert_coords bin/merge_entries bin/sort_plz # bin/join +CFLAGS += -W -Wall -Wextra -O3 -I src/export # -Weverything -Wno-cast-align -Wno-padded all: $(BINARIES) @@ -33,8 +33,14 @@ bin/map_branches_v3: src/export/map_branches_v3.c bin/convert_coords: src/export/convert_coords.c $(CC) $(CFLAGS) -o $@ src/export/convert_coords.c -lm -bin/join: src/postprocess/join.c src/export/mystdlib.c - $(CC) $(CFLAGS) -o $@ src/postprocess/join.c src/export/mystdlib.c -Isrc/export +#bin/join: src/postprocess/join.c src/export/mystdlib.c +# $(CC) $(CFLAGS) -o $@ src/postprocess/join.c src/export/mystdlib.c -Isrc/export + +bin/merge_entries: src/postprocess/merge_entries.c src/export/mystdlib.c src/postprocess/halfsiphash.c + $(CC) $(CFLAGS) -o $@ src/postprocess/merge_entries.c src/export/mystdlib.c src/postprocess/halfsiphash.c + +bin/sort_plz: src/postprocess/sort_plz.c + $(CC) $(CFLAGS) -o $@ src/postprocess/sort_plz.c .PHONY: clean clean: diff --git a/src/postprocess/merge_entries.c b/src/postprocess/merge_entries.c index f89113e..f9ee67d 100644 --- a/src/postprocess/merge_entries.c +++ b/src/postprocess/merge_entries.c @@ -193,12 +193,15 @@ static void escape_string(char * s, size_t len) { } int main(int argc, char **args) { - MAP tbuch = map_file(args[1], 1); + MAP tbuch; char *ptr; entry_t * sort_array; - int current = -1, outoff = 0, lines = COLUMNS, i; + int outoff = 0, lines = COLUMNS; + unsigned long current = 0, i, flag; uint64_t year_list = 0, revflag_list = 0, bizflag_list = 0; - long flag = 0; + + if (argc != 1) exit(1); + tbuch = map_file(args[1], 1); /* Estimate upper bound for amount of lines */ for (i=0; i<tbuch->size; ++i) @@ -232,13 +235,14 @@ int main(int argc, char **args) { } if (flag&2) { - assert( current >= 0); - sort_array[current].rows++; + assert(current>0); + sort_array[current-1].rows++; } else { - sort_array[++current].rows = 0; + sort_array[current].rows = 0; sort_array[current].outoff = outoff; sort_array[current].flag = flag; sort_array[current].year = year; + current++; } outoff += COLUMNS; } @@ -246,12 +250,12 @@ int main(int argc, char **args) { /* Sort the whole thing */ qsort(sort_array, current, sizeof(entry_t), sort_me); - for (i=0; i<=current; ++i) { + for (i=0; i<current; ++i) { year_list |= 1LL << sort_array[i].year; if (sort_array[i].flag & 0x80 ) bizflag_list |= 1LL << sort_array[i].year; if (sort_array[i].flag & 0x40 ) revflag_list |= 1LL << sort_array[i].year; - if ((i == current) || compare_entries(sort_array+i, sort_array+i+1)) { + if ((i == current - 1) || compare_entries(sort_array+i, sort_array+i+1)) { printf("%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t", year_list, bizflag_list, revflag_list); for (int c=2; c<COLUMNS; ++c) { int j, started = 0, skipped = 0; diff --git a/src/postprocess/sort_plz.c b/src/postprocess/sort_plz.c index 4c30ea3..dc0b222 100644 --- a/src/postprocess/sort_plz.c +++ b/src/postprocess/sort_plz.c @@ -84,6 +84,8 @@ int main(int argc, char **args) { char *input = malloc(1024); size_t input_size = 1024; + if (argc != 1) exit(1); + /* First open all input files */ for (i=F_01; i<F_COUNT; ++i) { in_handles[i] = fopen_prefix(args[1], i, 1); -- cgit v1.2.3