X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/fd71171a9f0e07c3bba58e6ab7478609d97b7058..5e972bffae68a75aafc9f9b639e82e252fde3b8b:/apt-pkg/tagfile.cc diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 45913877d..cae0fa819 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.cc,v 1.31 2001/10/04 05:13:23 jgg Exp $ +// $Id: tagfile.cc,v 1.37.2.2 2003/12/31 16:02:30 mdz Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -31,7 +31,9 @@ using std::string; // TagFile::pkgTagFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : Fd(*pFd), Size(Size) +pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : + Fd(*pFd), + Size(Size) { if (Fd.IsOpen() == false) { @@ -68,13 +70,13 @@ bool pkgTagFile::Step(pkgTagSection &Tag) return false; if (Tag.Scan(Start,End - Start) == false) - return _error->Error(_("Unable to parse package file %s (1)"),Fd.Name().c_str()); - } + return _error->Error(_("Unable to parse package file %s (1)"), + Fd.Name().c_str()); + } Start += Tag.size(); iOffset += Tag.size(); Tag.Trim(); - return true; } /*}}}*/ @@ -85,14 +87,25 @@ bool pkgTagFile::Step(pkgTagSection &Tag) bool pkgTagFile::Fill() { unsigned long EndSize = End - Start; + unsigned long Actual = 0; memmove(Buffer,Start,EndSize); Start = Buffer; End = Buffer + EndSize; + if (Done == false) + { + // See if only a bit of the file is left + if (Fd.Read(End,Size - (End - Buffer),&Actual) == false) + return false; + if (Actual != Size - (End - Buffer)) + Done = true; + End += Actual; + } + if (Done == true) { - if (EndSize <= 3) + if (EndSize <= 3 && Actual == 0) return false; if (Size - (End - Buffer) < 4) return true; @@ -108,31 +121,6 @@ bool pkgTagFile::Fill() return true; } - // See if only a bit of the file is left - unsigned long Actual; - if (Fd.Read(End,Size - (End - Buffer),&Actual) == false) - return false; - if (Actual != Size - (End - Buffer)) - Done = true; - End += Actual; -/* - if (Left < Size - (End - Buffer)) - { - if (Fd.Read(End,Left) == false) - return false; - - End += Left; - Left = 0; - } - else - { - if (Fd.Read(End,Size - (End - Buffer)) == false) - return false; - - Left -= Size - (End - Buffer); - End = Buffer + Size; - }*/ - return true; } /*}}}*/ @@ -211,7 +199,7 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) if (Stop == 0) return false; - for (; Stop+1 < End && Stop[1] == '\r'; Stop++); + for (; Stop+1 < End && Stop[1] == '\r'; Stop++); // Double newline marks the end of the record if (Stop+1 < End && Stop[1] == '\n')