diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-04 14:15:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-04 14:15:37 +0200 |
commit | 81abf8eab067eab362f180a418215f9408de41dc (patch) | |
tree | fd9915dd0ac551e989247fcd2cc78f57a378b6c4 /bpkg/diagnostics.cxx | |
parent | 0aa9007705231b72616c533aeed6a28ca3349999 (diff) |
Add support for printing process command line
Diffstat (limited to 'bpkg/diagnostics.cxx')
-rw-r--r-- | bpkg/diagnostics.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bpkg/diagnostics.cxx b/bpkg/diagnostics.cxx index 2bee18e..4c5e24b 100644 --- a/bpkg/diagnostics.cxx +++ b/bpkg/diagnostics.cxx @@ -10,6 +10,40 @@ using namespace std; namespace bpkg { + // print_process + // + void + print_process (const char* const* args, size_t n) + { + diag_record r (text); + print_process (r, args, n); + } + + void + print_process (diag_record& r, const char* const* args, size_t n) + { + 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++) + r << (p != args ? " " : "") + << (**p == '\0' ? "\"" : "") // Quote empty arguments. + << *p + << (**p == '\0' ? "\"" : ""); + + if (m < n) // Can we examine the next element? + { + p++; + m++; + } + + } while (*p != nullptr); + } + // Trace verbosity level. // uint16_t verb; |