Add support for disassembling WebAssembly opcodes.
[deliverable/binutils-gdb.git] / gdb / completer.c
index f13289a61bb7eed41231ececaf1f6ca70568ccf7..7e46416b1c7eef243a5b894be46e9befcae63074 100644 (file)
@@ -1,5 +1,5 @@
 /* Line completion stuff for GDB, the GNU debugger.
-   Copyright (C) 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -84,29 +84,30 @@ char *line_completion_function (const char *text, int matches,
    readline library sees one in any of the current completion strings,
    it thinks that the string needs to be quoted and automatically
    supplies a leading quote.  */
-static char *gdb_completer_command_word_break_characters =
+static const char gdb_completer_command_word_break_characters[] =
 " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";
 
 /* When completing on file names, we remove from the list of word
    break characters any characters that are commonly used in file
    names, such as '-', '+', '~', etc.  Otherwise, readline displays
    incorrect completion candidates.  */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
 /* MS-DOS and MS-Windows use colon as part of the drive spec, and most
    programs support @foo style response files.  */
-static char *gdb_completer_file_name_break_characters = " \t\n*|\"';?><@";
+static const char gdb_completer_file_name_break_characters[] =
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  " \t\n*|\"';?><@";
 #else
-static char *gdb_completer_file_name_break_characters = " \t\n*|\"';:?><";
+  " \t\n*|\"';:?><";
 #endif
 
 /* Characters that can be used to quote completion strings.  Note that
    we can't include '"' because the gdb C parser treats such quoted
    sequences as strings.  */
-static char *gdb_completer_quote_characters = "'";
+static const char gdb_completer_quote_characters[] = "'";
 \f
 /* Accessor for some completer data that may interest other files.  */
 
-char *
+const char *
 get_gdb_completer_quote_characters (void)
 {
   return gdb_completer_quote_characters;
@@ -264,7 +265,8 @@ linespec_location_completer (struct cmd_list_element *ignore,
       char *s;
 
       file_to_match = (char *) xmalloc (colon - text + 1);
-      strncpy (file_to_match, text, colon - text + 1);
+      strncpy (file_to_match, text, colon - text);
+      file_to_match[colon - text] = '\0';
       /* Remove trailing colons and quotes from the file name.  */
       for (s = file_to_match + (colon - text);
           s > file_to_match;
@@ -610,8 +612,7 @@ expression_completer (struct cmd_list_element *ignore,
       for (;;)
        {
          type = check_typedef (type);
-         if (TYPE_CODE (type) != TYPE_CODE_PTR
-             && TYPE_CODE (type) != TYPE_CODE_REF)
+         if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_IS_REFERENCE (type))
            break;
          type = TYPE_TARGET_TYPE (type);
        }
@@ -651,17 +652,27 @@ expression_completer (struct cmd_list_element *ignore,
 
 /* See definition in completer.h.  */
 
+void
+set_rl_completer_word_break_characters (const char *break_chars)
+{
+  rl_completer_word_break_characters = (char *) break_chars;
+}
+
+/* See definition in completer.h.  */
+
 void
 set_gdb_completion_word_break_characters (completer_ftype *fn)
 {
+  const char *break_chars;
+
   /* So far we are only interested in differentiating filename
      completers from everything else.  */
   if (fn == filename_completer)
-    rl_completer_word_break_characters
-      = gdb_completer_file_name_break_characters;
+    break_chars = gdb_completer_file_name_break_characters;
   else
-    rl_completer_word_break_characters
-      = gdb_completer_command_word_break_characters;
+    break_chars = gdb_completer_command_word_break_characters;
+
+  set_rl_completer_word_break_characters (break_chars);
 }
 
 /* Here are some useful test cases for completion.  FIXME: These
@@ -743,8 +754,8 @@ complete_line_internal (const char *text,
      then we will switch to the special word break set for command
      strings, which leaves out the '-' character used in some
      commands.  */
-  rl_completer_word_break_characters =
-    current_language->la_word_break_characters();
+  set_rl_completer_word_break_characters
+    (current_language->la_word_break_characters());
 
   /* Decide whether to complete on a list of gdb commands or on
      symbols.  */
@@ -821,8 +832,8 @@ complete_line_internal (const char *text,
            }
          /* Ensure that readline does the right thing with respect to
             inserting quotes.  */
-         rl_completer_word_break_characters =
-           gdb_completer_command_word_break_characters;
+         set_rl_completer_word_break_characters
+           (gdb_completer_command_word_break_characters);
        }
     }
   else
@@ -848,8 +859,8 @@ complete_line_internal (const char *text,
 
                  /* Ensure that readline does the right thing
                     with respect to inserting quotes.  */
-                 rl_completer_word_break_characters =
-                   gdb_completer_command_word_break_characters;
+                 set_rl_completer_word_break_characters
+                   (gdb_completer_command_word_break_characters);
                }
              else if (reason == handle_help)
                list = NULL;
@@ -857,8 +868,8 @@ complete_line_internal (const char *text,
                {
                  if (reason != handle_brkchars)
                    list = complete_on_enum (c->enums, p, word);
-                 rl_completer_word_break_characters =
-                   gdb_completer_command_word_break_characters;
+                 set_rl_completer_word_break_characters
+                   (gdb_completer_command_word_break_characters);
                }
              else
                {
@@ -879,8 +890,8 @@ complete_line_internal (const char *text,
                             && strchr (gdb_completer_file_name_break_characters, p[-1]) == NULL;
                           p--)
                        ;
-                     rl_completer_word_break_characters =
-                       gdb_completer_file_name_break_characters;
+                     set_rl_completer_word_break_characters
+                       (gdb_completer_file_name_break_characters);
                    }
                  if (reason == handle_brkchars
                      && c->completer_handle_brkchars != NULL)
@@ -913,8 +924,8 @@ complete_line_internal (const char *text,
 
              /* Ensure that readline does the right thing
                 with respect to inserting quotes.  */
-             rl_completer_word_break_characters =
-               gdb_completer_command_word_break_characters;
+             set_rl_completer_word_break_characters
+               (gdb_completer_command_word_break_characters);
            }
        }
       else if (reason == handle_help)
@@ -947,8 +958,8 @@ complete_line_internal (const char *text,
                                    p[-1]) == NULL;
                       p--)
                    ;
-                 rl_completer_word_break_characters =
-                   gdb_completer_file_name_break_characters;
+                 set_rl_completer_word_break_characters
+                   (gdb_completer_file_name_break_characters);
                }
              if (reason == handle_brkchars
                  && c->completer_handle_brkchars != NULL)
@@ -985,7 +996,7 @@ new_completion_tracker (void)
 static void
 free_completion_tracker (void *p)
 {
-  completion_tracker_t *tracker_ptr = p;
+  completion_tracker_t *tracker_ptr = (completion_tracker_t *) p;
 
   htab_delete (*tracker_ptr);
   *tracker_ptr = NULL;
@@ -1149,11 +1160,12 @@ signal_completer (struct cmd_list_element *ignore,
 /* Bit-flags for selecting what the register and/or register-group
    completer should complete on.  */
 
-enum reg_completer_targets
+enum reg_completer_target
   {
     complete_register_names = 0x1,
     complete_reggroup_names = 0x2
   };
+DEF_ENUM_FLAGS_TYPE (enum reg_completer_target, reg_completer_targets);
 
 /* Complete register names and/or reggroup names based on the value passed
    in TARGETS.  At least one bit in TARGETS must be set.  */
@@ -1161,7 +1173,7 @@ enum reg_completer_targets
 static VEC (char_ptr) *
 reg_or_group_completer_1 (struct cmd_list_element *ignore,
                          const char *text, const char *word,
-                         enum reg_completer_targets targets)
+                         reg_completer_targets targets)
 {
   VEC (char_ptr) *result = NULL;
   size_t len = strlen (word);
@@ -1672,7 +1684,8 @@ gdb_print_filename (char *to_print, char *full_pathname, int prefix_bytes,
                    const struct match_list_displayer *displayer)
 {
   int printed_len, extension_char, slen, tlen;
-  char *s, c, *new_full_pathname, *dn;
+  char *s, c, *new_full_pathname;
+  const char *dn;
   extern int _rl_complete_mark_directories;
 
   extension_char = 0;
This page took 0.039856 seconds and 4 git commands to generate.