summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheiterators.h1
-rw-r--r--apt-pkg/pkgcache.cc19
-rw-r--r--apt-pkg/pkgrecords.cc5
-rw-r--r--apt-pkg/pkgrecords.h1
4 files changed, 21 insertions, 5 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index f0aafb52d..64fa4636e 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -129,6 +129,7 @@ class pkgCache::VerIterator
inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
inline DescIterator DescriptionList() const;
+ DescIterator TranslatedDescription() const;
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
inline VerFileIterator FileList() const;
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index f76afb935..4452079a2 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -26,6 +26,7 @@
#endif
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/indexfile.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
@@ -43,6 +44,7 @@
using std::string;
+
// Cache::Header::Header - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* Simply initialize the header */
@@ -608,3 +610,20 @@ string pkgCache::PkgFileIterator::RelStr()
return Res;
}
/*}}}*/
+// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
+// ---------------------------------------------------------------------
+/* return a DescIter for the current locale or the default if none is
+ * found
+ */
+pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
+{
+ pkgCache::DescIterator DescDefault = DescriptionList();
+ pkgCache::DescIterator Desc = DescDefault;
+ for (; Desc.end() == false; Desc++)
+ if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
+ break;
+ if (Desc.end() == true) Desc = DescDefault;
+ return Desc;
+};
+
+ /*}}}*/
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index f62f945b5..b22f3e73f 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -42,9 +42,6 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
if (Files[I->ID] == 0)
return;
}
- // We store that to make sure that the destructor won't segfault,
- // even if the Cache object was destructed before this instance.
- PackageFileCount = Cache.HeaderP->PackageFileCount;
}
/*}}}*/
// Records::~pkgRecords - Destructor /*{{{*/
@@ -52,7 +49,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
/* */
pkgRecords::~pkgRecords()
{
- for (unsigned I = 0; I != PackageFileCount; I++)
+ for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++)
delete Files[I];
delete [] Files;
}
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index ece91680e..31c444dbf 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -33,7 +33,6 @@ class pkgRecords
pkgCache &Cache;
Parser **Files;
- int PackageFileCount;
public: