737,764d736 < < static void do_intermediate_merging _AP((database *db, boolean completely)); < < static void do_intermediate_merging(db, completely) < database *db; < boolean completely; < /* < * The highest index file in the db passed in has just been saved to < * disk. Merge all the merges that can take place, given how far < * we've gotten. If this is the last file (completely is true), < * finish the merging completely and generate the dictionary. < */ < { < int twotothe = 1, low, high, splitter; < int last = db->index_file_number - 1; < int temp; < char filename[MAX_FILENAME_LEN]; < char filename2[MAX_FILENAME_LEN]; < < printf("\n%ld\n", db->index_file_number); < < if (! completely) { < if (last % 2 == 0) { < return; < } < else { < splitter = last + 1; < } 766,812d737 < low = splitter - 2; < high = splitter - 1; < < while (((splitter % 2) == 0) && (low >= 0)) { < if (low < last) { < if (! merge_index_file(low, (high > last) ? last : high, db, < completely && (! low) && < !probe_file(index_filename(filename, db)))) { < panic("Error in merging file %ld into %ld", low, < (high > last) ? last : high); < } < } < high -= twotothe; < twotothe *= 2; < low -= twotothe; < splitter /= 2; < } < } < if (completely) { < < if (db->index_file_number != 1) { < do { < temp = last; < last ^= (last & -last); < < if (! merge_index_file(last, temp, db, < (! last) && < !probe_file(index_filename(filename, db)))) { < panic("Error in merging file %ld into %ld", temp, < last); < } < } < while (last); < } < < if (probe_file(index_filename(filename, db))) { < merge_index_file(-2L, 0L, db, true); < } < else if (db->index_file_number == 1) { < touch_file(index_filename_with_version(1, filename, db)); < merge_index_file(0L, 1, db, true); < /* rename 0 into the filal name */ < rename(index_filename_with_version(0L, filename2, db), < index_filename(filename, db)); < } < } < } 814,816d738 < < #if 0 < 818,820d739 < < static void merge_index_files(db) < 822,823d740 < static void merge_index_files _AP((database* db)); < 889c806 < } --- > } 891,892d807 < #endif < 1018,1019d932 < #if 0 < 1028,1033d940 < #else < < do_intermediate_merging(db, completely); < < #endif <