diff options
author | Tom Tromey <tromey@redhat.com> | 2012-06-13 15:47:16 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-06-13 15:47:16 +0000 |
commit | 49c4e619f81a66545e2332dc218d9bf31bbb51ad (patch) | |
tree | 7eb2c5e41613a35d7030005bbc19bb23414065ed /gdb/interps.c | |
parent | 625e8578d7514d65901421467d2b6f0f5d87f634 (diff) | |
download | gdb-49c4e619f81a66545e2332dc218d9bf31bbb51ad.zip gdb-49c4e619f81a66545e2332dc218d9bf31bbb51ad.tar.gz gdb-49c4e619f81a66545e2332dc218d9bf31bbb51ad.tar.bz2 |
* 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)
<la_make_symbol_completion_list>: 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) <list_used, list_alloced>: Remove.
<list>: 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.
Diffstat (limited to 'gdb/interps.c')
-rw-r--r-- | gdb/interps.c | 39 |
1 files changed, 11 insertions, 28 deletions
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; } |