X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b2e465d6d32d2dc884f58b94acb7e35f671a87fe..b4e57d2dd44728929cb83113ed79c8e16405767e:/apt-pkg/versionmatch.cc diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 45cdb117e..9e341852b 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: versionmatch.cc,v 1.2 2001/02/20 07:03:17 jgg Exp $ +// $Id: versionmatch.cc,v 1.9 2003/05/19 17:58:26 doogie Exp $ /* ###################################################################### Version Matching @@ -20,6 +20,7 @@ #include #include +#include /*}}}*/ // VersionMatch::pkgVersionMatch - Constructor /*{{{*/ @@ -27,6 +28,10 @@ /* Break up the data string according to the selected type */ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) { + MatchAll = false; + VerPrefixMatch = false; + RelVerPrefixMatch = false; + if (Type == None || Data.length() < 1) return; @@ -36,7 +41,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) if (Data.end()[-1] == '*') { VerPrefixMatch = true; - VerStr = string(Data.begin(),Data.end()-1); + VerStr = string(Data,0,Data.length()-1); } else VerStr = Data; @@ -47,11 +52,14 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) { // All empty = match all if (Data == "*") + { + MatchAll = true; return; + } // Are we a simple specification? - const char *I = Data.begin(); - for (; I < Data.end() && *I != '='; I++); + string::const_iterator I = Data.begin(); + for (; I != Data.end() && *I != '='; I++); if (I == Data.end()) { // Temporary @@ -60,7 +68,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) else RelArchive = Data; - if (RelVerStr.end()[-1] == '*') + if (RelVerStr.length() > 0 && RelVerStr.end()[-1] == '*') { RelVerPrefixMatch = true; RelVerStr = string(RelVerStr.begin(),RelVerStr.end()-1); @@ -124,8 +132,7 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) return false; // Match (leading?) - if (stringcasecmp(B.begin(),B.end(), - Ab,Ab + B.length()) == 0) + if (stringcasecmp(B,Ab,Ab + B.length()) == 0) return true; return false; @@ -163,9 +170,12 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) { if (Type == Release) { + if (MatchAll == true) + return true; + /* cout << RelVerStr << ',' << RelOrigin << ',' << RelArchive << ',' << RelLabel << endl; - cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl; -*/ + cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl;*/ + if (RelVerStr.empty() == true && RelOrigin.empty() == true && RelArchive.empty() == true && RelLabel.empty() == true && RelComponent.empty() == true) @@ -191,18 +201,20 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) return false; if (RelComponent.empty() == false) if (File->Component == 0 || - stringcasecmp(RelLabel,File.Component()) != 0) + stringcasecmp(RelComponent,File.Component()) != 0) return false; return true; } if (Type == Origin) { - if (OrSite.empty() == false) - if (File->Site == 0 || - OrSite != File.Site()) + if (OrSite.empty() == false) { + if (File->Site == 0 || OrSite != File.Site()) return false; - return true; + } else // so we are talking about file:// or status file + if (strcmp(File.Site(),"") == 0 && File->Archive != 0) // skip the status file + return false; + return (OrSite == File.Site()); /* both strings match */ } return false;