Constify strings in tracepoint.c, lookup_cmd and the completers.
[deliverable/binutils-gdb.git] / gdb / completer.c
index 3b14fc942342af4876a6729e43975849eb3fd3dc..e13265131a4a29e79275766e8add43f4d00e484f 100644 (file)
@@ -107,7 +107,7 @@ readline_line_completion_function (const char *text, int matches)
    symbols but don't want to complete on anything else either.  */
 VEC (char_ptr) *
 noop_completer (struct cmd_list_element *ignore, 
-               char *text, char *prefix)
+               const char *text, const char *prefix)
 {
   return NULL;
 }
@@ -115,7 +115,7 @@ noop_completer (struct cmd_list_element *ignore,
 /* Complete on filenames.  */
 VEC (char_ptr) *
 filename_completer (struct cmd_list_element *ignore, 
-                   char *text, char *word)
+                   const char *text, const char *word)
 {
   int subsequent_name;
   VEC (char_ptr) *return_val = NULL;
@@ -184,19 +184,19 @@ filename_completer (struct cmd_list_element *ignore,
 
 VEC (char_ptr) *
 location_completer (struct cmd_list_element *ignore, 
-                   char *text, char *word)
+                   const char *text, const char *word)
 {
   int n_syms, n_files, ix;
   VEC (char_ptr) *fn_list = NULL;
   VEC (char_ptr) *list = NULL;
-  char *p;
+  const char *p;
   int quote_found = 0;
   int quoted = *text == '\'' || *text == '"';
   int quote_char = '\0';
-  char *colon = NULL;
+  const char *colon = NULL;
   char *file_to_match = NULL;
-  char *symbol_start = text;
-  char *orig_text = text;
+  const char *symbol_start = text;
+  const char *orig_text = text;
   size_t text_len;
 
   /* Do we have an unquoted colon, as in "break foo.c:bar"?  */
@@ -285,8 +285,10 @@ location_completer (struct cmd_list_element *ignore,
     }
   else
     {
-      for (ix = 0; VEC_iterate (char_ptr, fn_list, ix, p); ++ix)
-       VEC_safe_push (char_ptr, list, p);
+      char *fn;
+
+      for (ix = 0; VEC_iterate (char_ptr, fn_list, ix, fn); ++ix)
+       VEC_safe_push (char_ptr, list, fn);
       VEC_free (char_ptr, fn_list);
     }
 
@@ -296,6 +298,8 @@ location_completer (struct cmd_list_element *ignore,
     }
   else if (n_files)
     {
+      char *fn;
+
       /* If we only have file names as possible completion, we should
         bring them in sync with what rl_complete expects.  The
         problem is that if the user types "break /foo/b TAB", and the
@@ -311,10 +315,10 @@ location_completer (struct cmd_list_element *ignore,
         completion, because rl_complete will prepend "/foo/" to each
         candidate completion.  The loop below removes that leading
         part.  */
-      for (ix = 0; VEC_iterate (char_ptr, list, ix, p); ++ix)
+      for (ix = 0; VEC_iterate (char_ptr, list, ix, fn); ++ix)
        {
-         memmove (p, p + (word - text),
-                  strlen (p) + 1 - (word - text));
+         memmove (fn, fn + (word - text),
+                  strlen (fn) + 1 - (word - text));
        }
     }
   else if (!n_syms)
@@ -385,10 +389,11 @@ add_struct_fields (struct type *type, VEC (char_ptr) **output,
    field names.  */
 VEC (char_ptr) *
 expression_completer (struct cmd_list_element *ignore, 
-                     char *text, char *word)
+                     const char *text, const char *word)
 {
   struct type *type = NULL;
-  char *fieldname, *p;
+  char *fieldname;
+  const char *p;
   volatile struct gdb_exception except;
   enum type_code code = TYPE_CODE_UNDEF;
 
@@ -506,11 +511,12 @@ complete_line_internal_reason;
 
 static VEC (char_ptr) *
 complete_line_internal (const char *text, 
-                       char *line_buffer, int point,
+                       const char *line_buffer, int point,
                        complete_line_internal_reason reason)
 {
   VEC (char_ptr) *list = NULL;
-  char *tmp_command, *p;
+  char *tmp_command;
+  const char *p;
   int ignore_help_classes;
   /* Pointer within tmp_command which corresponds to text.  */
   char *word;
@@ -567,7 +573,7 @@ complete_line_internal (const char *text,
     }
   else if (c == CMD_LIST_AMBIGUOUS)
     {
-      char *q;
+      const char *q;
 
       /* lookup_cmd_1 advances p up to the first ambiguous thing, but
         doesn't advance over that thing itself.  Do so now.  */
@@ -682,7 +688,7 @@ complete_line_internal (const char *text,
                 complete on the command itself, e.g. "p" which is a
                 command itself but also can complete to "print", "ptype"
                 etc.  */
-             char *q;
+             const char *q;
 
              /* Find the command we are completing on.  */
              q = p;
@@ -775,7 +781,7 @@ complete_line (const char *text, char *line_buffer, int point)
 /* Complete on command names.  Used by "help".  */
 VEC (char_ptr) *
 command_completer (struct cmd_list_element *ignore, 
-                  char *text, char *word)
+                  const char *text, const char *word)
 {
   return complete_line_internal (word, text, 
                                 strlen (text), handle_help);
@@ -785,7 +791,7 @@ command_completer (struct cmd_list_element *ignore,
 
 VEC (char_ptr) *
 signal_completer (struct cmd_list_element *ignore,
-                 char *text, char *word)
+                 const char *text, const char *word)
 {
   VEC (char_ptr) *return_val = NULL;
   size_t len = strlen (word);
This page took 0.027744 seconds and 4 git commands to generate.