diff --git a/src/prtget.cpp b/src/prtget.cpp index 6095607..c2c7558 100644 --- a/src/prtget.cpp +++ b/src/prtget.cpp @@ -926,7 +926,7 @@ void PrtGet::printDiff() const map& installed = m_pkgDB->installedPackages(); map::const_iterator it = installed.begin(); const Package* p = 0; - int count = 0; + size_t count = 0; COMP_RESULT result; for ( ; it != installed.end(); ++it ) { @@ -1941,28 +1941,28 @@ void PrtGet::remove() } -void PrtGet::assertMaxArgCount(int count) +void PrtGet::assertMaxArgCount(size_t count) { if ( m_parser->otherArgs().size() > count ) { argCountFailure(count, "at most"); } } -void PrtGet::assertExactArgCount(int count) +void PrtGet::assertExactArgCount(size_t count) { if ( m_parser->otherArgs().size() != count ) { argCountFailure(count, "exactly"); } } -void PrtGet::assertMinArgCount(int count) +void PrtGet::assertMinArgCount(size_t count) { if ( m_parser->otherArgs().size() < count ) { argCountFailure(count, "at least"); } } -void PrtGet::argCountFailure(int count, const string& specifier) +void PrtGet::argCountFailure(size_t count, const string& specifier) { cerr << m_appName << " " << m_parser->commandName() << " takes " << specifier << " " diff --git a/src/prtget.h b/src/prtget.h index 6a82975..8e5ad1f 100644 --- a/src/prtget.h +++ b/src/prtget.h @@ -146,10 +146,10 @@ protected: static const string DEFAULT_CACHE_FILE; - void assertMinArgCount(int count); - void assertMaxArgCount(int count); - void assertExactArgCount(int count); - void argCountFailure(int count, const string& specifier); + void assertMinArgCount(size_t count); + void assertMaxArgCount(size_t count); + void assertExactArgCount(size_t count); + void argCountFailure(size_t count, const string& specifier); VersionComparator::COMP_RESULT compareVersions( const string& v1, const string& v2 ); diff --git a/src/stringhelper.cpp b/src/stringhelper.cpp index 2b25d3f..2b4f783 100644 --- a/src/stringhelper.cpp +++ b/src/stringhelper.cpp @@ -58,18 +58,18 @@ string stripWhiteSpace( const string& s ) return s; } - int pos = 0; + size_t pos = 0; string line = s; - string::size_type len = line.length(); + size_t len = line.length(); while ( pos < len && isspace( line[pos] ) ) { ++pos; } line.erase( 0, pos ); pos = line.length()-1; - while ( pos > -1 && isspace( line[pos] ) ) { + while ( pos != (size_t) -1 && isspace( line[pos] ) ) { --pos; } - if ( pos != -1 ) { + if ( pos != (size_t) -1 ) { line.erase( pos+1 ); } return line; diff --git a/src/versioncomparator.cpp b/src/versioncomparator.cpp index 6116a97..b337ddf 100644 --- a/src/versioncomparator.cpp +++ b/src/versioncomparator.cpp @@ -39,16 +39,16 @@ COMP_RESULT compareVersions(const string& v1, const string& v2) tokenizeIntoBlocks(v1, blocks1); tokenizeIntoBlocks(v2, blocks2); - int blockLen = normalizeVectors(blocks1, blocks2); + size_t blockLen = normalizeVectors(blocks1, blocks2); - for (int i = 0; i < blockLen; ++i) { + for (size_t i = 0; i < blockLen; ++i) { vector tokens1; vector tokens2; split(blocks1[i], '.', tokens1); split(blocks2[i], '.', tokens2); - int tokLen = normalizeVectors(tokens1, tokens2); + size_t tokLen = normalizeVectors(tokens1, tokens2); - for (int j = 0; j < tokLen; ++j) { + for (size_t j = 0; j < tokLen; ++j) { if (tokens1[j] == tokens2[j]) { continue; } @@ -67,8 +67,8 @@ COMP_RESULT compareVersions(const string& v1, const string& v2) tokenizeMixed(tokens1[j], subtokens1); tokenizeMixed(tokens2[j], subtokens2); - int subTokLen = normalizeVectors(subtokens1, subtokens2); - for (int k = 0; k < subTokLen; ++k) { + size_t subTokLen = normalizeVectors(subtokens1, subtokens2); + for (size_t k = 0; k < subTokLen; ++k) { long sl1 = strtol(subtokens1[k].c_str(), &error1, 10); long sl2 = strtol(subtokens2[k].c_str(), &error2, 10); if (*error1 == 0 && *error2 == 0) { @@ -123,9 +123,9 @@ COMP_RESULT compareVersions(const string& v1, const string& v2) return EQUAL; } -int normalizeVectors(vector& v1, vector& v2) +size_t normalizeVectors(vector& v1, vector& v2) { - int length = max(v1.size(), v2.size()); + size_t length = max(v1.size(), v2.size()); while (v1.size() < length) { v1.push_back("-1"); @@ -140,14 +140,14 @@ int normalizeVectors(vector& v1, vector& v2) void tokenizeMixed(const string& s, vector& tokens) { vector digitMask; - for (int i = 0; i < s.length(); ++i) { + for (size_t i = 0; i < s.length(); ++i) { digitMask.push_back(isdigit(s[i])); } bool state = digitMask[0]; string tok; tok = s[0]; - for (int i = 1; i < digitMask.size(); ++i) { + for (size_t i = 1; i < digitMask.size(); ++i) { if (digitMask[i] != state) { tokens.push_back(tok); tok = s[i]; diff --git a/src/versioncomparator.h b/src/versioncomparator.h index 767b148..bdda33c 100644 --- a/src/versioncomparator.h +++ b/src/versioncomparator.h @@ -19,7 +19,7 @@ enum COMP_RESULT { LESS, GREATER, EQUAL, UNDEFINED }; COMP_RESULT compareVersions(const string& v1, const string& v2) ; void tokenizeIntoBlocks(const string& version, vector& blocks); -int normalizeVectors(vector& v1, vector& v2); +size_t normalizeVectors(vector& v1, vector& v2); void tokenizeMixed(const string& s, vector& tokens); }