]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/completer.h
Fix latent bug with custom word point completers
[thirdparty/binutils-gdb.git] / gdb / completer.h
index 73c0f4c7832b518ea073c53f24dcb8d7cd9d5f93..27371b63a5763ff28c19350e1b92a4ae2038964b 100644 (file)
@@ -1,5 +1,5 @@
 /* Header for GDB line completion.
-   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 #if !defined (COMPLETER_H)
 #define COMPLETER_H 1
 
-#include "gdb_vecs.h"
+#include "common/gdb_vecs.h"
 #include "command.h"
 
 /* Types of functions in struct match_list_displayer.  */
@@ -319,7 +319,8 @@ public:
      it is not there already.  If too many completions were already
      found, this throws an error.  */
   void add_completion (gdb::unique_xmalloc_ptr<char> name,
-                      completion_match_for_lcd *match_for_lcd = NULL);
+                      completion_match_for_lcd *match_for_lcd = NULL,
+                      const char *text = NULL, const char *word = NULL);
 
   /* Add all completions matches in LIST.  Elements are moved out of
      LIST.  */
@@ -356,7 +357,7 @@ public:
   { m_custom_word_point = point; }
 
   /* Advance the custom word point by LEN.  */
-  void advance_custom_word_point_by (size_t len);
+  void advance_custom_word_point_by (int len);
 
   /* Whether to tell readline to skip appending a whitespace after the
      completion.  See m_suppress_append_ws.  */
@@ -406,7 +407,8 @@ private:
      it is not there already.  If false is returned, too many
      completions were found.  */
   bool maybe_add_completion (gdb::unique_xmalloc_ptr<char> name,
-                            completion_match_for_lcd *match_for_lcd);
+                            completion_match_for_lcd *match_for_lcd,
+                            const char *text, const char *word);
 
   /* Given a new match, recompute the lowest common denominator (LCD)
      to hand over to readline.  Normally readline computes this itself
@@ -418,7 +420,8 @@ private:
      "std::vector<..>::push_back", "std::string::push_back", etc., and
      in this case we want the lowest common denominator to be
      "push_back" instead of "std::".  */
-  void recompute_lowest_common_denominator (const char *new_match);
+  void recompute_lowest_common_denominator
+    (gdb::unique_xmalloc_ptr<char> &&new_match);
 
   /* Completion match outputs returned by the symbol name matching
      routines (see symbol_name_matcher_ftype).  These results are only
@@ -507,6 +510,13 @@ extern void complete_line (completion_tracker &tracker,
                           const char *line_buffer,
                           int point);
 
+/* Complete LINE and return completion results.  For completion purposes,
+   cursor position is assumed to be at the end of LINE.  WORD is set to
+   the end of word to complete.  QUOTE_CHAR is set to the opening quote
+   character if we found an unclosed quoted substring, '\0' otherwise.  */
+extern completion_result
+  complete (const char *line, char const **word, int *quote_char);
+
 /* Find the bounds of the word in TEXT for completion purposes, and
    return a pointer to the end of the word.  Calls the completion
    machinery for a handle_brkchars phase (using TRACKER) to figure out