+ return true;
+}
+ /*}}}*/
+// Search - Perform a search /*{{{*/
+// ---------------------------------------------------------------------
+/* This searches the package names and pacakge descriptions for a pattern */
+bool Search(CommandLine &CmdL)
+{
+ pkgCache &Cache = *GCache;
+
+ // Make sure there is at least one argument
+ if (CmdL.FileSize() != 2)
+ return _error->Error("You must give exactly one pattern");
+
+ // Compile the regex pattern
+ regex_t Pattern;
+ if (regcomp(&Pattern,CmdL.FileList[1],REG_EXTENDED | REG_ICASE |
+ REG_NOSUB) != 0)
+ return _error->Error("Regex compilation error");
+
+ // Create the text record parser
+ pkgRecords Recs(Cache);
+ if (_error->PendingError() == true)
+ return false;
+
+ // Search package names
+ pkgCache::PkgIterator I = Cache.PkgBegin();
+ for (;I.end() != true; I++)
+ {
+ if (regexec(&Pattern,I.Name(),0,0,0) == 0)
+ {
+ cout << I.Name();
+ if (I->VersionList != 0)
+ {
+ pkgRecords::Parser &P = Recs.Lookup(I.VersionList().FileList());
+ cout << " - " << P.ShortDesc() << endl;
+ }
+ else
+ cout << " [virtual package]" << endl;
+ }
+ }
+
+ regfree(&Pattern);