From d933699b4dd106c227f8d07a2471d5f39f1c82af Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 3 Nov 2016 00:49:14 +0300 Subject: Adopt to auto_fd introduced to libbutl fdstreams and process --- build2/cc/compile.cxx | 5 +++-- build2/cc/gcc.cxx | 3 ++- build2/cc/link.cxx | 5 +++-- build2/cc/msvc.cxx | 3 ++- build2/cli/init.cxx | 2 +- build2/test/script/builtin | 2 +- build2/test/script/builtin.cxx | 17 +++-------------- build2/types | 1 + build2/utility.txx | 2 +- 9 files changed, 17 insertions(+), 23 deletions(-) (limited to 'build2') diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index e180798..45a0aff 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -1190,7 +1190,7 @@ namespace build2 // complains, loudly (broken pipe). So now we are going to skip // until the end. // - ifdstream is (cid == "msvc" ? pr.in_efd : pr.in_ofd, + ifdstream is (move (cid == "msvc" ? pr.in_efd : pr.in_ofd), fdstream_mode::text | fdstream_mode::skip, ifdstream::badbit); @@ -1565,7 +1565,8 @@ namespace build2 { try { - ifdstream is (pr.in_ofd, fdstream_mode::text, ifdstream::badbit); + ifdstream is ( + move (pr.in_ofd), fdstream_mode::text, ifdstream::badbit); msvc_filter_cl (is, rels); diff --git a/build2/cc/gcc.cxx b/build2/cc/gcc.cxx index a5c8357..b4ec45c 100644 --- a/build2/cc/gcc.cxx +++ b/build2/cc/gcc.cxx @@ -54,7 +54,8 @@ namespace build2 try { - ifdstream is (pr.in_ofd, fdstream_mode::skip, ifdstream::badbit); + ifdstream is ( + move (pr.in_ofd), fdstream_mode::skip, ifdstream::badbit); // The output of -print-search-dirs are a bunch of lines that start // with ": =" where name can be "install", "programs", or diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 7722c4f..cf284e1 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -947,7 +947,7 @@ namespace build2 try { - ofdstream os (pr.out_fd); + ofdstream os (move (pr.out_fd)); // 1 is resource ID, 24 is RT_MANIFEST. We also need to escape // Windows path backslashes. @@ -1475,7 +1475,8 @@ namespace build2 { try { - ifdstream is (pr.in_ofd, fdstream_mode::text, ifdstream::badbit); + ifdstream is ( + move (pr.in_ofd), fdstream_mode::text, ifdstream::badbit); msvc_filter_link (is, t, lt); diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx index 5261072..81736c9 100644 --- a/build2/cc/msvc.cxx +++ b/build2/cc/msvc.cxx @@ -144,7 +144,8 @@ namespace build2 try { - ifdstream is (pr.in_ofd, fdstream_mode::skip, ifdstream::badbit); + ifdstream is ( + move (pr.in_ofd), fdstream_mode::skip, ifdstream::badbit); while (getline (is, s)) { diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx index b41e095..093cdbb 100644 --- a/build2/cli/init.cxx +++ b/build2/cli/init.cxx @@ -100,7 +100,7 @@ namespace build2 try { - ifdstream is (pr.in_ofd, fdstream_mode::skip); + ifdstream is (move (pr.in_ofd), fdstream_mode::skip); // The version should be the last word on the first line. // diff --git a/build2/test/script/builtin b/build2/test/script/builtin index 805e5fd..3e49f98 100644 --- a/build2/test/script/builtin +++ b/build2/test/script/builtin @@ -19,7 +19,7 @@ namespace build2 // Note that unlike argc/argv, our args don't include the program name. // using builtin = int (*) (const strings& args, - int in_fd, int out_fd, int err_fd); + auto_fd in, auto_fd out, auto_fd err); class builtin_map: public std::map { diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx index f3a0bd4..a83bb6d 100644 --- a/build2/test/script/builtin.cxx +++ b/build2/test/script/builtin.cxx @@ -11,27 +11,16 @@ using namespace butl; namespace build2 { - //@@ auto_fd handover - // - // 1. We need auto_fd in libbutl - // 2. Overload fdstream ctors for auto_fd&& (or replace? also process data - // members?) - // 3. The builtin signature then will become: - // - // static int - // echo (const strings& args, auto_fd in, auto_fd out, auto_fd err) - static int - echo (const strings& args, int in_fd, int out_fd, int err_fd) + echo (const strings& args, auto_fd, auto_fd out, auto_fd err) try { int r (0); - ofdstream cerr (err_fd); + ofdstream cerr (move (err)); try { - fdclose (in_fd); //@@ TMP - ofdstream cout (out_fd); + ofdstream cout (move (out)); for (auto b (args.begin ()), i (b), e (args.end ()); i != e; ++i) cout << (i != b ? " " : "") << *i; diff --git a/build2/types b/build2/types index 19fe888..9b3dbc7 100644 --- a/build2/types +++ b/build2/types @@ -135,6 +135,7 @@ namespace build2 ostream& operator<< (ostream&, const process_path&); // Print as recall[@effect]. + using butl::auto_fd; using butl::ifdstream; using butl::ofdstream; } diff --git a/build2/utility.txx b/build2/utility.txx index bba66d6..8b5bdd2 100644 --- a/build2/utility.txx +++ b/build2/utility.txx @@ -45,7 +45,7 @@ namespace build2 try { - ifdstream is (pr.in_ofd); + ifdstream is (move (pr.in_ofd)); while (is.peek () != ifdstream::traits_type::eof () && // Keep last line. getline (is, l)) -- cgit v1.1