]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheset.cc
Merge branch 'debian/sid' into debian/experimental
[apt.git] / apt-pkg / cacheset.cc
index d453a2bfb0f26600060284c587ac0022e7d91890..d95a32aff110d617343085a5dce733bd7de188c5 100644 (file)
@@ -24,6 +24,7 @@
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/fileutl.h>
 
 #include <stddef.h>
 #include <stdio.h>
@@ -321,7 +322,8 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci
        if (FromGroup(pci, Cache, str, helper) == false &&
                 FromTask(pci, Cache, str, helper) == false &&
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
-                FromFnmatch(pci, Cache, str, helper) == false)
+                 // FIXME: hm, hm, regexp/fnmatch incompatible?
+                FromFnmatch(pci, Cache, str, helper) == false &&
 #endif
                 FromRegEx(pci, Cache, str, helper) == false)
        {
@@ -391,6 +393,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID,
                                                        CacheSetHelper &helper) {
        Version select = NEWEST;
        std::string str = cmdline;
+       if (unlikely(str.empty() == true))
+               return false;
        bool modifierPresent = false;
        unsigned short fallback = modID;
        for (std::list<Modifier>::const_iterator mod = mods.begin();
@@ -400,8 +404,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID,
                size_t const alength = strlen(mod->Alias);
                switch(mod->Pos) {
                case Modifier::POSTFIX:
-                       if (str.compare(str.length() - alength, alength,
-                                       mod->Alias, 0, alength) != 0)
+                       if (str.length() <= alength ||
+                             str.compare(str.length() - alength, alength, mod->Alias, 0, alength) != 0)
                                continue;
                        str.erase(str.length() - alength);
                        modID = mod->ID;
@@ -442,6 +446,15 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                                           pkgCacheFile &Cache, std::string pkg,
                                           Version const &fallback, CacheSetHelper &helper,
                                           bool const onlyFromName) {
+        PackageSet pkgset;
+        if(FileExists(pkg))
+        {
+                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
+                if(pkgset.size() == 0)
+                   return false;
+                return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
+        }
+
        std::string ver;
        bool verIsRel = false;
        size_t const vertag = pkg.find_last_of("/=");
@@ -450,7 +463,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
-       PackageSet pkgset;
        if (onlyFromName == false)
                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
        else {
@@ -608,7 +620,7 @@ void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/,
 }
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
 // canNotFindFnmatch - handle the case no package is found by a fnmatch        /*{{{*/
-void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+   void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) {
        if (ShowError == true)
                _error->Insert(ErrorType, _("Couldn't find any package by glob '%s'"), pattern.c_str());
 }
@@ -674,8 +686,8 @@ APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/
                                                                        /*}}}*/
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
 // showFnmatchSelection                                                        /*{{{*/
-APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
-                                          std::string const &pattern) {
+APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &/*pkg*/,
+                                         std::string const &/*pattern*/) {
 }
                                                                        /*}}}*/
 #endif