{
if (current_inferior ()->argc != 0)
{
- std::string n = construct_inferior_arguments (current_inferior ()->argc,
- current_inferior ()->argv);
+ gdb::array_view<char * const> args (current_inferior ()->argv,
+ current_inferior ()->argc);
+ std::string n = construct_inferior_arguments (args);
set_inferior_args (n.c_str ());
}
+2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
+
+ * common-inferior.cc, common-inferior.h (construct_inferior_arguments):
+ Adapt to take a gdb::array_view<char * const> parameter.
+ Adapt call site.
+
2020-05-25 Michael Weghorn <m.weghorn@posteo.de>
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
/* See common-inferior.h. */
std::string
-construct_inferior_arguments (int argc, char * const *argv)
+construct_inferior_arguments (gdb::array_view<char * const> argv)
{
- gdb_assert (argc >= 0);
-
std::string result;
if (startup_with_shell)
static const char special[] = "\"!#$&*()\\|[]{}<>?'`~^; \t\n";
static const char quote = '\'';
#endif
- for (int i = 0; i < argc; ++i)
+ for (int i = 0; i < argv.size (); ++i)
{
if (i > 0)
result += ' ';
{
/* In this case we can't handle arguments that contain spaces,
tabs, or newlines -- see breakup_args(). */
- for (int i = 0; i < argc; ++i)
+ for (char *arg : argv)
{
- char *cp = strchr (argv[i], ' ');
+ char *cp = strchr (arg, ' ');
if (cp == NULL)
- cp = strchr (argv[i], '\t');
+ cp = strchr (arg, '\t');
if (cp == NULL)
- cp = strchr (argv[i], '\n');
+ cp = strchr (arg, '\n');
if (cp != NULL)
error (_("can't handle command-line "
"argument containing whitespace"));
}
- for (int i = 0; i < argc; ++i)
+ for (int i = 0; i < argv.size (); ++i)
{
if (i > 0)
result += " ";
#ifndef COMMON_COMMON_INFERIOR_H
#define COMMON_COMMON_INFERIOR_H
+#include "gdbsupport/array-view.h"
+
/* Return the exec wrapper to be used when starting the inferior, or NULL
otherwise. */
extern const char *get_exec_wrapper ();
/* Compute command-line string given argument vector. This does the
same shell processing as fork_inferior. */
-extern std::string construct_inferior_arguments (int, char * const *);
+extern std::string
+construct_inferior_arguments (gdb::array_view<char * const>);
#endif /* COMMON_COMMON_INFERIOR_H */