aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/diagnostics.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/build/diagnostics.cxx b/build/diagnostics.cxx
index 70dfe07..a450301 100644
--- a/build/diagnostics.cxx
+++ b/build/diagnostics.cxx
@@ -4,6 +4,7 @@
#include <build/diagnostics>
+#include <cstring> // strchr()
#include <iostream>
#include <build/utility>
@@ -34,10 +35,22 @@ namespace build
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?
{