]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/configuration.cc
Merge branch 'debian/sid' into debian/experimental
[apt.git] / apt-pkg / contrib / configuration.cc
index d5334ae7205121f28c78869a91592a3418dee99d..4380d64b9ed2af6e930db118b5a73861ab36edb1 100644 (file)
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
-
+#include <apt-pkg/macros.h>
+
+#include <ctype.h>
+#include <regex.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
 #include <vector>
 #include <fstream>
 #include <vector>
 #include <fstream>
-#include <iostream>
 
 #include <apti18n.h>
 
 
 #include <apti18n.h>
 
@@ -42,8 +50,7 @@ Configuration::Configuration() : ToFree(true)
 }
 Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
 {
 }
 Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
 {
-};
-
+}
                                                                        /*}}}*/
 // Configuration::~Configuration - Destructor                          /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // Configuration::~Configuration - Destructor                          /*{{{*/
 // ---------------------------------------------------------------------
@@ -246,12 +253,15 @@ 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 */
 // Configuration::FindVector - Find a vector of values                 /*{{{*/
 // ---------------------------------------------------------------------
 /* Returns a vector of config values under the given item */
-vector<string> Configuration::FindVector(const char *Name) const
+vector<string> Configuration::FindVector(const char *Name, std::string const &Default) const
 {
    vector<string> Vec;
    const Item *Top = Lookup(Name);
    if (Top == NULL)
 {
    vector<string> 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)
 
    Item *I = Top->Child;
    while(I != NULL)
@@ -259,6 +269,9 @@ vector<string> Configuration::FindVector(const char *Name) const
       Vec.push_back(I->Value);
       I = I->Next;
    }
       Vec.push_back(I->Value);
       I = I->Next;
    }
+   if (Vec.empty() == true)
+      return VectorizeString(Default, ',');
+
    return Vec;
 }
                                                                        /*}}}*/
    return Vec;
 }
                                                                        /*}}}*/
@@ -823,7 +836,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
            // Go down a level
            if (TermChar == '{')
            {
            // 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
                  Stack[StackPos++] = ParentTag;
               
               /* Make sectional tags incorperate the section into the
@@ -970,7 +983,7 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config)
         continue;
       }
    }
         continue;
       }
    }
-   if (strings.size() == 0)
+   if (strings.empty() == true)
       patterns.push_back(NULL);
 }
                                                                        /*}}}*/
       patterns.push_back(NULL);
 }
                                                                        /*}}}*/