diff options
author | Pedro Alves <palves@redhat.com> | 2019-06-13 00:06:53 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2019-06-13 00:18:09 +0100 |
commit | 2c722807a752ce468b04fcf6d29857f377beeaf5 (patch) | |
tree | 68e88585cf81f0389104360d4208dd3c7b4b6e8c | |
parent | dee7b4c83a636471ee321fb4fe1c3be0a16a9ea7 (diff) | |
download | gdb-2c722807a752ce468b04fcf6d29857f377beeaf5.zip gdb-2c722807a752ce468b04fcf6d29857f377beeaf5.tar.gz gdb-2c722807a752ce468b04fcf6d29857f377beeaf5.tar.bz2 |
number_or_range_parser::get_number, don't treat "1 -" as a range
While adding -OPT options to "frame apply level", I noticed that:
(gdb) frame apply level 0 -[TAB]
wasn't completing on the supported options. This commit fixes it.
We'll get instead:
(gdb) frame apply level 0 -
-c -past-entry -past-main -q -s
I added the isspace check because this case:
(gdb) frame apply level 0-
can't be an option.
Tests for this will be in a new gdb.base/options.exp file, in a
following patch. It will exercise all of:
(gdb) frame apply level 0-
(gdb) frame apply level 0 -
(gdb) frame apply level 0 --
(gdb) frame apply level 0 -- -
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-utils.c (number_or_range_parser::get_number): Do not
parse a range if "-" is at the end of the string.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/cli/cli-utils.c | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 63a3690..73fd65e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2019-06-13 Pedro Alves <palves@redhat.com> + * cli/cli-utils.c (number_or_range_parser::get_number): Do not + parse a range if "-" is at the end of the string. + +2019-06-13 Pedro Alves <palves@redhat.com> + * cli/cli-setshow.c (parse_auto_binary_operation) (parse_cli_boolean_value): Don't allow "o". diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index a24fe92..23296ce 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -233,10 +233,18 @@ number_or_range_parser::get_number () /* Default case: state->m_cur_tok is pointing either to a solo number, or to the first number of a range. */ m_last_retval = get_number_trailer (&m_cur_tok, '-'); - /* If get_number_trailer has found a -, it might be the start - of a command option. So, do not parse a range if the - is - followed by an alpha. */ - if (*m_cur_tok == '-' && !isalpha (*(m_cur_tok + 1))) + /* If get_number_trailer has found a '-' preceded by a space, it + might be the start of a command option. So, do not parse a + range if the '-' is followed by an alpha or another '-'. We + might also be completing something like + "frame apply level 0 -" and we prefer treating that "-" as an + option rather than an incomplete range, so check for end of + string as well. */ + if (m_cur_tok[0] == '-' + && !(isspace (m_cur_tok[-1]) + && (isalpha (m_cur_tok[1]) + || m_cur_tok[1] == '-' + || m_cur_tok[1] == '\0'))) { const char **temp; |