make wxExecute() argv parameter fully const-qualified

This commit is contained in:
Paul Cornett
2017-02-18 10:14:25 -08:00
parent c9fad20b7b
commit c64a4c3224
5 changed files with 16 additions and 16 deletions

View File

@@ -381,12 +381,12 @@ WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
int flags = wxEXEC_ASYNC, int flags = wxEXEC_ASYNC,
wxProcess *process = NULL, wxProcess *process = NULL,
const wxExecuteEnv *env = NULL); const wxExecuteEnv *env = NULL);
WXDLLIMPEXP_BASE long wxExecute(char **argv, WXDLLIMPEXP_BASE long wxExecute(const char* const* argv,
int flags = wxEXEC_ASYNC, int flags = wxEXEC_ASYNC,
wxProcess *process = NULL, wxProcess *process = NULL,
const wxExecuteEnv *env = NULL); const wxExecuteEnv *env = NULL);
#if wxUSE_UNICODE #if wxUSE_UNICODE
WXDLLIMPEXP_BASE long wxExecute(wchar_t **argv, WXDLLIMPEXP_BASE long wxExecute(const wchar_t* const* argv,
int flags = wxEXEC_ASYNC, int flags = wxEXEC_ASYNC,
wxProcess *process = NULL, wxProcess *process = NULL,
const wxExecuteEnv *env = NULL); const wxExecuteEnv *env = NULL);

View File

@@ -1184,10 +1184,10 @@ long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC,
In wxPerl this function is called @c Wx::ExecuteArgs. In wxPerl this function is called @c Wx::ExecuteArgs.
@endWxPerlOnly @endWxPerlOnly
*/ */
long wxExecute(char** argv, int flags = wxEXEC_ASYNC, long wxExecute(const char* const* argv, int flags = wxEXEC_ASYNC,
wxProcess* callback = NULL, wxProcess* callback = NULL,
const wxExecuteEnv *env = NULL); const wxExecuteEnv *env = NULL);
long wxExecute(wchar_t** argv, int flags = wxEXEC_ASYNC, long wxExecute(const wchar_t* const* argv, int flags = wxEXEC_ASYNC,
wxProcess* callback = NULL, wxProcess* callback = NULL,
const wxExecuteEnv *env = NULL); const wxExecuteEnv *env = NULL);
//@} //@}

View File

@@ -1071,7 +1071,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
} }
template <typename CharType> template <typename CharType>
long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler, long wxExecuteImpl(const CharType* const* argv, int flags, wxProcess* handler,
const wxExecuteEnv *env) const wxExecuteEnv *env)
{ {
wxString command; wxString command;
@@ -1114,7 +1114,7 @@ long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler,
return wxExecute(command, flags, handler, env); return wxExecute(command, flags, handler, env);
} }
long wxExecute(char **argv, int flags, wxProcess *handler, long wxExecute(const char* const* argv, int flags, wxProcess* handler,
const wxExecuteEnv *env) const wxExecuteEnv *env)
{ {
return wxExecuteImpl(argv, flags, handler, env); return wxExecuteImpl(argv, flags, handler, env);
@@ -1122,7 +1122,7 @@ long wxExecute(char **argv, int flags, wxProcess *handler,
#if wxUSE_UNICODE #if wxUSE_UNICODE
long wxExecute(wchar_t **argv, int flags, wxProcess *handler, long wxExecute(const wchar_t* const* argv, int flags, wxProcess* handler,
const wxExecuteEnv *env) const wxExecuteEnv *env)
{ {
return wxExecuteImpl(argv, flags, handler, env); return wxExecuteImpl(argv, flags, handler, env);

View File

@@ -68,12 +68,12 @@ wxSocketManager *wxOSXSocketManagerCF = NULL;
// process is the process passed from wxExecute for pipe streams etc. // process is the process passed from wxExecute for pipe streams etc.
// returns -1 on error for wxEXEC_SYNC and 0 on error for wxEXEC_ASYNC // returns -1 on error for wxEXEC_SYNC and 0 on error for wxEXEC_ASYNC
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bool wxMacLaunch(char **argv) bool wxMacLaunch(const char* const* argv)
{ {
// Obtains the number of arguments for determining the size of // Obtains the number of arguments for determining the size of
// the CFArray used to hold them // the CFArray used to hold them
CFIndex cfiCount = 0; CFIndex cfiCount = 0;
for(char** argvcopy = argv; *argvcopy != NULL ; ++argvcopy) for (const char* const* argvcopy = argv; *argvcopy != NULL; ++argvcopy)
{ {
++cfiCount; ++cfiCount;
} }

View File

@@ -409,7 +409,7 @@ public:
} }
#if wxUSE_UNICODE #if wxUSE_UNICODE
ArgsArray(wchar_t **wargv) ArgsArray(const wchar_t* const* wargv)
{ {
int argc = 0; int argc = 0;
while ( wargv[argc] ) while ( wargv[argc] )
@@ -434,7 +434,7 @@ public:
delete [] m_argv; delete [] m_argv;
} }
operator char**() const { return m_argv; } operator const char* const*() const { return m_argv; }
private: private:
void Init(int argc) void Init(int argc)
@@ -457,7 +457,7 @@ private:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if defined(__DARWIN__) && !defined(__WXOSX_IPHONE__) #if defined(__DARWIN__) && !defined(__WXOSX_IPHONE__)
bool wxMacLaunch(char **argv); bool wxMacLaunch(const char* const* argv);
#endif #endif
long wxExecute(const wxString& command, int flags, wxProcess *process, long wxExecute(const wxString& command, int flags, wxProcess *process,
@@ -471,7 +471,7 @@ long wxExecute(const wxString& command, int flags, wxProcess *process,
#if wxUSE_UNICODE #if wxUSE_UNICODE
long wxExecute(wchar_t **wargv, int flags, wxProcess *process, long wxExecute(const wchar_t* const* wargv, int flags, wxProcess* process,
const wxExecuteEnv *env) const wxExecuteEnv *env)
{ {
ArgsArray argv(wargv); ArgsArray argv(wargv);
@@ -559,7 +559,7 @@ int BlockUntilChildExit(wxExecuteData& execData)
} // anonymous namespace } // anonymous namespace
// wxExecute: the real worker function // wxExecute: the real worker function
long wxExecute(char **argv, int flags, wxProcess *process, long wxExecute(const char* const* argv, int flags, wxProcess* process,
const wxExecuteEnv *env) const wxExecuteEnv *env)
{ {
// for the sync execution, we return -1 to indicate failure, but for async // for the sync execution, we return -1 to indicate failure, but for async
@@ -743,10 +743,10 @@ long wxExecute(char **argv, int flags, wxProcess *process,
} }
} }
execvp(*argv, argv); execvp(*argv, const_cast<char**>(argv));
fprintf(stderr, "execvp("); fprintf(stderr, "execvp(");
for ( char **a = argv; *a; a++ ) for (const char* const* a = argv; *a; a++)
fprintf(stderr, "%s%s", a == argv ? "" : ", ", *a); fprintf(stderr, "%s%s", a == argv ? "" : ", ", *a);
fprintf(stderr, ") failed with error %d!\n", errno); fprintf(stderr, ") failed with error %d!\n", errno);