From 80ea2bb51d1a9a37ab73c741b34fab08caa8bdaa Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 19 Nov 2016 09:45:04 -0500 Subject: [PATCH] TDB2: Made sure file exists before checking readability --- src/TDB2.cpp | 4 ++-- test/diag.t | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 9d80cca43..fa5cea3da 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -571,8 +571,8 @@ const std::string TF2::dump () label = rightJustify (_file._data.substr (slash + 1), 14); // File mode. - std::string mode = std::string (_file.readable () ? "r" : "-") + - std::string (_file.writable () ? "w" : "-"); + std::string mode = std::string (_file.exists () && _file.readable () ? "r" : "-") + + std::string (_file.exists () && _file.writable () ? "w" : "-"); if (mode == "r-") mode = red.colorize (mode); else if (mode == "rw") mode = green.colorize (mode); else mode = yellow.colorize (mode); diff --git a/test/diag.t b/test/diag.t index 894dd2c9c..4804ee131 100755 --- a/test/diag.t +++ b/test/diag.t @@ -50,6 +50,8 @@ class TestDiagnostics(TestCase): self.tap(out) self.assertRegexpMatches(out, "Compliance:\s+C\+\+11") self.assertRegexpMatches(out, "libgnutls:\s+\d+\.\d+\.\d+") + self.assertIn("edlin", out) + self.assertIn("strict", out) if __name__ == "__main__":