aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-09-15 22:06:02 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-09-16 13:03:13 +0300
commite0efe0475bed89b6d60a04ce63dbc061e553bd59 (patch)
tree3f4f1181a56af351202774ecf68d6bfc28006b24
parent8b69cab7c802a0d0bd9cc90da33002dd5f86042f (diff)
Move print_process() to butl::process::print()
-rw-r--r--bpkg/diagnostics.cxx49
1 files changed, 17 insertions, 32 deletions
diff --git a/bpkg/diagnostics.cxx b/bpkg/diagnostics.cxx
index 41f08b4..9d1f96d 100644
--- a/bpkg/diagnostics.cxx
+++ b/bpkg/diagnostics.cxx
@@ -9,7 +9,10 @@
#include <odb/statement.hxx>
+#include <butl/process>
+
using namespace std;
+using namespace butl;
namespace bpkg
{
@@ -22,41 +25,23 @@ namespace bpkg
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 << '"';
+ const char* const* a;
+ size_t n;
+ };
- r << *p;
-
- 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.