summaryrefslogtreecommitdiff
path: root/gdb/cli/cli-setshow.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2007-11-17 00:57:01 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2007-11-17 00:57:01 +0000
commit27ec42ccb6fe2e67cfd4109419af79f5ce53b057 (patch)
tree348b68135552971bd97903a3afc195c6263b3754 /gdb/cli/cli-setshow.c
parent1ba8bda81d31ed0e72c70eae63e829808a700b0d (diff)
downloadgdb-27ec42ccb6fe2e67cfd4109419af79f5ce53b057.tar.gz
* cli/cli-setshow.c (do_setshow_command): Use dynamically sized buffer
to construct error message if no argument was supplied.
Diffstat (limited to 'gdb/cli/cli-setshow.c')
-rw-r--r--gdb/cli/cli-setshow.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 54f2bd41a5b..6d62a23d042 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -242,16 +242,22 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
/* 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, ' ');