// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.51 2001/06/10 02:03:33 jgg Exp $
+// $Id: apt-cache.cc,v 1.56 2002/02/15 03:40:00 jgg Exp $
/* ######################################################################
apt-cache - Manages the cache files
#include <config.h>
#include <apti18n.h>
+#include <locale.h>
#include <iostream.h>
#include <unistd.h>
#include <errno.h>
if (ReadPinFile(Plcy) == false)
return false;
- pkgCache::VerFile **VFList = new pkgCache::VerFile *[Cache.HeaderP->PackageCount];
- memset(VFList,0,sizeof(*VFList)*Cache.HeaderP->PackageCount);
+ unsigned long Count = Cache.HeaderP->PackageCount+1;
+ pkgCache::VerFile **VFList = new pkgCache::VerFile *[Count];
+ memset(VFList,0,sizeof(*VFList)*Count);
// Map versions that we want to write out onto the VerList array.
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
VFList[P->ID] = VF;
}
- LocalitySort(VFList,Cache.HeaderP->PackageCount,sizeof(*VFList));
+ LocalitySort(VFList,Count,sizeof(*VFList));
// Iterate over all the package files and write them out.
char *Buffer = new char[Cache.HeaderP->MaxVerFileSize+10];
else
VFList[P->ID].NameMatch = false;
}
-
+
// Doing names only, drop any that dont match..
if (NamesOnly == true && VFList[P->ID].NameMatch == false)
continue;
// Find the proper version to use.
pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
- if (V.end() == true)
+ if (V.end() == false)
+ VFList[P->ID].Vf = V.FileList();
+ }
+
+ // Include all the packages that provide matching names too
+ for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
+ {
+ if (VFList[P->ID].NameMatch == false)
continue;
- VFList[P->ID].Vf = V.FileList();
+
+ for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++)
+ {
+ pkgCache::VerIterator V = Plcy.GetCandidateVer(Prv.OwnerPkg());
+ if (V.end() == false)
+ {
+ VFList[Prv.OwnerPkg()->ID].Vf = V.FileList();
+ VFList[Prv.OwnerPkg()->ID].NameMatch = true;
+ }
+ }
}
-
+
LocalitySort(&VFList->Vf,Cache.HeaderP->PackageCount,sizeof(*VFList));
// Iterate over all the version records and check them
{0,0}};
CacheInitialize();
-
+
+ // Set up gettext support
+ setlocale(LC_ALL,"");
+ textdomain(PACKAGE);
+
// Parse the command line and initialize the package library
CommandLine CmdL(Args,_config);
if (pkgInitConfig(*_config) == false ||
if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
{
- MMap *Map;
+ MMap *Map = 0;
if (_config->FindB("APT::Cache::Generate",true) == false)
{
Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),