From 5bfd306ee16fd1be012dd2cd01ae52ff4179176a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 10 Aug 2015 11:19:11 +0200 Subject: versionmatch: Extract version match checking out of Find() Refactor version matching to allow us to check if a version matches a pin. This will aid the per-version pinning implementation. --- apt-pkg/versionmatch.cc | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'apt-pkg/versionmatch.cc') diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 86c1b7d4a..c215f522c 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -164,25 +164,37 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) pkgCache::VerIterator Ver = Pkg.VersionList(); for (; Ver.end() == false; ++Ver) { - if (Type == Version) - { - if (MatchVer(Ver.VerStr(),VerStr,VerPrefixMatch) == true) - return Ver; - if (ExpressionMatches(VerStr, Ver.VerStr()) == true) - return Ver; - continue; - } - - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) - if (FileMatch(VF.File()) == true) - return Ver; + if (VersionMatches(Ver)) + return Ver; } - + // This will be Ended by now. return Ver; } /*}}}*/ +// VersionMatch::Find - Locate the best match for the select type /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgVersionMatch::VersionMatches(pkgCache::VerIterator Ver) +{ + if (Type == Version) + { + if (MatchVer(Ver.VerStr(),VerStr,VerPrefixMatch) == true) + return true; + if (ExpressionMatches(VerStr, Ver.VerStr()) == true) + return true; + return false; + } + + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) + if (FileMatch(VF.File()) == true) + return true; + + return false; +} + /*}}}*/ + #ifndef FNM_CASEFOLD #define FNM_CASEFOLD 0 #endif -- cgit v1.2.3-70-g09d2