+2021-05-05 Mike Frysinger <vapier@gentoo.org>
+
+ * gdb-if.c: Include libiberty.h.
+ (sim_do_command): Rewrite to use buildargv.
+
2021-05-04 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
#include <ctype.h>
#include "ansidecl.h"
+#include "libiberty.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
void
sim_do_command (SIM_DESC sd, const char *cmd)
{
- const char *args;
- char *p = strdup (cmd);
+ const char *arg;
+ char **argv = buildargv (cmd);
check_desc (sd);
- /* Skip leading whitespace. */
- while (isspace (*p))
- p++;
-
- /* Find the extent of the command word. */
- for (p = cmd; *p; p++)
- if (isspace (*p))
- break;
-
- /* Null-terminate the command word, and record the start of any
- further arguments. */
- if (*p)
+ cmd = arg = "";
+ if (argv != NULL)
{
- *p = '\0';
- args = p + 1;
- while (isspace (*args))
- args++;
+ if (argv[0] != NULL)
+ cmd = argv[0];
+ if (argv[1] != NULL)
+ arg = argv[1];
}
- else
- args = p;
if (strcmp (cmd, "trace") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
trace = 1;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
trace = 0;
else
printf ("The 'sim trace' command expects 'on' or 'off' "
}
else if (strcmp (cmd, "verbose") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
verbose = 1;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
verbose = 0;
else
printf ("The 'sim verbose' command expects 'on' or 'off'"
printf ("The 'sim' command expects either 'trace' or 'verbose'"
" as a subcommand.\n");
- free (p);
+ freeargv (argv);
}
char **
+2021-05-05 Mike Frysinger <vapier@gentoo.org>
+
+ * gdb-if.c: Include libiberty.h.
+ (sim_do_command): Rewrite to use buildargv.
+
2021-05-04 Mike Frysinger <vapier@gentoo.org>
* cpu.c (trace_register_init): Add missing (void).
#include <stdlib.h>
#include "ansidecl.h"
+#include "libiberty.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
void
sim_do_command (SIM_DESC sd, const char *cmd)
{
- const char *args;
- char *p = strdup (cmd);
+ const char *arg;
+ char **argv = buildargv (cmd);
check_desc (sd);
- if (cmd == NULL)
+ cmd = arg = "";
+ if (argv != NULL)
{
- cmd = "";
- args = "";
- }
- else
- {
- /* Skip leading whitespace. */
- while (isspace (*p))
- p++;
-
- /* Null-terminate the command word, and record the start of any
- further arguments. */
- if (*p)
- {
- *p = '\0';
- args = p + 1;
- while (isspace (*args))
- args++;
- }
- else
- args = p;
+ if (argv[0] != NULL)
+ cmd = argv[0];
+ if (argv[1] != NULL)
+ arg = argv[1];
}
if (strcmp (cmd, "trace") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
trace = 1;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
trace = 0;
else
printf ("The 'sim trace' command expects 'on' or 'off' "
}
else if (strcmp (cmd, "verbose") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
verbose = 1;
- else if (strcmp (args, "noisy") == 0)
+ else if (strcmp (arg, "noisy") == 0)
verbose = 2;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
verbose = 0;
else
printf ("The 'sim verbose' command expects 'on', 'noisy', or 'off'"
printf ("The 'sim' command expects either 'trace' or 'verbose'"
" as a subcommand.\n");
- free (p);
+ freeargv (argv);
}
/* Stub for command completion. */
+2021-05-05 Mike Frysinger <vapier@gentoo.org>
+
+ * gdb-if.c: Include libiberty.h.
+ (sim_do_command): Rewrite to use buildargv.
+
2021-05-04 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
#include <stdlib.h>
#include "ansidecl.h"
+#include "libiberty.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
void
sim_do_command (SIM_DESC sd, const char *cmd)
{
- const char *args;
- char *p = strdup (cmd);
+ const char *arg;
+ char **argv = buildargv (cmd);
check_desc (sd);
- /* Skip leading whitespace. */
- while (isspace (*p))
- p++;
-
- /* Find the extent of the command word. */
- for (; *p != '\0'; p++)
- if (isspace (*p))
- break;
-
- /* Null-terminate the command word, and record the start of any
- further arguments. */
- if (*p != '\0')
+ cmd = arg = "";
+ if (argv != NULL)
{
- *p = '\0';
- args = p + 1;
- while (isspace (*args))
- args++;
+ if (argv[0] != NULL)
+ cmd = argv[0];
+ if (argv[1] != NULL)
+ arg = argv[1];
}
- else
- args = p;
if (strcmp (cmd, "trace") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
trace = 1;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
trace = 0;
else
printf ("The 'sim trace' command expects 'on' or 'off' "
}
else if (strcmp (cmd, "verbose") == 0)
{
- if (strcmp (args, "on") == 0)
+ if (strcmp (arg, "on") == 0)
verbose = 1;
- else if (strcmp (args, "noisy") == 0)
+ else if (strcmp (arg, "noisy") == 0)
verbose = 2;
- else if (strcmp (args, "off") == 0)
+ else if (strcmp (arg, "off") == 0)
verbose = 0;
else
printf ("The 'sim verbose' command expects 'on', 'noisy', or 'off'"
printf ("The 'sim' command expects either 'trace' or 'verbose'"
" as a subcommand.\n");
- free (p);
+ freeargv (argv);
}
char **