+ else if (c->enums)
+ {
+ if (reason != handle_brkchars)
+ list = complete_on_enum (c->enums, p, word);
+ }
+ else
+ {
+ /* It is a normal command. */
+ if (c->completer == filename_completer)
+ {
+ /* See the commentary above about the specifics
+ of file-name completion. */
+ for (p = word;
+ p > tmp_command
+ && strchr (gdb_completer_file_name_break_characters, p[-1]) == NULL;
+ p--)
+ ;
+ rl_completer_word_break_characters =
+ gdb_completer_file_name_break_characters;
+ }
+ else if (c->completer == location_completer)
+ {
+ for (p = word;
+ p > tmp_command
+ && p[-1] != ' ' && p[-1] != '\t';
+ p--)
+ ;
+ }
+ if (reason != handle_brkchars && c->completer != NULL)
+ list = (*c->completer) (c, p, word);
+ }
+ }
+ }
+
+ return list;
+}
+/* Generate completions all at once. Returns a NULL-terminated array
+ of strings. Both the array and each element are allocated with
+ xmalloc. It can also return NULL if there are no completions.
+
+ TEXT is the caller's idea of the "word" we are looking at.
+
+ LINE_BUFFER is available to be looked at; it contains the entire text
+ of the line.
+
+ POINT is the offset in that line of the cursor. You
+ should pretend that the line ends at POINT. */
+
+char **
+complete_line (const char *text, char *line_buffer, int point)
+{
+ return complete_line_internal (text, line_buffer, point, handle_completions);
+}
+
+/* Complete on command names. Used by "help". */
+char **
+command_completer (struct cmd_list_element *ignore, char *text, char *word)
+{
+ return complete_line_internal (word, text, strlen (text), handle_help);
+}
+
+/* Get the list of chars that are considered as word breaks
+ for the current command. */
+
+char *
+gdb_completion_word_break_characters (void)
+{
+ char **list;
+
+ list = complete_line_internal (rl_line_buffer, rl_line_buffer, rl_point,
+ handle_brkchars);
+ gdb_assert (list == NULL);
+ return rl_completer_word_break_characters;
+}
+
+/* Generate completions one by one for the completer. Each time we are
+ called return another potential completion to the caller.
+ line_completion just completes on commands or passes the buck to the
+ command's completer function, the stuff specific to symbol completion
+ is in make_symbol_completion_list.
+
+ TEXT is the caller's idea of the "word" we are looking at.
+
+ MATCHES is the number of matches that have currently been collected from
+ calling this completion function. When zero, then we need to initialize,
+ otherwise the initialization has already taken place and we can just
+ return the next potential completion string.
+
+ LINE_BUFFER is available to be looked at; it contains the entire text
+ of the line. POINT is the offset in that line of the cursor. You
+ should pretend that the line ends at POINT.
+
+ Returns NULL if there are no more completions, else a pointer to a string
+ which is a possible completion, it is the caller's responsibility to
+ free the string. */
+
+static char *
+line_completion_function (const char *text, int matches,
+ char *line_buffer, int point)
+{
+ static char **list = (char **) NULL; /* Cache of completions. */
+ static int index; /* Next cached completion. */
+ char *output = NULL;
+
+ if (matches == 0)
+ {
+ /* The caller is beginning to accumulate a new set of completions, so
+ we need to find all of them now, and cache them for returning one at
+ a time on future calls. */
+
+ if (list)
+ {
+ /* Free the storage used by LIST, but not by the strings inside.
+ This is because rl_complete_internal () frees the strings.
+ As complete_line may abort by calling `error' clear LIST now. */
+ xfree (list);
+ list = NULL;