diff options
author | Pedro Alves <palves@redhat.com> | 2017-07-17 15:30:59 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-07-17 15:30:59 +0100 |
commit | 6a2c1b8790e58ce0688507b5b1f8369aa621a665 (patch) | |
tree | 4dc87fb939c2d320c05fa0ef224528c5ee936856 /gdb/completer.h | |
parent | eb3ff9a55175dcdac8328b558d54951a14d719b1 (diff) | |
download | binutils-6a2c1b8790e58ce0688507b5b1f8369aa621a665.zip binutils-6a2c1b8790e58ce0688507b5b1f8369aa621a665.tar.gz binutils-6a2c1b8790e58ce0688507b5b1f8369aa621a665.tar.bz2 |
"complete" command and completion word break characters
The linespec/locations/completer testcase added later in the series
tests every completion with both TAB completion and the "complete"
command. This exposed problems in the "complete" command, around
determining the completion word point.
First, the complete command has a too-simple approximation of what
readline's TAB-completion code does to find the completion word point.
Unfortunately, readline doesn't expose the functionality it uses
internally, so to fix this this patch copies over the relevant code,
and adjusts it a bit to better fit the use cases we need it for.
(Specifically, our version avoids relying on the
rl_word_break_characters, etc. globals, and instead takes those as
arguments.)
A following patch will want to use this function for TAB-completion
too, but the "complete" command was a good excuse to split this to a
separate patch.
Then, notice how the complete_command does not call into the completer
for the command being completed to determine the right set of word
break characters. It always uses the default set. That is fixed by
having the "complete" command call into complete_line_internal for a
full handle_brkchars phase, just TAB-completion.
gdb/ChangeLog:
2017-07-17 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (complete_command): Use a completion tracker
along with completion_find_completion_word for handle_brkchars
phase.
* completer.c (RL_QF_SINGLE_QUOTE, RL_QF_DOUBLE_QUOTE)
(RL_QF_BACKSLASH, RL_QF_OTHER_QUOTE): New.
(struct gdb_rl_completion_word_info): New.
(gdb_rl_find_completion_word): New.
(completion_find_completion_word): New.
* completer.h (completion_find_completion_word): Declare.
Diffstat (limited to 'gdb/completer.h')
-rw-r--r-- | gdb/completer.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/completer.h b/gdb/completer.h index 4b3b188..cf93cf0 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -203,6 +203,16 @@ extern void complete_line (completion_tracker &tracker, const char *line_buffer, int point); +/* Find the bounds of the word in TEXT for completion purposes, and + return a pointer to the end of the word. Calls the completion + machinery for a handle_brkchars phase (using TRACKER) to figure out + the right work break characters for the command in TEXT. + QUOTE_CHAR, if non-null, is set to the opening quote character if + we found an unclosed quoted substring, '\0' otherwise. */ +extern const char *completion_find_completion_word (completion_tracker &tracker, + const char *text, + int *quote_char); + extern char **gdb_rl_attempted_completion_function (const char *text, int start, int end); |