merge( out )
int out;
{
int i, isml;
typekey lastout;
extern struct rec LastRec[];
extern char FilStat[];
lastout = MinimumKey;
LastRec[0].k = MaximumKey;
while (TRUE) {
isml = 0;
for (i=1; i<=maxfiles; i++)
if ( FilStat[i]=='i' && !Eof(i) &&
LastRec[i].k >= lastout &&
LastRec[i].k < LastRec[isml].k )
isml = i;
if ( isml==0 ) {
for (i=1; i<=maxfiles; i++)
if ( FilStat[i]=='i' && !Eof(i)) return(0);
return( 'done' );
}
WriteFile( out, LastRec[isml] );
lastout = LastRec[isml].k;
LastRec[isml] = ReadFile(isml);
}
};
|