// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.cc,v 1.9 1998/07/19 04:22:06 jgg Exp $
+// $Id: tagfile.cc,v 1.14 1998/11/13 04:23:36 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
// TagFile::pkgTagFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgTagFile::pkgTagFile(File &Fd,unsigned long Size) : Fd(Fd), Size(Size)
+pkgTagFile::pkgTagFile(FileFd &Fd,unsigned long Size) : Fd(Fd), Size(Size)
{
Buffer = new char[Size];
Start = End = Buffer;
Start = Buffer;
End = Buffer + EndSize;
- // See if only a bit of the file is left
- if (Left < Size)
+ // See if only a bit of the file is left
+ if (Left < Size - (End - Buffer))
{
if (Fd.Read(End,Left) == false)
return false;
+
End += Left;
Left = 0;
}
{
if (Fd.Read(End,Size - (End - Buffer)) == false)
return false;
+
Left -= Size - (End - Buffer);
End = Buffer + Size;
}
/*}}}*/
// TagFile::Jump - Jump to a pre-recorded location in the file /*{{{*/
// ---------------------------------------------------------------------
-/* This jumps to a pre-recorded file location and */
+/* This jumps to a pre-recorded file location and reads the record
+ that is there */
bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
{
iOffset = Offset;
{
if (Stop[-1] != '\n')
continue;
+
+ // Skip line feeds
+ for (; Stop[0] == '\r' && Stop < End; Stop++);
+
if (Stop[0] == '\n')
{
// Extra one at the end to simplify find
Indexes[TagCount] = Stop - Section;
- for (; Stop[0] == '\n' && Stop < End; Stop++);
+ for (; (Stop[0] == '\n' || Stop[0] == '\r') && Stop < End; Stop++);
return true;
- break;
}
if (isspace(Stop[0]) == 0)
End = Section + Indexes[I+1];
for (; (isspace(*Start) != 0 || *Start == ':') && Start < End; Start++);
for (; isspace(End[-1]) != 0 && End > Start; End--);
+
return true;
}
Start = End = 0;