+ if (Pkg.end() == true)
+ return helper.canNotFindPkgName(Cache, str);
+ return Pkg;
+}
+ /*}}}*/
+// FromString - Return all packages matching a specific string /*{{{*/
+bool PackageContainerInterface::FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str, CacheSetHelper &helper) {
+ bool found = true;
+ _error->PushToStack();
+
+ pkgCache::PkgIterator Pkg = FromName(Cache, str, helper);
+ if (Pkg.end() == false)
+ pci->insert(Pkg);
+ else if (FromTask(pci, Cache, str, helper) == false &&
+ FromRegEx(pci, Cache, str, helper) == false)
+ {
+ helper.canNotFindPackage(pci, Cache, str);
+ found = false;
+ }
+
+ if (found == true)
+ _error->RevertToStack();
+ else
+ _error->MergeWithStack();
+ return found;
+}
+ /*}}}*/
+// FromCommandLine - Return all packages specified on commandline /*{{{*/
+bool PackageContainerInterface::FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) {
+ bool found = false;
+ for (const char **I = cmdline; *I != 0; ++I)
+ found |= PackageContainerInterface::FromString(pci, Cache, *I, helper);
+ return found;
+}
+ /*}}}*/
+// FromModifierCommandLine - helper doing the work for PKG:GroupedFromCommandLine /*{{{*/
+bool PackageContainerInterface::FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
+ pkgCacheFile &Cache, const char * cmdline,
+ std::list<Modifier> const &mods, CacheSetHelper &helper) {
+ std::string str = cmdline;
+ bool modifierPresent = false;
+ for (std::list<Modifier>::const_iterator mod = mods.begin();
+ mod != mods.end(); ++mod) {
+ 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)
+ continue;
+ str.erase(str.length() - alength);
+ modID = mod->ID;
+ break;
+ case Modifier::PREFIX:
+ continue;
+ case Modifier::NONE:
+ continue;
+ }
+ modifierPresent = true;
+ break;
+ }
+ if (modifierPresent == true) {
+ bool const errors = helper.showErrors(false);
+ pkgCache::PkgIterator Pkg = FromName(Cache, cmdline, helper);
+ helper.showErrors(errors);
+ if (Pkg.end() == false) {
+ pci->insert(Pkg);
+ return true;
+ }
+ }
+ return FromString(pci, Cache, str, helper);
+}
+ /*}}}*/
+// FromModifierCommandLine - helper doing the work for VER:GroupedFromCommandLine /*{{{*/
+bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID,
+ VersionContainerInterface * const vci,
+ pkgCacheFile &Cache, const char * cmdline,
+ std::list<Modifier> const &mods,
+ CacheSetHelper &helper) {
+ Version select = NEWEST;
+ std::string str = cmdline;
+ bool modifierPresent = false;
+ unsigned short fallback = modID;
+ for (std::list<Modifier>::const_iterator mod = mods.begin();
+ mod != mods.end(); ++mod) {
+ if (modID == fallback && mod->ID == fallback)
+ select = mod->SelectVersion;
+ 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)
+ continue;
+ str.erase(str.length() - alength);
+ modID = mod->ID;
+ select = mod->SelectVersion;
+ break;
+ case Modifier::PREFIX:
+ continue;
+ case Modifier::NONE:
+ continue;
+ }
+ modifierPresent = true;
+ break;