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/msvc.cxx | 77 +++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'build2/cxx/msvc.cxx') diff --git a/build2/cxx/msvc.cxx b/build2/cxx/msvc.cxx index 97d8fd5..294ac03 100644 --- a/build2/cxx/msvc.cxx +++ b/build2/cxx/msvc.cxx @@ -89,56 +89,63 @@ namespace build2 // redirect stderr to stdout. // process pr (start_run (args, false)); - ifdstream is (pr.in_ofd); bool obj (false), dll (false); - string s; - while (getline (is, s)) - { - // Detect the one error we should let through. - // - if (s.compare (0, 18, "unable to execute ") == 0) - break; - // The lines we are interested in seem to have this form (though - // presumably the "Archive member name at" part can be translated): - // - // Archive member name at 746: [...]hello.dll[/][ ]* - // Archive member name at 8C70: [...]hello.lib.obj[/][ ]* - // - size_t n (s.size ()); - - for (; n != 0 && s[n - 1] == ' '; --n) ; // Skip trailing spaces. + try + { + ifdstream is (pr.in_ofd, fdstream_mode::skip, ifdstream::badbit); - if (n >= 7) // At least ": X.obj" or ": X.dll". + while (getline (is, s)) { - --n; - - if (s[n] == '/') // Skip trailing slash if one is there. + // Detect the one error we should let through. + // + if (s.compare (0, 18, "unable to execute ") == 0) + break; + + // The lines we are interested in seem to have this form (though + // presumably the "Archive member name at" part can be translated): + // + // Archive member name at 746: [...]hello.dll[/][ ]* + // Archive member name at 8C70: [...]hello.lib.obj[/][ ]* + // + size_t n (s.size ()); + + for (; n != 0 && s[n - 1] == ' '; --n) ; // Skip trailing spaces. + + if (n >= 7) // At least ": X.obj" or ": X.dll". + { --n; - n -= 3; // Beginning of extension. + if (s[n] == '/') // Skip trailing slash if one is there. + --n; - if (s[n] == '.') - { - // Make sure there is ": ". - // - size_t p (s.rfind (':', n - 1)); + n -= 3; // Beginning of extension. - if (p != string::npos && s[p + 1] == ' ') + if (s[n] == '.') { - if (s.compare (n + 1, 3, "obj") == 0) // @@ CASE - obj = true; - - if (s.compare (n + 1, 3, "dll") == 0) // @@ CASE - dll = true; + // Make sure there is ": ". + // + size_t p (s.rfind (':', n - 1)); + + if (p != string::npos && s[p + 1] == ' ') + { + if (s.compare (n + 1, 3, "obj") == 0) // @@ CASE + obj = true; + + if (s.compare (n + 1, 3, "dll") == 0) // @@ CASE + dll = true; + } } } } } - - is.close (); // Don't block. + catch (const ifdstream::failure&) + { + // Presumably the child process failed. Let finish_run() deal with + // that. + } if (!finish_run (args, false, pr, s)) return otype::e; -- cgit v1.1