From 49c4e619f81a66545e2332dc218d9bf31bbb51ad Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 13 Jun 2012 15:47:16 +0000 Subject: * ada-lang.c (ada_make_symbol_completion_list): Return a VEC. * breakpoint.c (catch_syscall_completer): Return a VEC. * cli/cli-cmds.c (complete_command): Update. * cli/cli-decode.c (complete_on_cmdlist): Return a VEC. (complete_on_enum): Likewise. * command.h: Include gdb_vecs.h. (completer_ftype): Change return type. (complete_on_cmdlist, complete_on_enum): Likewise. * completer.c (noop_completer, filename_completer) (location_completer): Return a VEC. (add_struct_fields): Remove 'nextp' argument. Change 'output' to a VEC. (expression_completer, complete_line_internal, complete_line) (command_completer): Return a VEC. (gdb_completion_word_break_characters, line_completion_function): Update. * completer.h: Include gdb_vecs.h. (complete_line, noop_completer, filename_completer) (expression_completer, location_completer, command_completer): Update. * f-lang.c (f_word_break_characters): Return a VEC. * interps.c (interpreter_completer): Return a VEC. * language.h (struct language_defn) : Return a VEC. * python/py-cmd.c (cmdpy_completer): Return a VEC. * symtab.c (free_completion_list): Take a VEC. (return_val_size, return_val_index): Remove. (return_val): Now a VEC. (completion_list_add_name): Update. (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_list_fn, make_file_symbol_completion_list): Return a VEC. (add_filename_to_list): Update. (struct add_partial_filename_data) : Remove. : Now a VEC. (maybe_add_partial_symtab_filename): Update. (make_source_files_completion_list): Return a VEC. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_list_fn, make_file_symbol_completion_list) (make_source_files_completion_list): Update. --- gdb/interps.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'gdb/interps.c') diff --git a/gdb/interps.c b/gdb/interps.c index 23e5a10..9b24c59 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -73,8 +73,6 @@ struct interp /* Functions local to this file. */ static void initialize_interps (void); -static char **interpreter_completer (struct cmd_list_element *cmd, - char *text, char *word); /* The magic initialization routine for this module. */ @@ -445,54 +443,39 @@ interpreter_exec_cmd (char *args, int from_tty) } /* List the possible interpreters which could complete the given text. */ -static char ** +static VEC (char_ptr) * interpreter_completer (struct cmd_list_element *ignore, char *text, char *word) { - int alloced = 0; int textlen; - int num_matches; - char **matches; + VEC (char_ptr) *matches = NULL; struct interp *interp; - /* We expect only a very limited number of interpreters, so just - allocate room for all of them plus one for the last that must be NULL - to correctly end the list. */ - for (interp = interp_list; interp != NULL; interp = interp->next) - ++alloced; - matches = (char **) xcalloc (alloced + 1, sizeof (char *)); - - num_matches = 0; textlen = strlen (text); for (interp = interp_list; interp != NULL; interp = interp->next) { if (strncmp (interp->name, text, textlen) == 0) { - matches[num_matches] = - (char *) xmalloc (strlen (word) + strlen (interp->name) + 1); + char *match; + + match = (char *) xmalloc (strlen (word) + strlen (interp->name) + 1); if (word == text) - strcpy (matches[num_matches], interp->name); + strcpy (match, interp->name); else if (word > text) { /* Return some portion of interp->name. */ - strcpy (matches[num_matches], interp->name + (word - text)); + strcpy (match, interp->name + (word - text)); } else { /* Return some of text plus interp->name. */ - strncpy (matches[num_matches], word, text - word); - matches[num_matches][text - word] = '\0'; - strcat (matches[num_matches], interp->name); + strncpy (match, word, text - word); + match[text - word] = '\0'; + strcat (match, interp->name); } - ++num_matches; + VEC_safe_push (char_ptr, matches, match); } } - if (num_matches == 0) - { - xfree (matches); - matches = NULL; - } - return matches; } -- cgit v1.1