From 3f9c4cdf89ce00ae72a1176dbf5e68b5f1f1720e Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 1 Sep 2016 20:02:57 +0200 Subject: Tests/CMakeLib: use cmsys::ifstream --- Tests/CMakeLib/run_compile_commands.cxx | 17 ++++++++++------- Tests/CMakeLib/testRST.cxx | 9 ++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 502ffe7..529c830 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,6 +1,6 @@ #include "cmSystemTools.h" -#include +#include #include #include #include @@ -26,7 +26,10 @@ public: }; typedef std::vector TranslationUnitsType; - CompileCommandParser(std::ifstream* input) { this->Input = input; } + CompileCommandParser(std::istream& input) + : Input(input) + { + } void Parse() { @@ -109,8 +112,8 @@ private: void Next() { - this->C = char(Input->get()); - if (this->Input->bad()) { + this->C = char(Input.get()); + if (this->Input.bad()) { ErrorExit("Unexpected end of file."); } } @@ -131,13 +134,13 @@ private: TranslationUnitsType TranslationUnits; CommandType Command; std::string String; - std::ifstream* Input; + std::istream& Input; }; int main() { - std::ifstream file("compile_commands.json"); - CompileCommandParser parser(&file); + cmsys::ifstream file("compile_commands.json"); + CompileCommandParser parser(file); parser.Parse(); for (CompileCommandParser::TranslationUnitsType::const_iterator it = parser.GetTranslationUnits().begin(), diff --git a/Tests/CMakeLib/testRST.cxx b/Tests/CMakeLib/testRST.cxx index e5a96c2..cc92693 100644 --- a/Tests/CMakeLib/testRST.cxx +++ b/Tests/CMakeLib/testRST.cxx @@ -10,9 +10,12 @@ See the License for more information. ============================================================================*/ #include "cmRST.h" - #include "cmSystemTools.h" +#include +#include +#include + void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol) { if (ret) { @@ -52,8 +55,8 @@ int testRST(int argc, char* argv[]) } // Compare expected and actual outputs. - std::ifstream e_fin(e_name.c_str()); - std::ifstream a_fin(a_name.c_str()); + cmsys::ifstream e_fin(e_name.c_str()); + cmsys::ifstream a_fin(a_name.c_str()); if (!e_fin) { std::cerr << "Could not open input " << e_name << std::endl; return 1; -- cgit v0.12