X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0a8e3465cb644e380ab0fc6d66f6d1f17363b34e..a05599f12fd30388ee972ed2535d5297afe0c20b:/apt-pkg/tagfile.cc diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 50d669977..a55d5214a 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.11 1998/10/02 04:39:48 jgg Exp $ +// $Id: tagfile.cc,v 1.15 1998/11/27 01:14:06 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -45,10 +45,7 @@ bool pkgTagFile::Step(pkgTagSection &Tag) return false; if (Tag.Scan(Start,End - Start) == false) - { - cout << string(Start,End-Start) << endl; return _error->Error("Unable to parse package file"); - } } Start += Tag.size(); iOffset += Tag.size(); @@ -75,11 +72,12 @@ bool pkgTagFile::Fill() 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; } @@ -87,6 +85,7 @@ bool pkgTagFile::Fill() { if (Fd.Read(End,Size - (End - Buffer)) == false) return false; + Left -= Size - (End - Buffer); End = Buffer + Size; } @@ -95,7 +94,8 @@ bool pkgTagFile::Fill() /*}}}*/ // 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; @@ -180,3 +180,28 @@ bool pkgTagSection::Find(const char *Tag,const char *&Start, return false; } /*}}}*/ +// pkgTagSection::FindS - Find a string /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string pkgTagSection::FindS(const char *Tag) +{ + const char *Start; + const char *End; + if (Find(Tag,Start,End) == false) + return string(); + return string(Start,End); +} + /*}}}*/ +// TagSection::FindI - Find an integer /*{{{*/ +// --------------------------------------------------------------------- +/* */ +unsigned int pkgTagSection::FindI(const char *Tag) +{ + const char *Start; + const char *End; + if (Find(Tag,Start,End) == false) + return 0; + + return atoi(string(Start,End).c_str()); +} + /*}}}*/