summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-10-30 13:48:05 -0500
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-10-30 13:48:05 -0500
commit89d88ac3ef3f82fdfeac6d8d231deddeeb0f02e9 (patch)
tree258687a5f0984f0b4edd24b52d778cf4d21c7059 /apt-pkg
parentcd5e84440a9bb75a9cc2c142ac8bc214ba57685a (diff)
parent0a64ecd792b4caca519d597a69b8baeda6a1bf77 (diff)
merge with my debian-sid branch
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/strutl.cc15
-rw-r--r--apt-pkg/deb/deblistparser.cc21
-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/policy.cc3
-rw-r--r--apt-pkg/sourcelist.cc2
10 files changed, 59 insertions, 70 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/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..fd3e4808d 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;
@@ -797,21 +797,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/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);