diff options
author | Tom Tromey <tromey@redhat.com> | 2009-08-07 23:28:13 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2009-08-07 23:28:13 +0000 |
commit | bda180e01110741f20d30b95c3ae0d93e957de8a (patch) | |
tree | bfa2107e37d41e98f38a05d6323f23e822b5d94a | |
parent | 6cc0b2563e4aae5352e78e09370a0ba59feb26fc (diff) | |
download | binutils-gdb-bda180e01110741f20d30b95c3ae0d93e957de8a.tar.gz |
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.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/language.c | 45 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/setshow.exp | 15 |
4 files changed, 68 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 74af7e0fe57..c19632f4822 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2009-08-07 Tom Tromey <tromey@redhat.com> + * language.c (set_language_command): Strip whitespace. + (set_type_command): Likewise. + (set_range_command): Likewise. + +2009-08-07 Tom Tromey <tromey@redhat.com> + PR gdb/8869: * language.c (language_completer): New function. (range_or_type_completer): New function. diff --git a/gdb/language.c b/gdb/language.c index a6c6165248c..04c2fe48d3a 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; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 32a421bcc9e..7993ac5cca6 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-08-07 Tom Tromey <tromey@redhat.com> + + * gdb.base/setshow.exp: Add tests for changes to set language, set + check range, and set check type. + 2009-08-03 Vladimir Prus <vladimir@codesourcery.com> * lib/mi-support.exp (mi_list_breakpoints): Make it work. diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index 5630da38579..b405178b5db 100644 --- a/gdb/testsuite/gdb.base/setshow.exp +++ b/gdb/testsuite/gdb.base/setshow.exp @@ -104,6 +104,10 @@ if { ![target_info exists use_gdb_stub] && ![target_info exists noargs] } { gdb_test "set check range on" "" "set check range on" #test show check range on gdb_test "show check range" "Range checking is \"on\"\..*" "show check range (on)" +#test set check range off with trailing space +gdb_test "set check range off " "" "set check range off" +#test show check range off +gdb_test "show check range" "Range checking is \"off\"\..*" "show check range (off)" #test set check range auto gdb_test "set check range auto" "" "set check range auto" #test show check range auto @@ -112,6 +116,10 @@ gdb_test "show check range" "Range checking is \"auto; currently .*" "show check gdb_test "set check type on" "" "set check type on" #test show check type on gdb_test "show check type" "Type checking is \"on\"..*" "show check type (on)" +#test set check type off with trailing space +gdb_test "set check type off " "" "set check type off" +#test show check type off +gdb_test "show check type" "Type checking is \"off\"..*" "show check type (off)" #test set check type auto gdb_test "set check type auto" "" "set check type auto" #test show check type @@ -170,6 +178,13 @@ gdb_test "show history size" "The size of the command history is 100..*" "show h gdb_test "set language asm" "" "set language asm" #test show language asm gdb_test "show language" "The current source language is \"asm\"..*" "show language (asm)" +#test set language java, with a trailing space +gdb_test "set language java " "" "set language java" +#test show language java +gdb_test "show language" "The current source language is \"java\"..*" "show language (java)" +#test completion for set language. +gdb_test "complete set language min" "set language minimal" \ + "complete set language minimal" #test set language auto gdb_test "set language auto" "" "set language auto" #test show language |