+ // Make sure there is at least one argument
+ unsigned int const NumPatterns = CmdL.FileSize() -1;
+ if (NumPatterns < 1)
+ return _error->Error(_("You must give at least one search pattern"));
+
+#define APT_FREE_PATTERNS() for (std::vector<regex_t>::iterator P = Patterns.begin(); \
+ P != Patterns.end(); ++P) { regfree(&(*P)); }
+
+ // Compile the regex pattern
+ std::vector<regex_t> Patterns;
+ for (unsigned int I = 0; I != NumPatterns; ++I)
+ {
+ regex_t pattern;
+ if (regcomp(&pattern, CmdL.FileList[I + 1], REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
+ {
+ APT_FREE_PATTERNS();
+ return _error->Error("Regex compilation error");
+ }
+ Patterns.push_back(pattern);
+ }
+
+ bool const NamesOnly = _config->FindB("APT::Cache::NamesOnly", false);