X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/acfe730660b33aa49f97740688c26e3725e1994c..0fd68707605f42741574304e5d51582fe298a4b0:/apt-pkg/versionmatch.cc diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 9e341852b..b4d1d4696 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -11,9 +11,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/versionmatch.h" -#endif #include #include @@ -66,8 +63,8 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) if (isdigit(Data[0])) RelVerStr = Data; else - RelArchive = Data; - + RelRelease = Data; + if (RelVerStr.length() > 0 && RelVerStr.end()[-1] == '*') { RelVerPrefixMatch = true; @@ -90,19 +87,21 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) { if (strlen(Fragments[J]) < 3) continue; - + if (stringcasecmp(Fragments[J],Fragments[J]+2,"v=") == 0) RelVerStr = Fragments[J]+2; else if (stringcasecmp(Fragments[J],Fragments[J]+2,"o=") == 0) RelOrigin = Fragments[J]+2; else if (stringcasecmp(Fragments[J],Fragments[J]+2,"a=") == 0) RelArchive = Fragments[J]+2; + else if (stringcasecmp(Fragments[J],Fragments[J]+2,"n=") == 0) + RelCodename = Fragments[J]+2; else if (stringcasecmp(Fragments[J],Fragments[J]+2,"l=") == 0) RelLabel = Fragments[J]+2; else if (stringcasecmp(Fragments[J],Fragments[J]+2,"c=") == 0) RelComponent = Fragments[J]+2; } - + if (RelVerStr.end()[-1] == '*') { RelVerPrefixMatch = true; @@ -127,7 +126,7 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) const char *Ae = Ab + strlen(A); // Strings are not a compatible size. - if ((unsigned)(Ae - Ab) != B.length() && Prefix == false || + if (((unsigned)(Ae - Ab) != B.length() && Prefix == false) || (unsigned)(Ae - Ab) < B.length()) return false; @@ -172,15 +171,16 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) { if (MatchAll == true) return true; - + /* cout << RelVerStr << ',' << RelOrigin << ',' << RelArchive << ',' << RelLabel << endl; cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl;*/ - + if (RelVerStr.empty() == true && RelOrigin.empty() == true && RelArchive.empty() == true && RelLabel.empty() == true && + RelRelease.empty() == true && RelCodename.empty() == true && RelComponent.empty() == true) return false; - + if (RelVerStr.empty() == false) if (File->Version == 0 || MatchVer(File.Version(),RelVerStr,RelVerPrefixMatch) == false) @@ -190,11 +190,19 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) stringcasecmp(RelOrigin,File.Origin()) != 0) return false; if (RelArchive.empty() == false) - { - if (File->Archive == 0 || + if (File->Archive == 0 || stringcasecmp(RelArchive,File.Archive()) != 0) - return false; - } + return false; + if (RelCodename.empty() == false) + if (File->Codename == 0 || + stringcasecmp(RelCodename,File.Codename()) != 0) + return false; + if (RelRelease.empty() == false) + if ((File->Archive == 0 || + stringcasecmp(RelRelease,File.Archive()) != 0) && + (File->Codename == 0 || + stringcasecmp(RelRelease,File.Codename()) != 0)) + return false; if (RelLabel.empty() == false) if (File->Label == 0 || stringcasecmp(RelLabel,File.Label()) != 0) @@ -205,7 +213,7 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) return false; return true; } - + if (Type == Origin) { if (OrSite.empty() == false) { @@ -216,7 +224,7 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) return false; return (OrSite == File.Site()); /* both strings match */ } - + return false; } /*}}}*/