aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-15 17:38:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-15 17:38:48 +0200
commit2436f20262a41bd1cafa5107ab6d6799c03e0964 (patch)
treeb196004f790a055d721b7bf7619e268f069c1c1b
parentace11f2d33706d55b805ce7758667e0ec27902f8 (diff)
Handle paths with spaces on Windows1.2.0
-rw-r--r--odb/odb.cxx41
1 files changed, 21 insertions, 20 deletions
diff --git a/odb/odb.cxx b/odb/odb.cxx
index 707173e..5dec9e5 100644
--- a/odb/odb.cxx
+++ b/odb/odb.cxx
@@ -698,25 +698,6 @@ encode_plugin_option (string const& k, string const& cv)
if (!v.empty ())
{
o += '=';
-
- // On Windows we need to protect values with spaces using quotes.
- // Since there could be actual quotes in the value, we need to
- // escape them.
- //
-#ifdef _WIN32
- {
- string t ("\"");
- for (size_t i (0); i < v.size (); ++i)
- {
- if (v[i] == '"')
- t += "\\\"";
- else
- t += v[i];
- }
- t += '"';
- v = t;
- }
-#endif
o += v;
}
@@ -1181,12 +1162,32 @@ start_process (char const* args[], char const* name, bool out)
// Serialize the arguments to string.
//
string cmd_line;
+
for (char const** p (args); *p != 0; ++p)
{
if (p != args)
cmd_line += ' ';
- cmd_line += *p;
+ // On Windows we need to protect values with spaces using quotes.
+ // Since there could be actual quotes in the value, we need to
+ // escape them.
+ //
+ string a (*p);
+ bool quote (a.find (' ') != string::npos);
+
+ if (quote)
+ cmd_line += '"';
+
+ for (size_t i (0); i < a.size (); ++i)
+ {
+ if (a[i] == '"')
+ cmd_line += "\\\"";
+ else
+ cmd_line += a[i];
+ }
+
+ if (quote)
+ cmd_line += '"';
}
// Prepare other info.