X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/fd785e49fa017abbe1871f18af515fdedb3ad183..e5fefea6ec93746376bf42733ee84a9fafeab764:/apt-pkg/contrib/configuration.cc?ds=inline diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index d5334ae72..fbe180f8e 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -21,10 +21,18 @@ #include #include #include - +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include @@ -42,8 +50,7 @@ Configuration::Configuration() : ToFree(true) } Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false) { -}; - +} /*}}}*/ // Configuration::~Configuration - Destructor /*{{{*/ // --------------------------------------------------------------------- @@ -246,12 +253,20 @@ string Configuration::FindDir(const char *Name,const char *Default) const // Configuration::FindVector - Find a vector of values /*{{{*/ // --------------------------------------------------------------------- /* Returns a vector of config values under the given item */ -vector Configuration::FindVector(const char *Name) const +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) +vector Configuration::FindVector(const char *Name) const { + return FindVector(Name, ""); +} +#endif +vector Configuration::FindVector(const char *Name, std::string const &Default) const { vector Vec; const Item *Top = Lookup(Name); if (Top == NULL) - return Vec; + return VectorizeString(Default, ','); + + if (Top->Value.empty() == false) + return VectorizeString(Top->Value, ','); Item *I = Top->Child; while(I != NULL) @@ -259,6 +274,9 @@ vector Configuration::FindVector(const char *Name) const Vec.push_back(I->Value); I = I->Next; } + if (Vec.empty() == true) + return VectorizeString(Default, ','); + return Vec; } /*}}}*/ @@ -823,7 +841,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio // Go down a level if (TermChar == '{') { - if (StackPos <= 100) + if (StackPos < sizeof(Stack)/sizeof(std::string)) Stack[StackPos++] = ParentTag; /* Make sectional tags incorperate the section into the @@ -970,7 +988,7 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config) continue; } } - if (strings.size() == 0) + if (strings.empty() == true) patterns.push_back(NULL); } /*}}}*/