Skip to main content.
home | support | download

Back to List Archive

Re: merging empty file

From: Giulia Hill <ghill(at)not-real.library.berkeley.EDU>
Date: Wed Nov 19 1997 - 16:44:25 GMT
As J. pointed out in his e-mail there was a bug in the merge option, so that 
when the first of two indexes to be merged was empty, the merged index 
was incorrectly created, in particular, the offset and the indexed words 
from the non-empty file were not recorded.

Following is the fix for the problem as a diff -c between the old and new 
merge.c files.  The files in the ftp location have been updated with the 
fix, too.

Giulia
-----------------------------------------------------------------------------
*** oldMerge.c  Mon Sep 22 08:54:49 1997
--- newMerge.c  Tue Nov 18 15:50:50 1997
***************
*** 35,40 ****
--- 35,41 ----
        struct indexentry *buffer1, *buffer2;
        FILE *fp1, *fp2, *fp3;
        struct metaMergeEntry *metaFile1, *metaFile2;
+       int firstTime = 1;
 
        initindexfilehashlist();
 
***************
*** 137,148 ****
                        ip1 = (struct indexentry *)
                          readindexline(fp1, limit1,metaFile1);
                        if (ip1 == NULL) {
!                         if (ip2 == NULL) {
                            break;
                          }
                        }
                        buffer1 = ip1;
                }
                if (buffer2 == NULL) {
                        ip2 = (struct indexentry *)
                          readindexline(fp2, limit2,metaFile2);
--- 138,150 ----
                        ip1 = (struct indexentry *)
                          readindexline(fp1, limit1,metaFile1);
                        if (ip1 == NULL) {
!                         if (ip2 == NULL && !firstTime) {
                            break;
                          }
                        }
                        buffer1 = ip1;
                }
+               firstTime =0;
                if (buffer2 == NULL) {
                        ip2 = (struct indexentry *)
                          readindexline(fp2, limit2,metaFile2);
-----------------------------------------------------------------------
/* ----------------------------------------------------------- */
/*  Giulia Hill                        Library Systems Office  */
/*                                     386 Doe Library         */
/*  ghill@library.berkeley.edu         U.C. Berkeley,          */
/*                                     Berkeley, CA 94720      */
/* ----------------------------------------------------------- */
Received on Wed Nov 19 08:49:09 1997