home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
001-099
/
ff004.lzh
/
bm
/
MovResidue.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-01
|
1KB
|
38 lines
#include "bm.h"
/* Moves the text which has not been completely searched at the end of
* the buffer to the beginning of the buffer
* and returns number of bytes moved */
int MoveResidue(DescVec, NPats,Buffer, BuffEnd)
struct PattDesc *DescVec[];
int NPats;
char *Buffer, *BuffEnd;
{
char *FirstStart, *f, *t, *Residue;
int ResSize, i;
FirstStart = BuffEnd;
/* find the earliest point which has not been
* completely searched */
for (i=0; i < NPats; i++) {
FirstStart =
min(FirstStart, DescVec[i]-> Start );
} /* for */
/* now scan to the beginning of the line containing the
* unsearched text */
for (Residue = FirstStart; *Residue != '\n' &&
Residue >= Buffer; Residue--);
if (Residue < Buffer)
Residue = FirstStart;
else ++Residue;
ResSize = (BuffEnd - Residue + 1);
/* now move the residue to the beginning of
* the file */
t = Buffer; f = Residue;
for(i=ResSize;i;--i)
*t++ = *f++;
/* now fix the status vectors */
for (i=0; i < NPats; i++) {
DescVec[i]->Start -= (Residue - Buffer);
} /* for */
return(ResSize);
} /* MoveResidue */