From 33c5d3e0fce306631bad78ba3a4a87bb1f719fa5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2016 10:04:10 +0200 Subject: Minor changes to merge redirect code --- build2/test/script/parser.cxx | 20 +++++++++----------- build2/test/script/script | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'build2') diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx index 70f1ef2..2d9a065 100644 --- a/build2/test/script/parser.cxx +++ b/build2/test/script/parser.cxx @@ -599,17 +599,16 @@ namespace build2 try { size_t n; - if (stoi (w, &n) != fd || n != w.size ()) - throw invalid_argument (string ()); - } - catch (const exception&) - { - fail (l) << "invalid " << (fd == 1 ? "stderr" : "stdout") - << " merge redirect file descriptor '" << w << "'" << - info << "must be " << fd; + if (stoi (w, &n) == fd || n == w.size ()) + { + r.fd = fd; + return; + } } + catch (const exception&) {} // Fall through. - r.fd = fd; + fail (l) << (fd == 1 ? "stderr" : "stdout") << " merge redirect " + << "file descriptor must be " << fd; }; auto add_here_str = [&nn] (redirect& r, string&& w) @@ -1139,8 +1138,7 @@ namespace build2 if (c.out.type == redirect_type::merge && c.err.type == redirect_type::merge) - fail (l) << "stdout and stderr merge redirects" << - info << "should not be specified at the same time"; + fail (l) << "stdout and stderr redirected to each other"; } // While we no longer need to recognize command line operators, we diff --git a/build2/test/script/script b/build2/test/script/script index f0d8f21..a21f0c6 100644 --- a/build2/test/script/script +++ b/build2/test/script/script @@ -68,7 +68,7 @@ namespace build2 union { - int fd; // Used with 'merge' type. + int fd; // Merge-to descriptor. string str; // Note: includes trailing newline, if required. doc_type doc; file_type file; -- cgit v1.1