summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-11-10 16:10:55 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-11-10 16:10:55 +0100
commit37adedc9d0b66eeae7efb88aebd08dfbc6e06f77 (patch)
treeb0769df88e2b6496f23e3d899aeb1c240a3488d9 /apt-pkg
parentcf4f17a9d87a36b20ef5afa2cb5145e466d8ad3b (diff)
parent04340db392f14e2610189db6f8787e10fbf3c6d0 (diff)
merged from lp:~donkult/apt/experimental
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-method.cc10
-rw-r--r--apt-pkg/algorithms.cc11
-rw-r--r--apt-pkg/contrib/cmndline.cc28
-rw-r--r--apt-pkg/contrib/sha2_internal.cc16
-rw-r--r--apt-pkg/contrib/strutl.cc15
-rw-r--r--apt-pkg/deb/deblistparser.cc24
-rw-r--r--apt-pkg/deb/debversion.cc25
-rw-r--r--apt-pkg/deb/dpkgpm.cc1
-rw-r--r--apt-pkg/init.cc13
-rw-r--r--apt-pkg/packagemanager.cc29
-rw-r--r--apt-pkg/policy.cc3
-rw-r--r--apt-pkg/sourcelist.cc2
12 files changed, 92 insertions, 85 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 1ae139b40..2041fd9e9 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -291,12 +291,12 @@ bool pkgAcqMethod::Configuration(string Message)
I += Length + 1;
for (; I < MsgEnd && *I == ' '; I++);
- const char *Equals = I;
- for (; Equals < MsgEnd && *Equals != '='; Equals++);
- const char *End = Equals;
- for (; End < MsgEnd && *End != '\n'; End++);
- if (End == Equals)
+ const char *Equals = (const char*) memchr(I, '=', MsgEnd - I);
+ if (Equals == NULL)
return false;
+ const char *End = (const char*) memchr(Equals, '\n', MsgEnd - Equals);
+ if (End == NULL)
+ End = MsgEnd;
Cnf.Set(DeQuoteString(string(I,Equals-I)),
DeQuoteString(string(Equals+1,End-Equals-1)));
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 4c2ea0f2d..f7a333606 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1220,16 +1220,23 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
*/
bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
{
-
// a broken install is always a problem
if (Cache[I].InstBroken() == true)
+ {
+ if (Debug == true)
+ std::clog << " Dependencies are not satisfied for " << I << std::endl;
return true;
+ }
// a newly broken policy (recommends/suggests) is a problem
if (Cache[I].NowPolicyBroken() == false &&
Cache[I].InstPolicyBroken() == true)
+ {
+ if (Debug == true)
+ std::clog << " Policy breaks with upgrade of " << I << std::endl;
return true;
-
+ }
+
return false;
}
/*}}}*/
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 997f26bc7..159f330a1 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -90,9 +90,8 @@ bool CommandLine::Parse(int argc,const char **argv)
Opt++;
// Match up to a = against the list
- const char *OptEnd = Opt;
Args *A;
- for (; *OptEnd != 0 && *OptEnd != '='; OptEnd++);
+ const char *OptEnd = strchrnul(Opt, '=');
for (A = ArgList; A->end() == false &&
stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
@@ -100,9 +99,8 @@ bool CommandLine::Parse(int argc,const char **argv)
bool PreceedMatch = false;
if (A->end() == true)
{
- for (; Opt != OptEnd && *Opt != '-'; Opt++);
-
- if (Opt == OptEnd)
+ Opt = (const char*) memchr(Opt, '-', OptEnd - Opt);
+ if (Opt == NULL)
return _error->Error(_("Command line option %s is not understood"),argv[I]);
Opt++;
@@ -197,9 +195,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Arbitrary item specification
if ((A->Flags & ArbItem) == ArbItem)
{
- const char *J;
- for (J = Argument; *J != 0 && *J != '='; J++);
- if (*J == 0)
+ const char *J = strchr(Argument, '=');
+ if (J == NULL)
return _error->Error(_("Option %s: Configuration item specification must have an =<val>."),argv[I]);
// = is trailing
@@ -215,8 +212,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
return true;
}
- const char *I = A->ConfName;
- for (; *I != 0 && *I != ' '; I++);
+ const char *I = strchrnul(A->ConfName, ' ');
if (*I == ' ')
Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument);
else
@@ -272,10 +268,9 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Skip the leading dash
const char *J = argv[I];
for (; *J != 0 && *J == '-'; J++);
-
- const char *JEnd = J;
- for (; *JEnd != 0 && *JEnd != '-'; JEnd++);
- if (*JEnd != 0)
+
+ const char *JEnd = strchr(J, '-');
+ if (JEnd != NULL)
{
strncpy(Buffer,J,JEnd - J);
Buffer[JEnd - J] = 0;
@@ -376,9 +371,8 @@ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * co
{
// That is possibly an option: Quote it if it includes spaces,
// the benefit is that this will eliminate also most false positives
- const char* c = &argv[i][j+1];
- for (; *c != '\0' && *c != ' '; ++c);
- if (*c == '\0') continue;
+ const char* c = strchr(&argv[i][j+1], ' ');
+ if (c == NULL) continue;
cmdline[++length] = '"';
closeQuote = true;
}
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index ff995cdf2..6d27e8f2b 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/apt-pkg/contrib/sha2_internal.cc
@@ -605,7 +605,12 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80;
}
/* Set the bit count: */
- *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+ union {
+ sha2_byte* c;
+ sha2_word64* l;
+ } bitcount;
+ bitcount.c = &context->buffer[SHA256_SHORT_BLOCK_LENGTH];
+ *(bitcount.l) = context->bitcount;
/* Final transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -922,8 +927,13 @@ static void SHA512_Last(SHA512_CTX* context) {
*context->buffer = 0x80;
}
/* Store the length of input data (in bits): */
- *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
- *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+ union {
+ sha2_byte* c;
+ sha2_word64* l;
+ } bitcount;
+ bitcount.c = &context->buffer[SHA512_SHORT_BLOCK_LENGTH];
+ bitcount.l[0] = context->bitcount[1];
+ bitcount.l[1] = context->bitcount[0];
/* Final transform: */
SHA512_Transform(context, (sha2_word64*)context->buffer);
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index aaf44b7ff..861cdcbeb 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -179,14 +179,14 @@ bool ParseQuoteWord(const char *&String,string &Res)
{
if (*C == '"')
{
- for (C++; *C != 0 && *C != '"'; C++);
- if (*C == 0)
+ C = strchr(C + 1, '"');
+ if (C == NULL)
return false;
}
if (*C == '[')
{
- for (C++; *C != 0 && *C != ']'; C++);
- if (*C == 0)
+ C = strchr(C + 1, ']');
+ if (C == NULL)
return false;
}
}
@@ -904,11 +904,10 @@ bool StrToTime(const string &Val,time_t &Result)
{
struct tm Tm;
char Month[10];
- const char *I = Val.c_str();
-
+
// Skip the day of the week
- for (;*I != 0 && *I != ' '; I++);
-
+ const char *I = strchr(Val.c_str(), ' ');
+
// Handle RFC 1123 time
Month[0] = 0;
if (sscanf(I," %d %3s %d %d:%d:%d GMT",&Tm.tm_mday,Month,&Tm.tm_year,
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index a36857cb5..28568d5e3 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -522,9 +522,9 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// Skip whitespace
for (;I != Stop && isspace(*I) != 0; I++);
Start = I;
- for (;I != Stop && *I != ')'; I++);
- if (I == Stop || Start == I)
- return 0;
+ I = (const char*) memchr(I, ')', Stop - I);
+ if (I == NULL || Start == I)
+ return 0;
// Skip trailing whitespace
const char *End = I;
@@ -675,6 +675,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
return _error->Error("Problem parsing Provides line");
if (Op != pkgCache::Dep::NoOp) {
_error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+ } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
+ if (NewProvidesAllArch(Ver, Package, Version) == false)
+ return false;
} else {
if (NewProvides(Ver, Package, Arch, Version) == false)
return false;
@@ -797,21 +800,16 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
}
// seperate the tag from the data
- for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
- /* nothing */
- ;
- if (buffer[len] == '\0')
+ const char* dataStart = strchr(buffer + len, ':');
+ if (dataStart == NULL)
continue;
- char* dataStart = buffer + len;
+ len = dataStart - buffer;
for (++dataStart; *dataStart == ' '; ++dataStart)
/* nothing */
;
- char* dataEnd = dataStart;
- for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
- /* nothing */
- ;
+ const char* dataEnd = (const char*)rawmemchr(dataStart, '\0');
// The last char should be a newline, but we can never be sure: #633350
- char* lineEnd = dataEnd;
+ const char* lineEnd = dataEnd;
for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
/* nothing */
;
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index bc9e13d92..a02699a44 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -127,14 +127,12 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
const char *B,const char *BEnd)
{
- // Strip off the epoch and compare it
- const char *lhs = A;
- const char *rhs = B;
- for (;lhs != AEnd && *lhs != ':'; lhs++);
- for (;rhs != BEnd && *rhs != ':'; rhs++);
- if (lhs == AEnd)
+ // Strip off the epoch and compare it
+ const char *lhs = (const char*) memchr(A, ':', AEnd - A);
+ const char *rhs = (const char*) memchr(B, ':', BEnd - B);
+ if (lhs == NULL)
lhs = A;
- if (rhs == BEnd)
+ if (rhs == NULL)
rhs = B;
// Special case: a zero epoch is the same as no epoch,
@@ -169,15 +167,12 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
if (rhs != B)
rhs++;
- // Find the last -
- const char *dlhs = AEnd-1;
- const char *drhs = BEnd-1;
- for (;dlhs > lhs && *dlhs != '-'; dlhs--);
- for (;drhs > rhs && *drhs != '-'; drhs--);
-
- if (dlhs == lhs)
+ // Find the last -
+ const char *dlhs = (const char*) memrchr(lhs, '-', AEnd - lhs);
+ const char *drhs = (const char*) memrchr(rhs, '-', BEnd - rhs);
+ if (dlhs == NULL)
dlhs = AEnd;
- if (drhs == rhs)
+ if (drhs == NULL)
drhs = BEnd;
// Compare the main version
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 5eb6406c6..7c0ed5639 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -983,7 +983,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
char status_fd_buf[20];
snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]);
ADDARG(status_fd_buf);
-
unsigned long const Op = I->Op;
switch (I->Op)
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 2a709dd36..a1c47c030 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -86,13 +86,12 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Dir::Log::Terminal","term.log");
Cnf.CndSet("Dir::Log::History","history.log");
- if (Cnf.Exists("Dir::Ignore-Files-Silently") == false)
- {
- Cnf.Set("Dir::Ignore-Files-Silently::", "~$");
- Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$");
- Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$");
- Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$");
- }
+ Cnf.Set("Dir::Ignore-Files-Silently::", "~$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.orig$");
// Default cdrom mount point
Cnf.CndSet("Acquire::cdrom::mount", "/media/cdrom/");
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index a97ce4833..4f9762701 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -404,22 +404,27 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
/* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */
if (InstallVer != 0 && Bad) {
- Bad = false;
- if (List->IsNow(DepPkg) && !List->IsFlag(DepPkg,pkgOrderList::Loop)) {
- List->Flag(Pkg,pkgOrderList::Loop);
- if (Debug)
- cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.Name() << " to avoid loop" << endl;
- SmartUnPack(DepPkg, true, Depth + 1);
- List->RmFlag(Pkg,pkgOrderList::Loop);
+ if (List->IsNow(DepPkg)) {
+ Bad = false;
+ if (List->IsFlag(Pkg,pkgOrderList::Loop))
+ {
+ if (Debug)
+ std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure" << std::endl;
+ }
+ else
+ {
+ List->Flag(Pkg,pkgOrderList::Loop);
+ if (Debug)
+ cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.Name() << " to avoid loop" << endl;
+ SmartUnPack(DepPkg, true, Depth + 1);
+ List->RmFlag(Pkg,pkgOrderList::Loop);
+ }
}
}
if (Start==End) {
- if (Bad && Debug) {
- if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
- _error->Warning("Could not satisfy dependancies for %s",Pkg.Name());
- }
- }
+ if (Bad && Debug && List->IsFlag(DepPkg,pkgOrderList::Loop) == false)
+ std::clog << OutputInDepth(Depth) << "Could not satisfy dependancies for " << Pkg.Name() << std::endl;
break;
} else {
Start++;
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index e6c44ebe2..b47dab90c 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -66,7 +66,8 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner)
{
if ((F->Archive != 0 && vm.ExpressionMatches(DefRel, F.Archive()) == true) ||
(F->Codename != 0 && vm.ExpressionMatches(DefRel, F.Codename()) == true) ||
- (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true))
+ (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true) ||
+ (DefRel.length() > 2 && DefRel[1] == '='))
found = true;
}
if (found == false)
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 46025fc74..f5f458099 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -270,7 +270,7 @@ bool pkgSourceList::ReadAppend(string File)
// CNC:2003-02-20 - Do not break if '#' is inside [].
for (I = Buffer; *I != 0 && *I != '#'; I++)
if (*I == '[')
- for (I++; *I != 0 && *I != ']'; I++);
+ I = strchr(I + 1, ']');
*I = 0;
const char *C = _strstrip(Buffer);