summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2013-04-08 15:38:45 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2013-04-08 15:38:45 +0200
commit3278fe66567d149ea92c1afa78941f2bc3c71c85 (patch)
tree3a735d19278bb8f5aa19ba2707f3a09cf52e1d21 /apt-pkg
parent37cc828e003f51d63ed991be5acac36765b8230a (diff)
parent885594fc8831d1be5a254557385e3dbefb564fbf (diff)
merged bundle from david
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc4
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/cachefilter.cc3
-rw-r--r--apt-pkg/cacheiterators.h2
-rw-r--r--apt-pkg/contrib/configuration.cc2
-rw-r--r--apt-pkg/contrib/fileutl.cc10
-rw-r--r--apt-pkg/contrib/netrc.cc8
-rw-r--r--apt-pkg/contrib/strutl.cc8
-rw-r--r--apt-pkg/deb/deblistparser.cc14
-rw-r--r--apt-pkg/deb/debversion.cc11
-rw-r--r--apt-pkg/deb/dpkgpm.cc17
-rw-r--r--apt-pkg/depcache.cc25
-rw-r--r--apt-pkg/indexcopy.cc6
-rw-r--r--apt-pkg/orderlist.cc4
-rw-r--r--apt-pkg/pkgcache.cc65
-rw-r--r--apt-pkg/pkgcachegen.cc179
-rw-r--r--apt-pkg/pkgcachegen.h9
-rw-r--r--apt-pkg/srcrecords.cc11
-rw-r--r--apt-pkg/vendor.cc2
-rw-r--r--apt-pkg/versionmatch.cc2
20 files changed, 225 insertions, 159 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 9b7862111..d12733747 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -560,7 +560,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
Desc.Owner = this;
Desc.ShortDesc = ShortDesc;
- if(available_patches.size() == 0)
+ if(available_patches.empty() == true)
{
// we are done (yeah!)
Finish(true);
@@ -1649,7 +1649,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
assumption here that all the available sources for this version share
the same extension.. */
// Skip not source sources, they do not have file fields.
- for (; Vf.end() == false; Vf++)
+ for (; Vf.end() == false; ++Vf)
{
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
continue;
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 653775688..37c846582 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -401,8 +401,8 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
close(external[1]);
FILE *dpkg = fdopen(external[0], "r");
- char buf[1024];
if(dpkg != NULL) {
+ char buf[1024];
while (fgets(buf, sizeof(buf), dpkg) != NULL) {
char* arch = strtok(buf, " ");
while (arch != NULL) {
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index 58cc812bf..64cde41d1 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -71,8 +71,7 @@ static std::string CompleteArch(std::string const &arch) {
}
/*}}}*/
PackageArchitectureMatchesSpecification::PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern) :/*{{{*/
- literal(pattern), isPattern(isPattern), d(NULL) {
- complete = CompleteArch(pattern);
+ literal(pattern), complete(CompleteArch(pattern)), isPattern(isPattern), d(NULL) {
}
/*}}}*/
bool PackageArchitectureMatchesSpecification::operator() (char const * const &arch) {/*{{{*/
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index dcd353119..179a0e963 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -286,6 +286,8 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
bool IsIgnorable(PrvIterator const &Prv) const;
bool IsIgnorable(PkgIterator const &Pkg) const;
bool IsMultiArchImplicit() const;
+ bool IsSatisfied(VerIterator const &Ver) const;
+ bool IsSatisfied(PrvIterator const &Prv) const;
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets() const;
bool SmartTargetPkg(PkgIterator &Result) const;
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 4de17e3e1..808a708a1 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -958,7 +958,7 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config)
continue;
}
}
- if (strings.size() == 0)
+ if (strings.empty() == true)
patterns.push_back(NULL);
}
/*}}}*/
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 90e49cbfa..f18e17005 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -387,7 +387,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
std::vector<string> List;
- if (DirectoryExists(Dir.c_str()) == false)
+ if (DirectoryExists(Dir) == false)
{
_error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str());
return List;
@@ -413,14 +413,14 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
if (Ent->d_type != DT_REG)
#endif
{
- if (RealFileExists(File.c_str()) == false)
+ if (RealFileExists(File) == false)
{
// do not show ignoration warnings for directories
if (
#ifdef _DIRENT_HAVE_D_TYPE
Ent->d_type == DT_DIR ||
#endif
- DirectoryExists(File.c_str()) == true)
+ DirectoryExists(File) == true)
continue;
if (SilentIgnore.Match(Ent->d_name) == false)
_error->Notice(_("Ignoring '%s' in directory '%s' as it is not a regular file"), Ent->d_name, Dir.c_str());
@@ -501,7 +501,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, bool SortList)
std::vector<string> List;
- if (DirectoryExists(Dir.c_str()) == false)
+ if (DirectoryExists(Dir) == false)
{
_error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str());
return List;
@@ -526,7 +526,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, bool SortList)
if (Ent->d_type != DT_REG)
#endif
{
- if (RealFileExists(File.c_str()) == false)
+ if (RealFileExists(File) == false)
{
if (Debug == true)
std::clog << "Bad file: " << Ent->d_name << " → it is not a real file" << std::endl;
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 0a902f126..de95aa4ab 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -50,14 +50,10 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw
FILE *file;
int retcode = 1;
int specific_login = (login.empty() == false);
- char *home = NULL;
bool netrc_alloc = false;
- int state_our_login = false; /* With specific_login,
- found *our* login name */
-
if (!netrcfile) {
- home = getenv ("HOME"); /* portable environment reader */
+ char const * home = getenv ("HOME"); /* portable environment reader */
if (!home) {
struct passwd *pw;
@@ -86,6 +82,8 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw
int state = NOTHING;
char state_login = 0; /* Found a login keyword */
char state_password = 0; /* Found a password keyword */
+ int state_our_login = false; /* With specific_login,
+ found *our* login name */
while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) {
tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 9726138a0..03b98e93e 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1252,7 +1252,7 @@ string StripEpoch(const string &VerStr)
return VerStr;
return VerStr.substr(i+1);
}
-
+ /*}}}*/
// tolower_ascii - tolower() function that ignores the locale /*{{{*/
// ---------------------------------------------------------------------
/* This little function is the most called method we have and tries
@@ -1290,14 +1290,14 @@ bool CheckDomainList(const string &Host,const string &List)
return false;
}
/*}}}*/
-// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/
+// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/
// ---------------------------------------------------------------------
/* */
string DeEscapeString(const string &input)
{
char tmp[3];
- string::const_iterator it, escape_start;
- string output, octal, hex;
+ string::const_iterator it;
+ string output;
for (it = input.begin(); it != input.end(); ++it)
{
// just copy non-escape chars
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index d84a6a26d..db86bd698 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -284,7 +284,7 @@ unsigned short debListParser::VersionHash()
"Replaces",0};
unsigned long Result = INIT_FCS;
char S[1024];
- for (const char **I = Sections; *I != 0; I++)
+ for (const char * const *I = Sections; *I != 0; ++I)
{
const char *Start;
const char *End;
@@ -295,13 +295,13 @@ unsigned short debListParser::VersionHash()
of certain fields. dpkg also has the rather interesting notion of
reformatting depends operators < -> <= */
char *J = S;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
- if (isspace(*Start) == 0)
- *J++ = tolower_ascii(*Start);
- if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
- *J++ = '=';
- if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
+ if (isspace(*Start) != 0)
+ continue;
+ *J++ = tolower_ascii(*Start);
+
+ if ((*Start == '<' || *Start == '>') && Start[1] != *Start && Start[1] != '=')
*J++ = '=';
}
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index a02699a44..140561262 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -215,10 +215,15 @@ bool debVersioningSystem::CheckDep(const char *PkgVer,
return true;
if (PkgVer == 0 || PkgVer[0] == 0)
return false;
-
+ Op &= 0x0F;
+
+ // fast track for (equal) strings [by location] which are by definition equal versions
+ if (PkgVer == DepVer)
+ return Op == pkgCache::Dep::Equals || Op == pkgCache::Dep::LessEq || Op == pkgCache::Dep::GreaterEq;
+
// Perform the actual comparision.
- int Res = CmpVersion(PkgVer,DepVer);
- switch (Op & 0x0F)
+ int const Res = CmpVersion(PkgVer, DepVer);
+ switch (Op)
{
case pkgCache::Dep::LessEq:
if (Res <= 0)
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 6cb8bc6b6..3bc31dc37 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -147,11 +147,11 @@ static
pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
{
pkgCache::VerIterator Ver;
- for (Ver = Pkg.VersionList(); Ver.end() == false; Ver++)
+ for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
pkgCache::VerFileIterator Vf = Ver.FileList();
pkgCache::PkgFileIterator F = Vf.File();
- for (F = Vf.File(); F.end() == false; F++)
+ for (F = Vf.File(); F.end() == false; ++F)
{
if (F && F.Archive())
{
@@ -1585,12 +1585,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
if (!logfile_name.empty())
{
FILE *log = NULL;
- char buf[1024];
fprintf(report, "DpkgTerminalLog:\n");
log = fopen(logfile_name.c_str(),"r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
fclose(log);
@@ -1609,13 +1609,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// attach dmesg log (to learn about segfaults)
if (FileExists("/bin/dmesg"))
{
- FILE *log = NULL;
- char buf[1024];
-
fprintf(report, "Dmesg:\n");
- log = popen("/bin/dmesg","r");
+ FILE *log = popen("/bin/dmesg","r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
pclose(log);
@@ -1625,13 +1623,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// attach df -l log (to learn about filesystem status)
if (FileExists("/bin/df"))
{
- FILE *log = NULL;
- char buf[1024];
fprintf(report, "Df:\n");
- log = popen("/bin/df -l","r");
+ FILE *log = popen("/bin/df -l","r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
pclose(log);
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index a48cd8b0c..6a3e9bfc4 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -351,18 +351,15 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
PkgIterator Pkg = Dep.TargetPkg();
// Check the base package
if (Type == NowVersion && Pkg->CurrentVer != 0)
- if (VS().CheckDep(Pkg.CurrentVer().VerStr(),Dep->CompareOp,
- Dep.TargetVer()) == true)
+ if (Dep.IsSatisfied(Pkg.CurrentVer()) == true)
return true;
if (Type == InstallVersion && PkgState[Pkg->ID].InstallVer != 0)
- if (VS().CheckDep(PkgState[Pkg->ID].InstVerIter(*this).VerStr(),
- Dep->CompareOp,Dep.TargetVer()) == true)
+ if (Dep.IsSatisfied(PkgState[Pkg->ID].InstVerIter(*this)) == true)
return true;
if (Type == CandidateVersion && PkgState[Pkg->ID].CandidateVer != 0)
- if (VS().CheckDep(PkgState[Pkg->ID].CandidateVerIter(*this).VerStr(),
- Dep->CompareOp,Dep.TargetVer()) == true)
+ if (Dep.IsSatisfied(PkgState[Pkg->ID].CandidateVerIter(*this)) == true)
return true;
}
@@ -398,7 +395,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
}
// Compare the versions.
- if (VS().CheckDep(P.ProvideVersion(),Dep->CompareOp,Dep.TargetVer()) == true)
+ if (Dep.IsSatisfied(P) == true)
{
Res = P.OwnerPkg();
return true;
@@ -1192,14 +1189,13 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
{
APT::VersionList verlist;
pkgCache::VerIterator Cand = PkgState[Start.TargetPkg()->ID].CandidateVerIter(*this);
- if (Cand.end() == false && VS().CheckDep(Cand.VerStr(), Start->CompareOp, Start.TargetVer()) == true)
+ if (Cand.end() == false && Start.IsSatisfied(Cand) == true)
verlist.insert(Cand);
for (PrvIterator Prv = Start.TargetPkg().ProvidesList(); Prv.end() != true; ++Prv)
{
pkgCache::VerIterator V = Prv.OwnerVer();
pkgCache::VerIterator Cand = PkgState[Prv.OwnerPkg()->ID].CandidateVerIter(*this);
- if (Cand.end() == true || V != Cand ||
- VS().CheckDep(Prv.ProvideVersion(), Start->CompareOp, Start.TargetVer()) == false)
+ if (Cand.end() == true || V != Cand || Start.IsSatisfied(Prv) == false)
continue;
verlist.insert(Cand);
}
@@ -1407,7 +1403,7 @@ bool pkgDepCache::SetCandidateRelease(pkgCache::VerIterator TargetVer,
if (Cand.end() == true)
continue;
// check if the current candidate is enough for the versioned dependency - and installable?
- if (VS().CheckDep(P.CandVersion(), Start->CompareOp, Start.TargetVer()) == true &&
+ if (Start.IsSatisfied(Cand) == true &&
(VersionState(Cand.DependsList(), DepInstall, DepCandMin, DepCandPolicy) & DepCandMin) == DepCandMin)
{
itsFine = true;
@@ -1441,7 +1437,7 @@ bool pkgDepCache::SetCandidateRelease(pkgCache::VerIterator TargetVer,
V = Match.Find(D.TargetPkg());
// check if the version from this release could satisfy the dependency
- if (V.end() == true || VS().CheckDep(V.VerStr(), D->CompareOp, D.TargetVer()) == false)
+ if (V.end() == true || D.IsSatisfied(V) == false)
{
if (stillOr == true)
continue;
@@ -1771,7 +1767,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
for(VerIterator V = d.TargetPkg().VersionList();
!V.end(); ++V)
{
- if(_system->VS->CheckDep(V.VerStr(), d->CompareOp, d.TargetVer()))
+ if(d.IsSatisfied(V))
{
if(debug_autoremove)
{
@@ -1793,8 +1789,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
for(PrvIterator prv=d.TargetPkg().ProvidesList();
!prv.end(); ++prv)
{
- if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp,
- d.TargetVer()))
+ if(d.IsSatisfied(prv))
{
if(debug_autoremove)
{
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index f53989bdb..a262ef789 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -141,7 +141,6 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
File = OrigPath + ChopDirs(File,Chop);
// See if the file exists
- bool Mangled = false;
if (NoStat == false || Hits < 10)
{
// Attempt to fix broken structure
@@ -164,6 +163,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
if (stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0 ||
Buf.st_size == 0)
{
+ bool Mangled = false;
// Attempt to fix busted symlink support for one instance
string OrigFile = File;
string::size_type Start = File.find("binary-");
@@ -681,9 +681,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
unsigned int WrongSize = 0;
unsigned int Packages = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
- {
- string OrigPath = string(*I,CDROM.length());
-
+ {
// Open the package file
FileFd Pkg(*I, FileFd::ReadOnly, FileFd::Auto);
off_t const FileSize = Pkg.Size();
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index 3a179b2a2..80d8fd490 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -331,9 +331,11 @@ int pkgOrderList::Score(PkgIterator Pkg)
}
// Important Required Standard Optional Extra
- signed short PrioMap[] = {0,5,4,3,1,0};
if (Cache[Pkg].InstVerIter(Cache)->Priority <= 5)
+ {
+ signed short PrioMap[] = {0,5,4,3,1,0};
Score += PrioMap[Cache[Pkg].InstVerIter(Cache)->Priority];
+ }
return Score;
}
/*}}}*/
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 1de33ff9b..d7725563b 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -52,7 +52,7 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
MajorVersion = 8;
- MinorVersion = 0;
+ MinorVersion = 1;
Dirty = false;
HeaderSz = sizeof(pkgCache::Header);
@@ -182,18 +182,17 @@ unsigned long pkgCache::sHash(const string &Str) const
{
unsigned long Hash = 0;
for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
- Hash = 5*Hash + tolower_ascii(*I);
+ Hash = 41 * Hash + tolower_ascii(*I);
return Hash % _count(HeaderP->PkgHashTable);
}
unsigned long pkgCache::sHash(const char *Str) const
{
- unsigned long Hash = 0;
- for (const char *I = Str; *I != 0; ++I)
- Hash = 5*Hash + tolower_ascii(*I);
+ unsigned long Hash = tolower_ascii(*Str);
+ for (const char *I = Str + 1; *I != 0; ++I)
+ Hash = 41 * Hash + tolower_ascii(*I);
return Hash % _count(HeaderP->PkgHashTable);
}
-
/*}}}*/
// Cache::SingleArchFindPkg - Locate a package by name /*{{{*/
// ---------------------------------------------------------------------
@@ -206,9 +205,14 @@ pkgCache::PkgIterator pkgCache::SingleArchFindPkg(const string &Name)
Package *Pkg = PkgP + HeaderP->PkgHashTable[Hash(Name)];
for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
{
- if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
- stringcasecmp(Name,StrP + Pkg->Name) == 0)
- return PkgIterator(*this,Pkg);
+ if (unlikely(Pkg->Name == 0))
+ continue;
+
+ int const cmp = strcasecmp(Name.c_str(), StrP + Pkg->Name);
+ if (cmp == 0)
+ return PkgIterator(*this, Pkg);
+ else if (cmp < 0)
+ break;
}
return PkgIterator(*this,0);
}
@@ -265,9 +269,14 @@ pkgCache::GrpIterator pkgCache::FindGrp(const string &Name) {
// Look at the hash bucket for the group
Group *Grp = GrpP + HeaderP->GrpHashTable[sHash(Name)];
for (; Grp != GrpP; Grp = GrpP + Grp->Next) {
- if (Grp->Name != 0 && StrP[Grp->Name] == Name[0] &&
- stringcasecmp(Name, StrP + Grp->Name) == 0)
+ if (unlikely(Grp->Name == 0))
+ continue;
+
+ int const cmp = strcasecmp(Name.c_str(), StrP + Grp->Name);
+ if (cmp == 0)
return GrpIterator(*this, Grp);
+ else if (cmp < 0)
+ break;
}
return GrpIterator(*this,0);
@@ -279,22 +288,22 @@ pkgCache::GrpIterator pkgCache::FindGrp(const string &Name) {
type in the weird debian style.. */
const char *pkgCache::CompTypeDeb(unsigned char Comp)
{
- const char *Ops[] = {"","<=",">=","<<",">>","=","!="};
- if ((unsigned)(Comp & 0xF) < 7)
- return Ops[Comp & 0xF];
- return "";
+ const char * const Ops[] = {"","<=",">=","<<",">>","=","!="};
+ if (unlikely((unsigned)(Comp & 0xF) >= sizeof(Ops)/sizeof(Ops[0])))
+ return "";
+ return Ops[Comp & 0xF];
}
/*}}}*/
// Cache::CompType - Return a string describing the compare type /*{{{*/
// ---------------------------------------------------------------------
-/* This returns a string representation of the dependency compare
+/* This returns a string representation of the dependency compare
type */
const char *pkgCache::CompType(unsigned char Comp)
{
- const char *Ops[] = {"","<=",">=","<",">","=","!="};
- if ((unsigned)(Comp & 0xF) < 7)
- return Ops[Comp & 0xF];
- return "";
+ const char * const Ops[] = {"","<=",">=","<",">","=","!="};
+ if (unlikely((unsigned)(Comp & 0xF) >= sizeof(Ops)/sizeof(Ops[0])))
+ return "";
+ return Ops[Comp & 0xF];
}
/*}}}*/
// Cache::DepType - Return a string describing the dep type /*{{{*/
@@ -625,8 +634,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
{
if (IsIgnorable(I.ParentPkg()) == true)
continue;
-
- if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
+ if (IsSatisfied(I) == false)
continue;
Size++;
@@ -639,8 +647,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
{
if (IsIgnorable(I) == true)
continue;
-
- if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
+ if (IsSatisfied(I) == false)
continue;
Size++;
@@ -748,6 +755,16 @@ bool pkgCache::DepIterator::IsMultiArchImplicit() const
return false;
}
/*}}}*/
+// DepIterator::IsSatisfied - check if a version satisfied the dependency /*{{{*/
+bool pkgCache::DepIterator::IsSatisfied(VerIterator const &Ver) const
+{
+ return Owner->VS->CheckDep(Ver.VerStr(),S->CompareOp,TargetVer());
+}
+bool pkgCache::DepIterator::IsSatisfied(PrvIterator const &Prv) const
+{
+ return Owner->VS->CheckDep(Prv.ProvideVersion(),S->CompareOp,TargetVer());
+}
+ /*}}}*/
// ostream operator to handle string representation of a dependecy /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 373f6625c..3f10b6c40 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -300,36 +300,35 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator
for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
- pkgCache::DescIterator Desc = Ver.DescriptionList();
+ pkgCache::DescIterator VerDesc = Ver.DescriptionList();
// a version can only have one md5 describing it
- if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
+ if (VerDesc.end() == true || MD5SumValue(VerDesc.md5()) != CurMd5)
continue;
// don't add a new description if we have one for the given
// md5 && language
- if (IsDuplicateDescription(Desc, CurMd5, CurLang) == true)
+ if (IsDuplicateDescription(VerDesc, CurMd5, CurLang) == true)
continue;
+ pkgCache::DescIterator Desc;
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
- // we add at the end, so that the start is constant as we need
- // that to be able to efficiently share these lists
- map_ptrloc *LastDesc = &Ver->DescriptionList;
- for (;Desc.end() == false && Desc->NextDesc != 0; ++Desc);
- if (Desc.end() == false)
- LastDesc = &Desc->NextDesc;
- void const * const oldMap = Map.Data();
- map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+ map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, VerDesc->md5sum);
if (unlikely(descindex == 0 && _error->PendingError()))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewDescription", 1);
- if (oldMap != Map.Data())
- LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
- *LastDesc = descindex;
+
Desc->ParentPkg = Pkg.Index();
- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+ // we add at the end, so that the start is constant as we need
+ // that to be able to efficiently share these lists
+ VerDesc = Ver.DescriptionList(); // old value might be invalid after ReMap
+ for (;VerDesc.end() == false && VerDesc->NextDesc != 0; ++VerDesc);
+ map_ptrloc * const LastNextDesc = (VerDesc.end() == true) ? &Ver->DescriptionList : &VerDesc->NextDesc;
+ *LastNextDesc = descindex;
+
+ if (NewFileDesc(Desc,List) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewFileDesc", 1);
@@ -391,7 +390,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
}
// Add a new version
- map_ptrloc const verindex = NewVersion(Ver,Version,*LastVer);
+ map_ptrloc const verindex = NewVersion(Ver, Version, Pkg.Index(), Hash, *LastVer);
if (verindex == 0 && _error->PendingError())
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewVersion", 1);
@@ -399,8 +398,6 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
if (oldMap != Map.Data())
LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
*LastVer = verindex;
- Ver->ParentPkg = Pkg.Index();
- Ver->Hash = Hash;
if (unlikely(List.NewVersion(Ver) == false))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
@@ -464,11 +461,8 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
pkgCache::VerIterator ConVersion = D.ParentVer();
Dynamic<pkgCache::VerIterator> DynV(ConVersion);
// duplicate the Conflicts/Breaks/Replaces for :none arch
- if (D->Version == 0)
- NewDepends(Pkg, ConVersion, "", 0, D->Type, OldDepLast);
- else
- NewDepends(Pkg, ConVersion, D.TargetVer(),
- D->CompareOp, D->Type, OldDepLast);
+ NewDepends(Pkg, ConVersion, D->Version,
+ D->CompareOp, D->Type, OldDepLast);
}
}
}
@@ -509,19 +503,16 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
// We haven't found reusable descriptions, so add the first description
pkgCache::DescIterator Desc = Ver.DescriptionList();
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
- map_ptrloc *LastDesc = &Ver->DescriptionList;
- oldMap = Map.Data();
- map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+ map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, 0);
if (unlikely(descindex == 0 && _error->PendingError()))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewDescription", 2);
- if (oldMap != Map.Data())
- LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
- *LastDesc = descindex;
+
Desc->ParentPkg = Pkg.Index();
+ Ver->DescriptionList = descindex;
- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+ if (NewFileDesc(Desc,List) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewFileDesc", 2);
@@ -564,7 +555,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
Dynamic<pkgCache::VerIterator> DynVer(Ver);
for (; Ver.end() == false; ++Ver)
{
- if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr())
+ if (Ver->Hash == Hash && Version == Ver.VerStr())
{
if (List.CollectFileProvides(Cache,Ver) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
@@ -602,8 +593,11 @@ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name)
// Insert it into the hash table
unsigned long const Hash = Cache.Hash(Name);
- Grp->Next = Cache.HeaderP->GrpHashTable[Hash];
- Cache.HeaderP->GrpHashTable[Hash] = Group;
+ map_ptrloc *insertAt = &Cache.HeaderP->GrpHashTable[Hash];
+ while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.GrpP + *insertAt)->Name) > 0)
+ insertAt = &(Cache.GrpP + *insertAt)->Next;
+ Grp->Next = *insertAt;
+ *insertAt = Group;
Grp->ID = Cache.HeaderP->GroupCount++;
return true;
@@ -632,11 +626,14 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
// Insert the package into our package list
if (Grp->FirstPackage == 0) // the group is new
{
+ Grp->FirstPackage = Package;
// Insert it into the hash table
unsigned long const Hash = Cache.Hash(Name);
- Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
- Cache.HeaderP->PkgHashTable[Hash] = Package;
- Grp->FirstPackage = Package;
+ map_ptrloc *insertAt = &Cache.HeaderP->PkgHashTable[Hash];
+ while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.PkgP + *insertAt)->Name) > 0)
+ insertAt = &(Cache.PkgP + *insertAt)->NextPackage;
+ Pkg->NextPackage = *insertAt;
+ *insertAt = Package;
}
else // Group the Packages together
{
@@ -675,6 +672,7 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G,
bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
pkgCache::PkgIterator D = G.PackageList();
Dynamic<pkgCache::PkgIterator> DynD(D);
+ map_ptrloc const VerStrIdx = V->VerStr;
for (; D.end() != true; D = G.NextPkg(D))
{
if (Arch == D.Arch() || D->VersionList == 0)
@@ -685,16 +683,16 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G,
if (coInstall == true)
{
// Replaces: ${self}:other ( << ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::Less, pkgCache::Dep::Replaces,
OldDepLast);
// Breaks: ${self}:other (!= ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
OldDepLast);
} else {
// Conflicts: ${self}:other
- NewDepends(D, V, "",
+ NewDepends(D, V, 0,
pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
OldDepLast);
}
@@ -711,17 +709,18 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::VerIterator &V,
bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
if (coInstall == true)
{
+ map_ptrloc const VerStrIdx = V->VerStr;
// Replaces: ${self}:other ( << ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::Less, pkgCache::Dep::Replaces,
OldDepLast);
// Breaks: ${self}:other (!= ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
OldDepLast);
} else {
// Conflicts: ${self}:other
- NewDepends(D, V, "",
+ NewDepends(D, V, 0,
pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
OldDepLast);
}
@@ -767,6 +766,8 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
/* This puts a version structure in the linked list */
unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
const string &VerStr,
+ map_ptrloc const ParentPkg,
+ unsigned long const Hash,
unsigned long Next)
{
// Get a structure
@@ -778,12 +779,37 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
//Dynamic<pkgCache::VerIterator> DynV(Ver); // caller MergeListVersion already takes care of it
Ver->NextVer = Next;
+ Ver->ParentPkg = ParentPkg;
+ Ver->Hash = Hash;
Ver->ID = Cache.HeaderP->VersionCount++;
+
+ // try to find the version string in the group for reuse
+ pkgCache::PkgIterator Pkg = Ver.ParentPkg();
+ pkgCache::GrpIterator Grp = Pkg.Group();
+ if (Pkg.end() == false && Grp.end() == false)
+ {
+ for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P))
+ {
+ if (Pkg == P)
+ continue;
+ for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
+ {
+ int const cmp = strcmp(V.VerStr(), VerStr.c_str());
+ if (cmp == 0)
+ {
+ Ver->VerStr = V->VerStr;
+ return Version;
+ }
+ else if (cmp < 0)
+ break;
+ }
+ }
+ }
+ // haven't found the version string, so create
map_ptrloc const idxVerStr = WriteStringInMap(VerStr);
if (unlikely(idxVerStr == 0))
return 0;
Ver->VerStr = idxVerStr;
-
return Version;
}
/*}}}*/
@@ -825,9 +851,9 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
// ---------------------------------------------------------------------
/* This puts a description structure in the linked list */
map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
- const string &Lang,
- const MD5SumValue &md5sum,
- map_ptrloc Next)
+ const string &Lang,
+ const MD5SumValue &md5sum,
+ map_ptrloc idxmd5str)
{
// Get a structure
map_ptrloc const Description = AllocateInMap(sizeof(pkgCache::Description));
@@ -836,14 +862,21 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
// Fill it in
Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
- Desc->NextDesc = Next;
Desc->ID = Cache.HeaderP->DescriptionCount++;
- map_ptrloc const idxlanguage_code = WriteStringInMap(Lang);
- map_ptrloc const idxmd5sum = WriteStringInMap(md5sum.Value());
- if (unlikely(idxlanguage_code == 0 || idxmd5sum == 0))
+ map_ptrloc const idxlanguage_code = WriteUniqString(Lang);
+ if (unlikely(idxlanguage_code == 0))
return 0;
Desc->language_code = idxlanguage_code;
- Desc->md5sum = idxmd5sum;
+
+ if (idxmd5str != 0)
+ Desc->md5sum = idxmd5str;
+ else
+ {
+ map_ptrloc const idxmd5sum = WriteStringInMap(md5sum.Value());
+ if (unlikely(idxmd5sum == 0))
+ return 0;
+ Desc->md5sum = idxmd5sum;
+ }
return Description;
}
@@ -859,34 +892,48 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
unsigned int const &Type,
map_ptrloc* &OldDepLast)
{
+ map_ptrloc index = 0;
+ if (Version.empty() == false)
+ {
+ int const CmpOp = Op & 0x0F;
+ // =-deps are used (79:1) for lockstep on same-source packages (e.g. data-packages)
+ if (CmpOp == pkgCache::Dep::Equals && strcmp(Version.c_str(), Ver.VerStr()) == 0)
+ index = Ver->VerStr;
+
+ if (index == 0)
+ {
+ void const * const oldMap = Map.Data();
+ index = WriteStringInMap(Version);
+ if (unlikely(index == 0))
+ return false;
+ if (OldDepLast != 0 && oldMap != Map.Data())
+ OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
+ }
+ }
+ return NewDepends(Pkg, Ver, index, Op, Type, OldDepLast);
+}
+bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver,
+ map_ptrloc const Version,
+ unsigned int const &Op,
+ unsigned int const &Type,
+ map_ptrloc* &OldDepLast)
+{
void const * const oldMap = Map.Data();
// Get a structure
map_ptrloc const Dependency = AllocateInMap(sizeof(pkgCache::Dependency));
if (unlikely(Dependency == 0))
return false;
-
+
// Fill it in
pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
Dynamic<pkgCache::DepIterator> DynDep(Dep);
Dep->ParentVer = Ver.Index();
Dep->Type = Type;
Dep->CompareOp = Op;
+ Dep->Version = Version;
Dep->ID = Cache.HeaderP->DependsCount++;
- // Probe the reverse dependency list for a version string that matches
- if (Version.empty() == false)
- {
-/* for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
- if (I->Version != 0 && I.TargetVer() == Version)
- Dep->Version = I->Version;*/
- if (Dep->Version == 0) {
- map_ptrloc const index = WriteStringInMap(Version);
- if (unlikely(index == 0))
- return false;
- Dep->Version = index;
- }
- }
-
// Link it to the package
Dep->Package = Pkg.Index();
Dep->NextRevDepends = Pkg->RevDepends;
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index b6259b433..428e8459b 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -77,7 +77,14 @@ class pkgCacheGenerator /*{{{*/
bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver,
std::string const &Version, unsigned int const &Op,
unsigned int const &Type, map_ptrloc* &OldDepLast);
- unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next);
+ bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver,
+ map_ptrloc const Version, unsigned int const &Op,
+ unsigned int const &Type, map_ptrloc* &OldDepLast);
+ __deprecated unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next)
+ { return NewVersion(Ver, VerStr, 0, 0, Next); }
+ unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,
+ map_ptrloc const ParentPkg, unsigned long const Hash,
+ unsigned long Next);
map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const std::string &Lang,const MD5SumValue &md5sum,map_ptrloc Next);
public:
diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc
index d63d2c422..297559957 100644
--- a/apt-pkg/srcrecords.cc
+++ b/apt-pkg/srcrecords.cc
@@ -42,7 +42,7 @@ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : d(NULL), Files(0), Current(0
}
// Doesn't work without any source index files
- if (Files.size() == 0)
+ if (Files.empty() == true)
{
_error->Error(_("You must put some 'source' URIs"
" in your sources.list"));
@@ -121,14 +121,13 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn
/* */
const char *pkgSrcRecords::Parser::BuildDepType(unsigned char const &Type)
{
- const char *fields[] = {"Build-Depends",
- "Build-Depends-Indep",
+ const char *fields[] = {"Build-Depends",
+ "Build-Depends-Indep",
"Build-Conflicts",
"Build-Conflicts-Indep"};
- if (Type < 4)
- return fields[Type];
- else
+ if (unlikely(Type >= sizeof(fields)/sizeof(fields[0])))
return "";
+ return fields[Type];
}
/*}}}*/
diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc
index 36fc25957..fc03ec845 100644
--- a/apt-pkg/vendor.cc
+++ b/apt-pkg/vendor.cc
@@ -12,7 +12,7 @@ Vendor::Vendor(std::string VendorID,
this->VendorID = VendorID;
this->Origin = Origin;
for (std::vector<struct Vendor::Fingerprint *>::iterator I = FingerprintList->begin();
- I != FingerprintList->end(); I++)
+ I != FingerprintList->end(); ++I)
{
if (_config->FindB("Debug::Vendor", false))
std::cerr << "Vendor \"" << VendorID << "\": Mapping \""
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc
index e4fa0ea65..26262a010 100644
--- a/apt-pkg/versionmatch.cc
+++ b/apt-pkg/versionmatch.cc
@@ -181,9 +181,9 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg)
bool pkgVersionMatch::ExpressionMatches(const char *pattern, const char *string)
{
if (pattern[0] == '/') {
- bool res = false;
size_t length = strlen(pattern);
if (pattern[length - 1] == '/') {
+ bool res = false;
regex_t preg;
char *regex = strdup(pattern + 1);
regex[length - 2] = '\0';