From a81aaca0578ee91ce1cee56c0a31e26c2a5ef581 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 25 Nov 2017 00:20:31 +0000 Subject: Fix completing an empty string Earlier while working on the big completer rework series, I managed to break (gdb) [TAB] locally, and make GDB crash, but only notice a few weeks down the road, because we have no test for that... I also noticed that: (gdb) [TAB] didn't work (didn't show all commands as matches), even though entering a command with leading whitespace works: (gdb) help This commit fixes the latter and adds a testcase that covers both issues. The gdb.base/completion.exp change is necessary because the new test has a file name that also starts with "gdb.base/complet", making that particular test ambiguous. Adding another letter disambiguates. gdb/ChangeLog: 2017-11-25 Pedro Alves * completer.c (complete_line_internal_1): Skip spaces until the start of the command. gdb/testsuite/ChangeLog: 2017-11-25 Pedro Alves * gdb.base/complete-empty.exp: New file. * gdb.base/completion.exp: Adjust. --- gdb/completer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gdb/completer.c') diff --git a/gdb/completer.c b/gdb/completer.c index 68e9171..f9ece59 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1270,10 +1270,13 @@ complete_line_internal_1 (completion_tracker &tracker, word = tmp_command + point - strlen (text); } - if (point == 0) + /* Move P up to the start of the command. */ + p = skip_spaces (p); + + if (*p == '\0') { - /* An empty line we want to consider ambiguous; that is, it - could be any command. */ + /* An empty line is ambiguous; that is, it could be any + command. */ c = CMD_LIST_AMBIGUOUS; result_list = 0; } -- cgit v1.1