/* Handle set and show GDB commands.
- Copyright (C) 2000-2013 Free Software Foundation, Inc.
+ Copyright (C) 2000-2014 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "readline/tilde.h"
#include "value.h"
#include <ctype.h>
-#include "gdb_string.h"
+#include <string.h>
#include "arch-utils.h"
#include "observer.h"
#include "cli/cli-decode.h"
#include "cli/cli-cmds.h"
#include "cli/cli-setshow.h"
+#include "cli/cli-utils.h"
/* Return true if the change of command parameter should be notified. */
/* See cli-setshow.h. */
int
-parse_cli_boolean_value (char *arg)
+parse_cli_boolean_value (const char *arg)
{
int length;
}
}
+/* Returns true if ARG is "unlimited". */
+
+static int
+is_unlimited_literal (const char *arg)
+{
+ size_t len = sizeof ("unlimited") - 1;
+
+ arg = skip_spaces_const (arg);
+
+ return (strncmp (arg, "unlimited", len) == 0
+ && (isspace (arg[len]) || arg[len] == '\0'));
+}
+
+
/* Do a "set" command. ARG is NULL if no argument, or the
text of the argument, and FROM_TTY is nonzero if this command is
being entered directly by the user (i.e. these are just like any
other command). C is the command list element for the command. */
void
-do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
+do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
{
/* A flag to indicate the option is changed or not. */
int option_changed = 0;
case var_string:
{
char *new;
- char *p;
+ const char *p;
char *q;
int ch;
if (arg != NULL)
{
/* Clear trailing whitespace of filename. */
- char *ptr = arg + strlen (arg) - 1;
+ const char *ptr = arg + strlen (arg) - 1;
+ char *copy;
while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
ptr--;
- *(ptr + 1) = '\0';
+ copy = xstrndup (arg, ptr + 1 - arg);
- val = tilde_expand (arg);
+ val = tilde_expand (copy);
+ xfree (copy);
}
else
val = xstrdup ("");
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ {
+ if (c->var_type == var_uinteger)
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+ else
+ error_no_arg (_("integer to set it to."));
+ }
+
+ if (c->var_type == var_uinteger && is_unlimited_literal (arg))
+ val = 0;
+ else
+ val = parse_and_eval_long (arg);
if (c->var_type == var_uinteger && val == 0)
val = UINT_MAX;
- /* For var_uinteger, don't let the user set the value to
- UINT_MAX directly, as that exposes an implementation detail
- to the user interface. */
- else if ((c->var_type == var_uinteger && val >= UINT_MAX)
+ else if (val < 0
+ /* For var_uinteger, don't let the user set the value
+ to UINT_MAX directly, as that exposes an
+ implementation detail to the user interface. */
+ || (c->var_type == var_uinteger && val >= UINT_MAX)
|| (c->var_type == var_zuinteger && val > UINT_MAX))
error (_("integer %s out of range"), plongest (val));
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ {
+ if (c->var_type == var_integer)
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+ else
+ error_no_arg (_("integer to set it to."));
+ }
+
+ if (c->var_type == var_integer && is_unlimited_literal (arg))
+ val = 0;
+ else
+ val = parse_and_eval_long (arg);
if (val == 0 && c->var_type == var_integer)
val = INT_MAX;
- /* For var_integer, don't let the user set the value to
- INT_MAX directly, as that exposes an implementation detail
- to the user interface. */
- else if ((c->var_type == var_integer && val >= INT_MAX)
- || (c->var_type == var_zinteger && val > INT_MAX)
- || val < INT_MIN)
+ else if (val < INT_MIN
+ /* For var_integer, don't let the user set the value
+ to INT_MAX directly, as that exposes an
+ implementation detail to the user interface. */
+ || (c->var_type == var_integer && val >= INT_MAX)
+ || (c->var_type == var_zinteger && val > INT_MAX))
error (_("integer %s out of range"), plongest (val));
if (*(int *) c->var != val)
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+
+ if (is_unlimited_literal (arg))
+ val = -1;
+ else
+ val = parse_and_eval_long (arg);
if (val > INT_MAX)
error (_("integer %s out of range"), plongest (val));
error (_("gdb internal error: bad var_type in do_setshow_command"));
}
c->func (c, NULL, from_tty);
- if (deprecated_set_hook)
- deprecated_set_hook (c);
if (notify_command_param_changed_p (option_changed, c))
{
other command). C is the command list element for the command. */
void
-do_show_command (char *arg, int from_tty, struct cmd_list_element *c)
+do_show_command (const char *arg, int from_tty, struct cmd_list_element *c)
{
struct ui_out *uiout = current_uiout;
struct cleanup *old_chain;
/* Show all the settings in a list of show commands. */
void
-cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix)
+cmd_show_list (struct cmd_list_element *list, int from_tty, const char *prefix)
{
struct cleanup *showlist_chain;
struct ui_out *uiout = current_uiout;