]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/configuration.cc
[contrib/error.cc] place a colon between errno and error text in output
[apt.git] / apt-pkg / contrib / configuration.cc
index 6f617e9148bdf9983e6fd482eb1338043ceda90e..48a5f0bff1f26551602339623592d96d85a1ee22 100644 (file)
@@ -182,9 +182,9 @@ string Configuration::FindFile(const char *Name,const char *Default) const
    if (Itm == 0 || Itm->Value.empty() == true)
    {
       if (Default == 0)
-        return "";
+        return rootDir;
       else
-        return Default;
+        return rootDir + Default;
    }
    
    string val = Itm->Value;
@@ -521,6 +521,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
          F.getline(Buffer,sizeof(Buffer) / 2);
 
          Input += Buffer;
+         delete[] Buffer;
        }
       while (F.fail() && !F.eof());
 
@@ -582,7 +583,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
         if (InQuote == true)
            continue;
         
-        if (*I == '/' && I + 1 != End && I[1] == '/')
+        if ((*I == '/' && I + 1 != End && I[1] == '/') || *I == '#')
          {
            End = I;
            break;
@@ -635,26 +636,21 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
       for (std::string::const_iterator I = Start;
           I != End; ++I)
       {
-        if(Start > End)
-          {
-            _error->Error("Why is Start > End?");
-          }
-
         if (*I == '"')
            InQuote = !InQuote;
         
         if (InQuote == false && (*I == '{' || *I == ';' || *I == '}'))
         {
            // Put the last fragment into the buffer
-           std::string::const_iterator FirstNonWhitespace = Start;
-           std::string::const_iterator LastNonWhitespace = I;
-           for (; FirstNonWhitespace != I && isspace(*FirstNonWhitespace) != 0; FirstNonWhitespace++)
+           std::string::const_iterator NonWhitespaceStart = Start;
+           std::string::const_iterator NonWhitespaceStop = I;
+           for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; NonWhitespaceStart++)
              ;
-           for (; LastNonWhitespace != FirstNonWhitespace && isspace(LastNonWhitespace[-1]) != 0; LastNonWhitespace--)
+           for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; NonWhitespaceStop--)
              ;
-           if (LineBuffer.empty() == false && LastNonWhitespace - FirstNonWhitespace != 0)
+           if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0)
               LineBuffer += ' ';
-           LineBuffer += string(FirstNonWhitespace, LastNonWhitespace);
+           LineBuffer += string(NonWhitespaceStart, NonWhitespaceStop);
 
            // Drop this from the input string, saving the character
            // that terminated the construct we just closed. (i.e., a