summaryrefslogtreecommitdiff
path: root/src/postprocess/merge_entries.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/postprocess/merge_entries.c')
-rw-r--r--src/postprocess/merge_entries.c20
1 files changed, 12 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
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;