arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC
[deliverable/binutils-gdb.git] / gdb / completer.c
index c2bb4ee50dc1ebc0e7da3a67a7bbdb81b3775823..cd0ecc3acc440db53f2d64779d161f7408439c89 100644 (file)
@@ -45,9 +45,6 @@
 
 #include "completer.h"
 
-static void complete_expression (completion_tracker &tracker,
-                                const char *text, const char *word);
-
 /* Misc state that needs to be tracked across several different
    readline completer entry point calls, all related to a single
    completion invocation.  */
@@ -558,8 +555,46 @@ complete_files_symbols (completion_tracker &tracker,
     }
 }
 
+/* See completer.h.  */
+
+completion_list
+complete_source_filenames (const char *text)
+{
+  size_t text_len = strlen (text);
+
+  /* If text includes characters which cannot appear in a file name,
+     the user cannot be asking for completion on files.  */
+  if (strcspn (text,
+              gdb_completer_file_name_break_characters)
+      == text_len)
+    return make_source_files_completion_list (text, text);
+
+  return {};
+}
+
+/* Complete address and linespec locations.  */
+
+static void
+complete_address_and_linespec_locations (completion_tracker &tracker,
+                                        const char *text)
+{
+  if (*text == '*')
+    {
+      tracker.advance_custom_word_point_by (1);
+      text++;
+      const char *word
+       = advance_to_expression_complete_word_point (tracker, text);
+      complete_expression (tracker, text, word);
+    }
+  else
+    {
+      linespec_complete (tracker, text);
+    }
+}
+
 /* The explicit location options.  Note that indexes into this array
    must match the explicit_location_match_type enumerators.  */
+
 static const char *const explicit_options[] =
   {
     "-source",
@@ -664,7 +699,7 @@ collect_explicit_location_matches (completion_tracker &tracker,
             keyword.  */
          if (keyword != word)
            {
-             keyword = skip_spaces_const (keyword);
+             keyword = skip_spaces (keyword);
 
              tracker.advance_custom_word_point_by (keyword - word);
              complete_on_enum (tracker, linespec_keywords, keyword, keyword);
@@ -694,7 +729,7 @@ skip_keyword (completion_tracker &tracker,
              const char * const *keywords, const char **text_p)
 {
   const char *text = *text_p;
-  const char *after = skip_to_space_const (text);
+  const char *after = skip_to_space (text);
   size_t len = after - text;
 
   if (text[len] != ' ')
@@ -801,7 +836,7 @@ complete_explicit_location (completion_tracker &tracker,
 void
 location_completer (struct cmd_list_element *ignore,
                    completion_tracker &tracker,
-                   const char *text, const char *word_entry)
+                   const char *text, const char * /* word */)
 {
   int found_probe_option = -1;
 
@@ -872,27 +907,7 @@ location_completer (struct cmd_list_element *ignore,
   else
     {
       /* This is an address or linespec location.  */
-      if (*text == '*')
-       {
-         tracker.advance_custom_word_point_by (1);
-         text++;
-         const char *word
-           = advance_to_expression_complete_word_point (tracker, text);
-         complete_expression (tracker, text, word);
-       }
-      else
-       {
-         /* Fall back to the old linespec completer, for now.  */
-
-         if (word_entry == NULL)
-           {
-            /* We're in the handle_brkchars phase.  */
-             tracker.set_use_custom_word_point (false);
-             return;
-           }
-
-         complete_files_symbols (tracker, text, word_entry);
-       }
+      complete_address_and_linespec_locations (tracker, text);
     }
 
   /* Add matches for option names, if either:
@@ -984,11 +999,9 @@ add_struct_fields (struct type *type, completion_list &output,
     }
 }
 
-/* Complete on expressions.  Often this means completing on symbol
-   names, but some language parsers also have support for completing
-   field names.  */
+/* See completer.h.  */
 
-static void
+void
 complete_expression (completion_tracker &tracker,
                     const char *text, const char *word)
 {
@@ -1434,6 +1447,7 @@ complete_line_internal (completion_tracker &tracker,
       if (except.error != MAX_COMPLETIONS_REACHED_ERROR)
        throw_exception (except);
     }
+  END_CATCH
 }
 
 /* See completer.h.  */
@@ -1890,7 +1904,7 @@ expand_preserving_ws (const char *orig, size_t orig_len,
        {
          while (p_orig < orig_end && *p_orig == ' ')
            res += *p_orig++;
-         p_lcd = skip_spaces_const (p_lcd);
+         p_lcd = skip_spaces (p_lcd);
        }
       else
        {
@@ -1944,10 +1958,12 @@ completion_tracker::build_completion_result (const char *text,
                                buf, (char *) NULL);
       match_list[1] = NULL;
 
-      /* If we already have a space at the end of the match, tell
-        readline to skip appending another.  */
+      /* If the tracker wants to, or we already have a space at the
+        end of the match, tell readline to skip appending
+        another.  */
       bool completion_suppress_append
-       = (match_list[0][strlen (match_list[0]) - 1] == ' ');
+       = (suppress_append_ws ()
+          || match_list[0][strlen (match_list[0]) - 1] == ' ');
 
       return completion_result (match_list, 1, completion_suppress_append);
     }
@@ -2011,14 +2027,6 @@ completion_result::release_match_list ()
   return ret;
 }
 
-/* Compare C strings for std::sort.  */
-
-static bool
-compare_cstrings (const char *str1, const char *str2)
-{
-  return strcmp (str1, str2) < 0;
-}
-
 /* See completer.h  */
 
 void
@@ -2768,8 +2776,6 @@ gdb_display_match_list (char **matches, int len, int max,
        }
     }
 }
-\f
-extern initialize_file_ftype _initialize_completer; /* -Wmissing-prototypes */
 
 void
 _initialize_completer (void)
This page took 0.026019 seconds and 4 git commands to generate.