+/* See complete.h. */
+
+completion_result
+complete (const char *line, char const **word, int *quote_char)
+{
+ completion_tracker tracker_handle_brkchars;
+ completion_tracker tracker_handle_completions;
+ completion_tracker *tracker;
+
+ /* The WORD should be set to the end of word to complete. We initialize
+ to the completion point which is assumed to be at the end of LINE.
+ This leaves WORD to be initialized to a sensible value in cases
+ completion_find_completion_word() fails i.e., throws an exception.
+ See bug 24587. */
+ *word = line + strlen (line);
+
+ try
+ {
+ *word = completion_find_completion_word (tracker_handle_brkchars,
+ line, quote_char);
+
+ /* Completers that provide a custom word point in the
+ handle_brkchars phase also compute their completions then.
+ Completers that leave the completion word handling to readline
+ must be called twice. */
+ if (tracker_handle_brkchars.use_custom_word_point ())
+ tracker = &tracker_handle_brkchars;
+ else
+ {
+ complete_line (tracker_handle_completions, *word, line, strlen (line));
+ tracker = &tracker_handle_completions;
+ }
+ }
+ catch (const gdb_exception &ex)
+ {
+ return {};
+ }
+
+ return tracker->build_completion_result (*word, *word - line, strlen (line));
+}
+
+