diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-08-09 14:45:01 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-08-09 14:45:01 +0200 |
commit | 754229c5d8e929a221645a5c56c1bd4274910c26 (patch) | |
tree | af29ab8694b0ff8876a2df83513c4cd41e492415 | |
parent | af5a94f4c7b1f2cc797cd1e023e36a1bb359689d (diff) | |
parent | 1b5f30cb5575f274246b1dabad0efc7a7a549aac (diff) |
* merged with mainline
-rw-r--r-- | apt-pkg/tagfile.cc | 115 | ||||
-rw-r--r-- | apt-pkg/tagfile.h | 5 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | debian/changelog | 15 | ||||
-rw-r--r-- | debian/control | 2 |
5 files changed, 117 insertions, 22 deletions
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 25e2930fa..8fcbeb23b 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -33,21 +33,32 @@ using std::string; /* */ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : Fd(*pFd), - Size(Size) + Size(Size), + Map(NULL), + Buffer(0) { - if (Fd.IsOpen() == false || Fd.Size() == 0) + if (Fd.IsOpen() == false) { - Buffer = 0; Start = End = Buffer = 0; + Done = true; iOffset = 0; Map = NULL; return; } - Map = new MMap (Fd, MMap::Public | MMap::ReadOnly); - Buffer = (char *) Map->Data (); - Start = Buffer; - End = Buffer + Map->Size (); + // check if we can MMap it + if(Fd.Size() == 0) + { + Buffer = new char[Size]; + Start = End = Buffer; + Done = false; + Fill(); + } else { + Map = new MMap (Fd, MMap::Public | MMap::ReadOnly); + Buffer = (char *) Map->Data (); + Start = Buffer; + End = Buffer + Map->Size (); + } iOffset = 0; } /*}}}*/ @@ -56,6 +67,7 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : /* */ pkgTagFile::~pkgTagFile() { + if(!Map) delete [] Buffer; delete Map; } /*}}}*/ @@ -64,13 +76,21 @@ pkgTagFile::~pkgTagFile() /* If the Section Scanner fails we refill the buffer and try again. */ bool pkgTagFile::Step(pkgTagSection &Tag) { - if (Start == End) + if ((Map != NULL) && (Start == End)) return false; if (Tag.Scan(Start,End - Start) == false) { - return _error->Error(_("Unable to parse package file %s (1)"), - Fd.Name().c_str()); + if (Map != NULL) + return _error->Error(_("Unable to parse package file %s (1)"), + Fd.Name().c_str()); + + if (Fill() == false) + return false; + + if (Tag.Scan(Start,End - Start) == false) + return _error->Error(_("Unable to parse package file %s (1)"), + Fd.Name().c_str()); } Start += Tag.size(); iOffset += Tag.size(); @@ -79,6 +99,50 @@ bool pkgTagFile::Step(pkgTagSection &Tag) return true; } /*}}}*/ +// TagFile::Fill - Top up the buffer /*{{{*/ +// --------------------------------------------------------------------- +/* This takes the bit at the end of the buffer and puts it at the start + then fills the rest from the file */ +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 && Actual == 0) + return false; + if (Size - (End - Buffer) < 4) + return true; + + // Append a double new line if one does not exist + unsigned int LineCount = 0; + for (const char *E = End - 1; E - End < 6 && (*E == '\n' || *E == '\r'); E--) + if (*E == '\n') + LineCount++; + for (; LineCount < 2; LineCount++) + *End++ = '\n'; + + return true; + } + + return true; +} + /*}}}*/ // TagFile::Jump - Jump to a pre-recorded location in the file /*{{{*/ // --------------------------------------------------------------------- /* This jumps to a pre-recorded file location and reads the record @@ -94,12 +158,31 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset) return Step(Tag); } - // Reposition and reload.. iOffset = Offset; - Start = Buffer + iOffset; + if (Map != NULL) + { + Start = Buffer + iOffset; + } + else + { + // Reposition and reload.. + Done = false; + if (Fd.Seek(Offset) == false) + return false; + End = Start = Buffer; - // Start != End is a special case to not fail on empty TagFiles - if (Start != End && Tag.Scan(Start,End - Start) == false) + if (Fill() == false) + return false; + + if (Tag.Scan(Start,End - Start) == true) + return true; + + // This appends a double new line (for the real eof handling) + if (Fill() == false) + return false; + } + + if (Tag.Scan(Start,End - Start) == false) return _error->Error(_("Unable to parse package file %s (2)"),Fd.Name().c_str()); return true; @@ -157,8 +240,8 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) if ((Stop+1 >= End) && (End[-1] == '\n' || End[-1] == '\r')) { - Indexes[TagCount] = (End - 1) - Section; - return true; + Indexes[TagCount] = (End - 1) - Section; + return true; } return false; diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 5cff2681c..dd481ba51 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -74,16 +74,19 @@ class pkgTagFile char *Buffer; char *Start; char *End; + bool Done; unsigned long iOffset; unsigned long Size; + bool Fill(); + public: bool Step(pkgTagSection &Section); inline unsigned long Offset() {return iOffset;}; bool Jump(pkgTagSection &Tag,unsigned long Offset); - pkgTagFile(FileFd *F,unsigned long Size = 32*1024); + pkgTagFile(FileFd *F,unsigned long Size = 64*1024); ~pkgTagFile(); }; diff --git a/configure.in b/configure.in index fc4eff203..f0b0d6703 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib) AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in) dnl -- SET THIS TO THE RELEASE VERSION -- -AC_DEFINE_UNQUOTED(VERSION,"0.6.45") +AC_DEFINE_UNQUOTED(VERSION,"0.6.45.1") PACKAGE="apt" AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE") AC_SUBST(PACKAGE) diff --git a/debian/changelog b/debian/changelog index c658fe400..ec802a80c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,16 @@ +apt (0.6.45.1) unstable; urgency=low + + * debian/control: + - switched to libdb4.4 for building + + -- Michael Vogt <michael.vogt@ubuntu.com> Wed, 9 Aug 2006 14:27:54 +0200 + apt (0.6.45) unstable; urgency=low * apt-pkg/contrib/sha256.cc: - fixed the sha256 generation (closes: #378183) * ftparchive/cachedb.cc: - - applied patch from ajt to fix Clean() function + - applied patch from Anthony Towns to fix Clean() function (closes: #379576) * doc/apt-get.8.xml: - fix path to the apt user build (Closes: #375640) @@ -21,6 +28,9 @@ apt (0.6.45) unstable; urgency=low - fix for string mangling, closes: #373864 * apt-pkg/acquire-item.cc: - check for bzip2 in /bin (closes: #377391) + * apt-pkg/tagfile.cc: + - make it work on non-mapable files again, thanks + to James Troup for confirming the fix (closes: #376777) * Merged from Christian Perrier bzr branch: * ko.po: Updated to 512t. Closes: #378901 * hu.po: Updated to 512t. Closes: #376330 @@ -31,9 +41,8 @@ apt (0.6.45) unstable; urgency=low * dz.po: New Dzongkha translation: 512t * ro.po: Updated to 512t * eu.po: Updated - * eu.po: Updated - -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 25 Jul 2006 11:55:22 +0200 + -- Michael Vogt <mvo@debian.org> Thu, 27 Jul 2006 00:52:05 +0200 apt (0.6.44.2) unstable; urgency=low diff --git a/debian/control b/debian/control index 53ce851f6..3cba50acb 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: important Maintainer: APT Development Team <deity@lists.debian.org> Uploaders: Jason Gunthorpe <jgg@debian.org>, Adam Heath <doogie@debian.org>, Matt Zimmerman <mdz@debian.org>, Michael Vogt <mvo@debian.org> Standards-Version: 3.6.2.2 -Build-Depends: debhelper (>= 5.0), libdb4.3-dev, gettext (>= 0.12) +Build-Depends: debhelper (>= 5.0), libdb4.4-dev, gettext (>= 0.12) Build-Depends-Indep: debiandoc-sgml, docbook-utils (>= 0.6.12-1) Package: apt |