[RFC] Cleanup for make_source_files_completion_list

Keith Seitz keiths@redhat.com
Tue May 7 19:46:00 GMT 2013


Hi,

make_source_files_completion_list is only ever called with the first 
parameter twice, e.g.,

   fn_list = make_source_files_completion_list (text, text);

Is there any reason to not whack the second parameter as the following 
patch does?

Keith

ChangeLog
2013-05-07  Keith Seitz  <keiths@redhat.com>

	* symtab.h (make_source_files_completion_list): Remove unused
	second parameter.
	* completer.c (location_completer): Update call to
	make_source_files_completion_list.
	* symtab.c (maybe_add_partial_symtab_filename): Likewise.
	(make_source_files_completion_list): Remove unused second
	parameter.
	Pass text to add_filename_to_list instead of word.
	Set datum.word to text, too.

diff --git a/gdb/symtab.h b/gdb/symtab.h
index c735e16..8703f77 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1241,8 +1241,7 @@ extern VEC (char_ptr) 
*make_file_symbol_completion_list (const char *,
  							 const char *,
  							 const char *);

-extern VEC (char_ptr) *make_source_files_completion_list (const char *,
-							  const char *);
+extern VEC (char_ptr) *make_source_files_completion_list (const char *);

  /* symtab.c */

diff --git a/gdb/completer.c b/gdb/completer.c
index e132651..b4845cb 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);
      }

    n_syms = VEC_length (char_ptr, list);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index def556b..201fa82 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4682,7 +4682,7 @@ maybe_add_partial_symtab_filename (const char 
*filename, const char *fullname,
     NULL.  */

  VEC (char_ptr) *
-make_source_files_completion_list (const char *text, const char *word)
+make_source_files_completion_list (const char *text)
  {
    struct symtab *s;
    struct objfile *objfile;
@@ -4711,7 +4711,7 @@ make_source_files_completion_list (const char 
*text, const char *word)
  	{
  	  /* This file matches for a completion; add it to the current
  	     list of matches.  */
-	  add_filename_to_list (s->filename, text, word, &list);
+	  add_filename_to_list (s->filename, text, text, &list);
  	}
        else
  	{
@@ -4723,13 +4723,13 @@ make_source_files_completion_list (const char 
*text, const char *word)
  	  if (base_name != s->filename
  	      && !filename_seen (filename_seen_cache, base_name, 1)
  	      && filename_ncmp (base_name, text, text_len) == 0)
-	    add_filename_to_list (base_name, text, word, &list);
+	    add_filename_to_list (base_name, text, text, &list);
  	}
      }

    datum.filename_seen_cache = filename_seen_cache;
    datum.text = text;
-  datum.word = word;
+  datum.word = text;
    datum.text_len = text_len;
    datum.list = &list;
    map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum,



More information about the Gdb-patches mailing list