]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utilsexc.cpp
compilation fix for Windows after the last change (misplaced #endif)
[wxWidgets.git] / src / msw / utilsexc.cpp
index 60fb2164e59e7d51783bc528d50c581dba58da35..aaf6176b1c2b86d35b62b49dcfe99ae771b033fb 100644 (file)
@@ -217,7 +217,7 @@ protected:
 protected:
     HANDLE m_hInput;
 
-    DECLARE_NO_COPY_CLASS(wxPipeInputStream)
+    wxDECLARE_NO_COPY_CLASS(wxPipeInputStream);
 };
 
 class wxPipeOutputStream: public wxOutputStream
@@ -233,7 +233,7 @@ protected:
 protected:
     HANDLE m_hOutput;
 
-    DECLARE_NO_COPY_CLASS(wxPipeOutputStream)
+    wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream);
 };
 
 // define this to let wxexec.cpp know that we know what we're doing
@@ -899,6 +899,9 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
     {
         // may be NULL or not
         data->handler = handler;
+
+        if (handler)
+            handler->SetPid(pi.dwProcessId);
     }
 
     DWORD tid;
@@ -1027,9 +1030,34 @@ long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler)
     wxString command;
     command.reserve(1024);
 
+    wxString arg;
     for ( ;; )
     {
-        command += *argv++;
+        arg = *argv++;
+
+        bool quote;
+        if ( arg.empty() )
+        {
+            // we need to quote empty arguments, otherwise they'd just
+            // disappear
+            quote = true;
+        }
+        else // non-empty
+        {
+            // escape any quotes present in the string to avoid interfering
+            // with the command line parsing in the child process
+            arg.Replace("\"", "\\\"", true /* replace all */);
+
+            // and quote any arguments containing the spaces to prevent them from
+            // being broken down
+            quote = arg.find_first_of(" \t") != wxString::npos;
+        }
+
+        if ( quote )
+            command += '\"' + arg + '\"';
+        else
+            command += arg;
+
         if ( !*argv )
             break;