aboutsummaryrefslogtreecommitdiff
path: root/build2/cxx/link.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-07-22 12:47:21 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-07-23 20:13:21 +0300
commit2d9579da2144b2a8d67ea1d05fde96ec9d365944 (patch)
treeb4e033f0e8284309efeecd68ba1e9cd70dc75220 /build2/cxx/link.cxx
parent3425432752d362341b8e39cd319d7f3c56aef169 (diff)
Adapt to fdstream extension
Diffstat (limited to 'build2/cxx/link.cxx')
-rw-r--r--build2/cxx/link.cxx44
1 files changed, 24 insertions, 20 deletions
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)
{