/dev/null is a special absolute path as it has no subdirectories
authorDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 23 Apr 2012 17:33:32 +0000 (19:33 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 23 Apr 2012 17:33:32 +0000 (19:33 +0200)
apt-pkg/contrib/configuration.cc
debian/changelog
test/libapt/configuration_test.cc

index ce02f1b..4de17e3 100644 (file)
@@ -194,7 +194,11 @@ string Configuration::FindFile(const char *Name,const char *Default) const
 
         // Absolute
         if (val.length() >= 1 && val[0] == '/')
+        {
+           if (val.compare(0, 9, "/dev/null") == 0)
+              val.erase(9);
            break;
+        }
 
         // ~/foo or ./foo
         if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/')
@@ -230,7 +234,12 @@ string Configuration::FindDir(const char *Name,const char *Default) const
 {
    string Res = FindFile(Name,Default);
    if (Res.end()[-1] != '/')
+   {
+      size_t const found = Res.rfind("/dev/null");
+      if (found != string::npos && found == Res.size() - 9)
+        return Res; // /dev/null returning
       return Res + '/';
+   }
    return Res;
 }
                                                                        /*}}}*/
index dc331dc..5586773 100644 (file)
@@ -6,6 +6,7 @@ apt (0.9.3) unstable; urgency=low
   * apt-pkg/contrib/configuration.cc:
     - add a more versatile Dump() method
     - normalize a bit by replacing // and /./ with / in FindFile
+    - /dev/null is a special absolute path as it has no subdirectories
   * apt-pkg/acquire-worker.cc:
     - use Dump() to generate the configuration message for sending
   * cmdline/apt-config.cc:
@@ -21,7 +22,7 @@ apt (0.9.3) unstable; urgency=low
     - check with RealFileExists for scenario file as otherwise a directory
       like one provided with RootDir triggers the usage of EDSP
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 23 Apr 2012 19:10:13 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 23 Apr 2012 19:32:29 +0200
 
 apt (0.9.2) unstable; urgency=low
 
index 6b657a7..87d5699 100644 (file)
@@ -93,6 +93,11 @@ int main(int argc,const char *argv[]) {
        equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
        equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
 
+       Cnf.Set("Dir::State", "/dev/null");
+       Cnf.Set("Dir::State::lists", "lists/");
+       equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null");
+       equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null");
+
        //FIXME: Test for configuration file parsing;
        // currently only integration/ tests test them implicitly