This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Cleanup for make_source_files_completion_list
- From: Keith Seitz <keiths at redhat dot com>
- To: Doug Evans <dje at google dot com>
- Cc: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Mon, 13 May 2013 14:11:17 -0700
- Subject: Re: [RFC] Cleanup for make_source_files_completion_list
- References: <51895A2F dot 8000504 at redhat dot com> <CADPb22Sj_5Bp+FhoQYk_9vR5c1D3fXsw4gLFu7v+jmDNSaOPFg at mail dot gmail dot com> <5191340B dot 60100 at redhat dot com>
On 05/13/2013 11:42 AM, Keith Seitz wrote:
However, I think that the comment quoted above (and the surrounding
block of code which does the copying) should be removed and the callers
of make_source_files_completion list should pass text AND word instead
of text and text. add_filename_to_list (in symtab.c) does this text -
word adjustment already, so it is not necessary to repeat it here. WDYT?
Something like this? [This causes no regressions in the test suite or by
manually hacking at it.]
Keith
ChangeLog
2013-05-13 Keith Seitz <keiths@redhat.com>
* completer.c (location_completer): Pass 'word' to
make_source_files_completion_list.
Do not adjust filenames -- add_filename_to_list, called
from make_source_files_completion_list, will do it.
diff --git a/gdb/completer.c b/gdb/completer.c
index e132651..28d27f8 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -270,7 +270,7 @@ location_completer (struct cmd_list_element *ignore,
name, they cannot be asking for completion on files. */
if (strcspn (text,
gdb_completer_file_name_break_characters) == text_len)
- fn_list = make_source_files_completion_list (text, text);
+ fn_list = make_source_files_completion_list (text, word);
}
n_syms = VEC_length (char_ptr, list);
@@ -296,32 +296,7 @@ location_completer (struct cmd_list_element *ignore,
{
/* Nothing. */
}
- else if (n_files)
- {
- char *fn;
-
- /* If we only have file names as possible completion, we should
- bring them in sync with what rl_complete expects. The
- problem is that if the user types "break /foo/b TAB", and the
- possible completions are "/foo/bar" and "/foo/baz"
- rl_complete expects us to return "bar" and "baz", without the
- leading directories, as possible completions, because `word'
- starts at the "b". But we ignore the value of `word' when we
- call make_source_files_completion_list above (because that
- would not DTRT when the completion results in both symbols
- and file names), so make_source_files_completion_list returns
- the full "/foo/bar" and "/foo/baz" strings. This produces
- wrong results when, e.g., there's only one possible
- completion, because rl_complete will prepend "/foo/" to each
- candidate completion. The loop below removes that leading
- part. */
- for (ix = 0; VEC_iterate (char_ptr, list, ix, fn); ++ix)
- {
- memmove (fn, fn + (word - text),
- strlen (fn) + 1 - (word - text));
- }
- }
- else if (!n_syms)
+ else if (!n_syms && !n_files)
{
/* No completions at all. As the final resort, try completing
on the entire text as a symbol. */