aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/diagnostics.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/bpkg/diagnostics.cxx b/bpkg/diagnostics.cxx
index 221bded..ece3308 100644
--- a/bpkg/diagnostics.cxx
+++ b/bpkg/diagnostics.cxx
@@ -4,6 +4,7 @@
#include <bpkg/diagnostics>
+#include <cstring> // strchr()
#include <iostream>
#include <odb/statement.hxx>
@@ -34,10 +35,22 @@ namespace bpkg
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 (p != args)
+ r << ' ';
+
+ // Quote if empty or contains spaces.
+ //
+ bool q (**p == '\0' || strchr (*p, ' ') != nullptr);
+
+ if (q)
+ r << '"';
+
+ r << *p;
+
+ if (q)
+ r << '"';
+ }
if (m < n) // Can we examine the next element?
{