if (Type == Origin)
{
- OrSite = Data;
+ if (Data[0] == '"' && Data.length() >= 2 && Data.end()[-1] == '"')
+ OrSite = Data.substr(1, Data.length() - 2);
+ else
+ OrSite = Data;
return;
}
}
bool pkgVersionMatch::ExpressionMatches(const char *pattern, const char *string)
{
- std::cerr << "MATCH " << pattern;
if (pattern[0] == '/') {
bool res = false;
size_t length = strlen(pattern);
char *regex = strdup(pattern + 1);
regex[length - 2] = '\0';
if (regcomp(&preg, regex, REG_EXTENDED | REG_ICASE) != 0) {
- std::cerr << "E: Invalid regular expression: " << regex << "\n";
+ _error->Warning("Invalid regular expression: %s", regex);
} else if (regexec(&preg, string, 0, NULL, 0) == 0) {
res = true;
}
free(regex);
+ regfree(&preg);
return res;
}
}
if (Type == Origin)
{
if (OrSite.empty() == false) {
- if (File->Site == 0 || !ExpressionMatches(OrSite, File.Site()))
+ if (File->Site == 0)
return false;
} else // so we are talking about file:// or status file
- if (strcmp(File.Site(),"") == 0 && File->Archive != 0) // skip the status file
+ if (strcmp(File.Site(),"") == 0 && File->Archive != 0 && strcmp(File.Archive(),"now") == 0) // skip the status file
return false;
return (ExpressionMatches(OrSite, File.Site())); /* both strings match */
}