From 404528bd581a4d2fa3bae1834d6fde48c6153434 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 21 Sep 2011 18:42:08 +0200 Subject: convert a few for-loop char finds to proper strchr and memchr --- apt-pkg/deb/deblistparser.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 8d3f6f0ba..0562be44c 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -525,9 +525,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; @@ -800,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 */ ; -- cgit v1.2.3