diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2019-03-07 16:29:02 +0100 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2019-03-07 16:29:02 +0100 |
commit | 39ad0db84adecfeb8ec2e2c7628b9d55a3fe0894 (patch) | |
tree | 3c1b19d3b85ccda5c17242f054fd8e3ea092cfc6 /src | |
parent | 072d7dc38ebf8ac7e9b35afec8692a71dd7cdfbe (diff) |
Build all postprocess tools with make
Diffstat (limited to 'src')
-rw-r--r-- | src/postprocess/merge_entries.c | 20 | ||||
-rw-r--r-- | src/postprocess/sort_plz.c | 2 |
2 files changed, 14 insertions, 8 deletions
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 | ||
195 | int main(int argc, char **args) { | 195 | int 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); |