X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/7ea4af9da25a802516461434b12a61e21743f960..a865ed25fa54514224cf4d6f83dd9cf48b7ed02b:/apt-pkg/contrib/configuration.cc diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 81cc87d15..2d1dee22d 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -318,6 +318,19 @@ void Configuration::CndSet(const char *Name,const string &Value) Itm->Value = Value; } /*}}}*/ +// Configuration::Set - Set an integer value /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void Configuration::CndSet(const char *Name,int const Value) +{ + Item *Itm = Lookup(Name,true); + if (Itm == 0 || Itm->Value.empty() == false) + return; + char S[300]; + snprintf(S,sizeof(S),"%i",Value); + Itm->Value = S; +} + /*}}}*/ // Configuration::Set - Set a value /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -857,22 +870,31 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config) { regfree(p); delete p; - _error->Warning("Regex compilation error for '%s' in configuration option '%s'", - s->c_str(), Config); + _error->Warning("Invalid regular expression '%s' in configuration " + "option '%s' will be ignored.", + s->c_str(), Config); + continue; } - } - + } + if (strings.size() == 0) + patterns.push_back(NULL); } /*}}}*/ // MatchAgainstConfig Destructor /*{{{*/ Configuration::MatchAgainstConfig::~MatchAgainstConfig() +{ + clearPatterns(); +} +void Configuration::MatchAgainstConfig::clearPatterns() { for(std::vector::const_iterator p = patterns.begin(); p != patterns.end(); ++p) { + if (*p == NULL) continue; regfree(*p); delete *p; } + patterns.clear(); } /*}}}*/ // MatchAgainstConfig::Match - returns true if a pattern matches /*{{{*/ @@ -880,7 +902,7 @@ bool Configuration::MatchAgainstConfig::Match(char const * str) const { for(std::vector::const_iterator p = patterns.begin(); p != patterns.end(); ++p) - if (regexec(*p, str, 0, 0, 0) == 0) + if (*p != NULL && regexec(*p, str, 0, 0, 0) == 0) return true; return false;