From bda180e01110741f20d30b95c3ae0d93e957de8a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 7 Aug 2009 23:28:13 +0000 Subject: gdb * language.c (set_language_command): Strip whitespace. (set_type_command): Likewise. (set_range_command): Likewise. gdb/testsuite * gdb.base/setshow.exp: Add tests for changes to set language, set check range, and set check type. --- gdb/language.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'gdb/language.c') diff --git a/gdb/language.c b/gdb/language.c index a6c6165..04c2fe4 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -150,11 +150,21 @@ show_language_command (struct ui_file *file, int from_tty, static void set_language_command (char *ignore, int from_tty, struct cmd_list_element *c) { - int i; + int i, len; enum language flang; - char *err_lang; + char *err_lang, *tem; + + /* Strip trailing whitespace. */ + if (!language) + len = 0; + else + { + len = strlen (language); + while (len > 0 && language[len - 1] == ' ') + --len; + } - if (!language || !language[0]) + if (len == 0) { printf_unfiltered (_("\ The currently understood settings are:\n\n\ @@ -181,6 +191,11 @@ local or auto Automatic setting based on source file\n")); return; } + /* Reset LANGUAGE to avoid trailing spaces. */ + tem = savestring (language, len); + xfree (language); + language = tem; + /* Search the list of languages for a match. */ for (i = 0; i < languages_size; i++) { @@ -251,6 +266,18 @@ show_type_command (struct ui_file *file, int from_tty, static void set_type_command (char *ignore, int from_tty, struct cmd_list_element *c) { + int len; + char *tem; + + /* Strip trailing whitespace. */ + len = strlen (type); + while (len > 0 && type[len - 1] == ' ') + --len; + /* Reset TYPE. */ + tem = savestring (type, len); + xfree (type); + type = tem; + if (strcmp (type, "on") == 0) { type_check = type_check_on; @@ -298,6 +325,18 @@ show_range_command (struct ui_file *file, int from_tty, static void set_range_command (char *ignore, int from_tty, struct cmd_list_element *c) { + int len; + char *tem; + + /* Strip trailing whitespace. */ + len = strlen (range); + while (len > 0 && range[len - 1] == ' ') + --len; + /* Reset RANGE. */ + tem = savestring (range, len); + xfree (range); + range = tem; + if (strcmp (range, "on") == 0) { range_check = range_check_on; -- cgit v1.1