Parcourir la source

* apt-pkg/contrib/configuration.cc:
- do not stop parent transversal in FindDir if the value is empty

See http://lists.debian.org/deity/2012/01/msg00053.html , too.

David Kalnischkies il y a 14 ans
Parent
commit
017f9fd682
3 fichiers modifiés avec 20 ajouts et 3 suppressions
  1. 8 2
      apt-pkg/contrib/configuration.cc
  2. 3 1
      debian/changelog
  3. 9 0
      test/libapt/configuration_test.cc

+ 8 - 2
apt-pkg/contrib/configuration.cc

@@ -185,8 +185,14 @@ string Configuration::FindFile(const char *Name,const char *Default) const
    }
    
    string val = Itm->Value;
-   while (Itm->Parent != 0 && Itm->Parent->Value.empty() == false)
-   {	 
+   while (Itm->Parent != 0)
+   {
+      if (Itm->Parent->Value.empty() == true)
+      {
+	 Itm = Itm->Parent;
+	 continue;
+      }
+
       // Absolute
       if (val.length() >= 1 && val[0] == '/')
          break;

+ 3 - 1
debian/changelog

@@ -7,6 +7,8 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
   * apt-pkg/depcache.cc:
     - if a M-A:same package is marked for reinstall, mark all it's installed
       silbings for reinstallation as well (LP: #859188)
+  * apt-pkg/contrib/configuration.cc:
+    - do not stop parent transversal in FindDir if the value is empty
 
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
@@ -20,7 +22,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
     - use a signed int instead of short for score calculation as upgrades
       become so big now that it can overflow (Closes: #657732, LP: #917173)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 29 Jan 2012 15:22:50 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 30 Jan 2012 13:07:30 +0100
 
 apt (0.8.16~exp12) experimental; urgency=low
 

+ 9 - 0
test/libapt/configuration_test.cc

@@ -71,6 +71,15 @@ int main(int argc,const char *argv[]) {
 	equals(Cnf.Find("APT2::Version", "33"), "33");
 	equals(Cnf.FindI("APT2::Version", 33), 33);
 
+	equals(Cnf.FindFile("Dir::State"), "");
+	equals(Cnf.FindFile("Dir::Aptitude::State"), "");
+	Cnf.Set("Dir", "/srv/sid");
+	equals(Cnf.FindFile("Dir::State"), "");
+	Cnf.Set("Dir::State", "var/lib/apt");
+	Cnf.Set("Dir::Aptitude::State", "var/lib/aptitude");
+	equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+	equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+
 	//FIXME: Test for configuration file parsing;
 	// currently only integration/ tests test them implicitly