From: Vadim Zeitlin Date: Wed, 16 Jul 2008 00:53:11 +0000 (+0000) Subject: use wxCmdLineParser::ConverStringToArgs() instead of (incorrectly) duplicating it... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fae7120624035224841ccf6a563f72e1fc37f64a use wxCmdLineParser::ConverStringToArgs() instead of (incorrectly) duplicating it here (#9743) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 7e8b8f23d5..23b2b17a36 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -39,6 +39,8 @@ #include "wx/process.h" #include "wx/thread.h" +#include "wx/cmdline.h" + #include "wx/wfstream.h" #include "wx/private/selectdispatcher.h" @@ -436,60 +438,9 @@ bool wxMacLaunch(char **argv); long wxExecute(const wxString& command, int flags, wxProcess *process) { - wxArrayString args; - - const char *cptr = command.c_str(); - - // split the command line in arguments - // - // TODO: combine this with wxCmdLineParser::ConvertStringToArgs(), it - // doesn't do exactly the same thing right now but it's pretty close - // and we shouldn't maintain 2 copies of this code - do - { - wxString argument; - char quotechar = '\0'; // is arg quoted? - bool escaped = false; - - // eat leading whitespace: - while ( wxIsspace(*cptr) ) - cptr++; - - if ( *cptr == '\'' || *cptr == '"' ) - quotechar = *cptr++; - - do - { - if ( *cptr == '\\' && !escaped ) - { - escaped = true; - cptr++; - continue; - } - - // all other characters: - argument += *cptr++; - escaped = false; - - // have we reached the end of the argument? - if ( (*cptr == quotechar && !escaped) - || (quotechar == '\0' && wxIsspace(*cptr)) - || *cptr == '\0' ) - { - args.push_back(argument); - - // if not at end of buffer, swallow last character: - if ( *cptr ) - cptr++; - - break; // done with this one, start over - } - } while ( *cptr ); - } while ( *cptr ); - - ArgsArray argv(args); + ArgsArray argv(wxCmdLineParser::ConvertStringToArgs(command, + wxCMD_LINE_SPLIT_UNIX)); - // do execute the command return wxExecute(argv, flags, process); }