]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/configuration.cc
* apt-pkg/acquire.cc:
[apt.git] / apt-pkg / contrib / configuration.cc
index 843e91f2a450218d4583d0e3d05bf5d5c3af6e53..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;
@@ -641,15 +642,15 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
         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