From 4260fd3972cc0c01e6cbc825063c06311d440f9b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Oct 2010 16:54:28 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - Add a FileFd::FileSize() method to get the size of the underlying file and not the size of the content in the file as FileFd::Size() does - the sizes can differ since the direct gzip integration * methods/{gzip,bzip2}.cc: - use FileSize() to determine if the file is invalid (Closes: #600852) --- apt-pkg/contrib/fileutl.cc | 18 ++++++++++++------ apt-pkg/contrib/fileutl.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index cbf1d64a9..f4ab066d7 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -910,18 +910,24 @@ unsigned long FileFd::Tell() return Res; } /*}}}*/ -// FileFd::Size - Return the size of the file /*{{{*/ +// FileFd::FileSize - Return the size of the file /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::Size() +unsigned long FileFd::FileSize() { struct stat Buf; - unsigned long size; - off_t orig_pos; if (fstat(iFd,&Buf) != 0) return _error->Errno("fstat","Unable to determine the file size"); - size = Buf.st_size; + return Buf.st_size; +} + /*}}}*/ +// FileFd::Size - Return the size of the content in the file /*{{{*/ +// --------------------------------------------------------------------- +/* */ +unsigned long FileFd::Size() +{ + unsigned long size = FileSize(); // only check gzsize if we are actually a gzip file, just checking for // "gz" is not sufficient as uncompressed files will be opened with @@ -931,7 +937,7 @@ unsigned long FileFd::Size() /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do * this ourselves; the original (uncompressed) file size is the last 32 * bits of the file */ - orig_pos = lseek(iFd, 0, SEEK_CUR); + off_t orig_pos = lseek(iFd, 0, SEEK_CUR); if (lseek(iFd, -4, SEEK_END) < 0) return _error->Errno("lseek","Unable to seek to end of gzipped file"); if (read(iFd, &size, 4) != 4) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 419506273..1380f06b4 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -63,6 +63,7 @@ class FileFd bool Truncate(unsigned long To); unsigned long Tell(); unsigned long Size(); + unsigned long FileSize(); bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false); bool Close(); -- cgit v1.2.3 From 4b625b95a04a9d73c6682a3f9354112a394bb674 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 26 Oct 2010 23:24:41 +0200 Subject: * apt-pkg/pkgcache.cc: - fallback always to a suitable description (Closes: #601016) --- apt-pkg/pkgcache.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 324445fa7..616d400a2 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -891,18 +891,19 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const for (std::vector::const_iterator l = lang.begin(); l != lang.end(); l++) { - pkgCache::DescIterator DescDefault = DescriptionList(); - pkgCache::DescIterator Desc = DescDefault; - - for (; Desc.end() == false; Desc++) + pkgCache::DescIterator Desc = DescriptionList(); + for (; Desc.end() == false; ++Desc) if (*l == Desc.LanguageCode() || (*l == "en" && strcmp(Desc.LanguageCode(),"") == 0)) break; - if (Desc.end() == true) - Desc = DescDefault; + if (Desc.end() == true) + continue; return Desc; } - + for (pkgCache::DescIterator Desc = DescriptionList(); + Desc.end() == false; ++Desc) + if (strcmp(Desc.LanguageCode(), "") == 0) + return Desc; return DescriptionList(); }; -- cgit v1.2.3