From 2d9579da2144b2a8d67ea1d05fde96ec9d365944 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Jul 2016 12:47:21 +0300 Subject: Adapt to fdstream extension --- build2/cxx/link.cxx | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'build2/cxx/link.cxx') diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index e714bc1..19bf6d9 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -56,27 +56,31 @@ namespace build2 try { process pr (args.data (), 0, -1); // Open pipe to stdout. - ifdstream is (pr.in_ofd); - while (!is.eof ()) + try { - string s; - getline (is, s); - - if (is.fail () && !is.eof ()) - fail << "error reading C++ compiler -print-search-dirs output"; + ifdstream is (pr.in_ofd, fdstream_mode::skip, ifdstream::badbit); - if (s.compare (0, 12, "libraries: =") == 0) + string s; + while (getline (is, s)) { - l.assign (s, 12, string::npos); - break; + if (s.compare (0, 12, "libraries: =") == 0) + { + l.assign (s, 12, string::npos); + break; + } } - } - is.close (); // Don't block. + is.close (); // Don't block. - if (!pr.wait ()) - throw failed (); + if (!pr.wait ()) + throw failed (); + } + catch (const ifdstream::failure&) + { + pr.wait (); + fail << "error reading C++ compiler -print-search-dirs output"; + } } catch (const process_error& e) { @@ -1147,7 +1151,6 @@ namespace build2 try { ofdstream os (pr.out_fd); - os.exceptions (ofdstream::badbit | ofdstream::failbit); // 1 is resource ID, 24 is RT_MANIFEST. We also need to escape // Windows path backslashes. @@ -1170,15 +1173,16 @@ namespace build2 os << "\"" << endl; os.close (); + + if (!pr.wait ()) + throw failed (); // Assume diagnostics issued. } - catch (const ofdstream::failure&) + catch (const ofdstream::failure& e) { if (pr.wait ()) // Ignore if child failed. - fail << "unable to pipe resource file to " << args[0]; + fail << "unable to pipe resource file to " << args[0] + << ": " << e.what (); } - - if (!pr.wait ()) - throw failed (); // Assume diagnostics issued. } catch (const process_error& e) { -- cgit v1.1