summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2019-03-07 16:29:02 +0100
committerDirk Engling <erdgeist@erdgeist.org>2019-03-07 16:29:02 +0100
commit39ad0db84adecfeb8ec2e2c7628b9d55a3fe0894 (patch)
tree3c1b19d3b85ccda5c17242f054fd8e3ea092cfc6
parent072d7dc38ebf8ac7e9b35afec8692a71dd7cdfbe (diff)
Build all postprocess tools with make
-rw-r--r--Makefile14
-rw-r--r--src/postprocess/merge_entries.c20
-rw-r--r--src/postprocess/sort_plz.c2
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 @@
1BINARIES=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 1BINARIES=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
2CFLAGS += -W -Wall -Wextra -O3 # -Weverything -Wno-cast-align -Wno-padded 2CFLAGS += -W -Wall -Wextra -O3 -I src/export # -Weverything -Wno-cast-align -Wno-padded
3 3
4all: $(BINARIES) 4all: $(BINARIES)
5 5
@@ -33,8 +33,14 @@ bin/map_branches_v3: src/export/map_branches_v3.c
33bin/convert_coords: src/export/convert_coords.c 33bin/convert_coords: src/export/convert_coords.c
34 $(CC) $(CFLAGS) -o $@ src/export/convert_coords.c -lm 34 $(CC) $(CFLAGS) -o $@ src/export/convert_coords.c -lm
35 35
36bin/join: src/postprocess/join.c src/export/mystdlib.c 36#bin/join: src/postprocess/join.c src/export/mystdlib.c
37 $(CC) $(CFLAGS) -o $@ src/postprocess/join.c src/export/mystdlib.c -Isrc/export 37# $(CC) $(CFLAGS) -o $@ src/postprocess/join.c src/export/mystdlib.c -Isrc/export
38
39bin/merge_entries: src/postprocess/merge_entries.c src/export/mystdlib.c src/postprocess/halfsiphash.c
40 $(CC) $(CFLAGS) -o $@ src/postprocess/merge_entries.c src/export/mystdlib.c src/postprocess/halfsiphash.c
41
42bin/sort_plz: src/postprocess/sort_plz.c
43 $(CC) $(CFLAGS) -o $@ src/postprocess/sort_plz.c
38 44
39.PHONY: clean 45.PHONY: clean
40clean: 46clean:
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) {
193} 193}
194 194
195int main(int argc, char **args) { 195int main(int argc, char **args) {
196 MAP tbuch = map_file(args[1], 1); 196 MAP tbuch;
197 char *ptr; 197 char *ptr;
198 entry_t * sort_array; 198 entry_t * sort_array;
199 int current = -1, outoff = 0, lines = COLUMNS, i; 199 int outoff = 0, lines = COLUMNS;
200 unsigned long current = 0, i, flag;
200 uint64_t year_list = 0, revflag_list = 0, bizflag_list = 0; 201 uint64_t year_list = 0, revflag_list = 0, bizflag_list = 0;
201 long flag = 0; 202
203 if (argc != 1) exit(1);
204 tbuch = map_file(args[1], 1);
202 205
203 /* Estimate upper bound for amount of lines */ 206 /* Estimate upper bound for amount of lines */
204 for (i=0; i<tbuch->size; ++i) 207 for (i=0; i<tbuch->size; ++i)
@@ -232,13 +235,14 @@ int main(int argc, char **args) {
232 } 235 }
233 236
234 if (flag&2) { 237 if (flag&2) {
235 assert( current >= 0); 238 assert(current>0);
236 sort_array[current].rows++; 239 sort_array[current-1].rows++;
237 } else { 240 } else {
238 sort_array[++current].rows = 0; 241 sort_array[current].rows = 0;
239 sort_array[current].outoff = outoff; 242 sort_array[current].outoff = outoff;
240 sort_array[current].flag = flag; 243 sort_array[current].flag = flag;
241 sort_array[current].year = year; 244 sort_array[current].year = year;
245 current++;
242 } 246 }
243 outoff += COLUMNS; 247 outoff += COLUMNS;
244 } 248 }
@@ -246,12 +250,12 @@ int main(int argc, char **args) {
246 /* Sort the whole thing */ 250 /* Sort the whole thing */
247 qsort(sort_array, current, sizeof(entry_t), sort_me); 251 qsort(sort_array, current, sizeof(entry_t), sort_me);
248 252
249 for (i=0; i<=current; ++i) { 253 for (i=0; i<current; ++i) {
250 year_list |= 1LL << sort_array[i].year; 254 year_list |= 1LL << sort_array[i].year;
251 if (sort_array[i].flag & 0x80 ) bizflag_list |= 1LL << sort_array[i].year; 255 if (sort_array[i].flag & 0x80 ) bizflag_list |= 1LL << sort_array[i].year;
252 if (sort_array[i].flag & 0x40 ) revflag_list |= 1LL << sort_array[i].year; 256 if (sort_array[i].flag & 0x40 ) revflag_list |= 1LL << sort_array[i].year;
253 257
254 if ((i == current) || compare_entries(sort_array+i, sort_array+i+1)) { 258 if ((i == current - 1) || compare_entries(sort_array+i, sort_array+i+1)) {
255 printf("%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t", year_list, bizflag_list, revflag_list); 259 printf("%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t", year_list, bizflag_list, revflag_list);
256 for (int c=2; c<COLUMNS; ++c) { 260 for (int c=2; c<COLUMNS; ++c) {
257 int j, started = 0, skipped = 0; 261 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) {
84 char *input = malloc(1024); 84 char *input = malloc(1024);
85 size_t input_size = 1024; 85 size_t input_size = 1024;
86 86
87 if (argc != 1) exit(1);
88
87 /* First open all input files */ 89 /* First open all input files */
88 for (i=F_01; i<F_COUNT; ++i) { 90 for (i=F_01; i<F_COUNT; ++i) {
89 in_handles[i] = fopen_prefix(args[1], i, 1); 91 in_handles[i] = fopen_prefix(args[1], i, 1);