aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-09-15 22:15:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-09-15 22:15:47 +0300
commitaaf0d51b8ba50f2614313bf098ee6695235db676 (patch)
tree1b3d19449306d5ff3acf284553f6594991d3bcb3
parent3473cc68f59911cb6659634fdc577f882c8128de (diff)
Move print_process() to butl::process::print()
-rw-r--r--build2/diagnostics.cxx46
1 files changed, 14 insertions, 32 deletions
diff --git a/build2/diagnostics.cxx b/build2/diagnostics.cxx
index 1265f73..ca395ab 100644
--- a/build2/diagnostics.cxx
+++ b/build2/diagnostics.cxx
@@ -22,41 +22,23 @@ namespace build2
print_process (r, args, n);
}
- void
- print_process (diag_record& r, const char* const* args, size_t n)
+ struct process_args
{
- size_t m (0);
- const char* const* p (args);
- do
- {
- if (m != 0)
- r << " |"; // Trailing space will be added inside the loop.
-
- for (m++; *p != nullptr; p++, m++)
- {
- if (p != args)
- r << ' ';
-
- // Quote if empty or contains spaces.
- //
- bool q (**p == '\0' || strchr (*p, ' ') != nullptr);
-
- if (q)
- r << '"';
-
- r << *p;
+ const char* const* a;
+ size_t n;
+ };
- if (q)
- r << '"';
- }
-
- if (m < n) // Can we examine the next element?
- {
- p++;
- m++;
- }
+ inline static ostream&
+ operator<< (ostream& o, const process_args& p)
+ {
+ process::print (o, p.a, p.n);
+ return o;
+ }
- } while (*p != nullptr);
+ void
+ print_process (diag_record& r, const char* const* args, size_t n)
+ {
+ r << process_args {args, n};
}
// Diagnostics verbosity level.