/* Handle set and show GDB commands.
- Copyright (c) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (c) 2000, 2001, 2002, 2003, 2007, 2008, 2009
+ 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
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "readline/tilde.h"
error_no_arg (_("filename to set it to."));
if (*(char **) c->var != NULL)
xfree (*(char **) c->var);
+ {
+ /* Clear trailing whitespace of filename. */
+ char *ptr = arg + strlen (arg) - 1;
+ while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+ ptr--;
+ *(ptr + 1) = '\0';
+ }
*(char **) c->var = tilde_expand (arg);
break;
case var_boolean:
error_no_arg (_("integer to set it to."));
*(int *) c->var = parse_and_eval_long (arg);
break;
+ case var_zuinteger:
+ if (arg == NULL)
+ error_no_arg (_("integer to set it to."));
+ *(unsigned int *) c->var = parse_and_eval_long (arg);
+ break;
case var_enum:
{
int i;
/* if no argument was supplied, print an informative error message */
if (arg == NULL)
{
- char msg[1024];
- strcpy (msg, "Requires an argument. Valid arguments are ");
+ char *msg;
+ int msg_len = 0;
+ for (i = 0; c->enums[i]; i++)
+ msg_len += strlen (c->enums[i]) + 2;
+
+ msg = xmalloc (msg_len);
+ *msg = '\0';
+ make_cleanup (xfree, msg);
+
for (i = 0; c->enums[i]; i++)
{
if (i != 0)
strcat (msg, ", ");
strcat (msg, c->enums[i]);
}
- strcat (msg, ".");
- error (("%s"), msg);
+ error (_("Requires an argument. Valid arguments are %s."), msg);
}
p = strchr (arg, ' ');
break;
}
/* else fall through */
+ case var_zuinteger:
case var_zinteger:
fprintf_filtered (stb->stream, "%u", *(unsigned int *) c->var);
break;
/* Close the tuple. */
do_cleanups (optionlist_chain);
}
- if (list->type == show_cmd)
+ else
{
struct cleanup *option_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "option");
ui_out_text (uiout, prefix);
ui_out_field_string (uiout, "name", list->name);
ui_out_text (uiout, ": ");
- do_setshow_command ((char *) NULL, from_tty, list);
+ if (list->type == show_cmd)
+ do_setshow_command ((char *) NULL, from_tty, list);
+ else
+ cmd_func (list, NULL, from_tty);
/* Close the tuple. */
do_cleanups (option_chain);
}