diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-21 14:07:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-21 14:07:17 +0200 |
commit | 489faa4e8a06ecaf9a42924690b1978ede4c2a12 (patch) | |
tree | 07179ba4906a6642cf6438eb4a77d18f860c45bb | |
parent | 035c945aed68af2c725263a1d9123943ecd22004 (diff) |
Move eof() utility to libbutl
-rw-r--r-- | build2/cc/compile.cxx | 18 | ||||
-rw-r--r-- | build2/utility.hxx | 2 |
2 files changed, 3 insertions, 17 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 0b9c20b..83230b2 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -2419,22 +2419,6 @@ namespace build2 fdstream_mode::text | fdstream_mode::skip, ifdstream::badbit); - // If an input stream operation has failed, return true if - // because of the eof and throw is_error otherwise. - // - auto eof = [] (std::istream& is) -> bool - { - if (is.fail ()) - { - if (is.eof ()) - return true; - - throw io_error (""); - } - - return false; - }; - // In some cases we may need to ignore the error return status. // The good_error flag keeps track of that. Similarly we // sometimes expect the error return status based on the output @@ -2444,7 +2428,7 @@ namespace build2 size_t skip (skip_count); string l; // Reuse. - for (bool first (true), second (false); !(restart || is.eof ());) + for (bool first (true), second (false); !restart; ) { if (eof (getline (is, l))) break; diff --git a/build2/utility.hxx b/build2/utility.hxx index a6f6fa6..2fa7e6e 100644 --- a/build2/utility.hxx +++ b/build2/utility.hxx @@ -74,6 +74,8 @@ namespace build2 using butl::throw_generic_error; using butl::throw_system_error; + using butl::eof; + // Basic string utilities. // |