constify search_symbols
authorTom Tromey <tromey@redhat.com>
Thu, 28 Mar 2013 17:08:31 +0000 (11:08 -0600)
committerTom Tromey <tromey@redhat.com>
Mon, 30 Jun 2014 13:59:38 +0000 (07:59 -0600)
This constifies the parameters to search_symbols and fixes up the
fallout.

Tested by rebuilding.

2014-06-30  Tom Tromey  <tromey@redhat.com>

* symtab.c (operator_chars): Make parameters and return type
const.
(file_matches): Make "files" const.
(struct search_symbols_data) <files>: Now const.
(search_symbols): Make "regexp" and "files" parameters const.
Update.
(symtab_symbol_info): Remove cast.
(rbreak_command): Update.
* symtab.h (search_symbols): Update.

gdb/ChangeLog
gdb/symtab.c
gdb/symtab.h

index 8b7c5fa..8d304ac 100644 (file)
@@ -1,3 +1,15 @@
+2014-06-30  Tom Tromey  <tromey@redhat.com>
+
+       * symtab.c (operator_chars): Make parameters and return type
+       const.
+       (file_matches): Make "files" const.
+       (struct search_symbols_data) <files>: Now const.
+       (search_symbols): Make "regexp" and "files" parameters const.
+       Update.
+       (symtab_symbol_info): Remove cast.
+       (rbreak_command): Update.
+       * symtab.h (search_symbols): Update.
+
 2014-06-27  Yao Qi  <yao@codesourcery.com>
 
        * breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
index 655c6e8..09f3114 100644 (file)
@@ -3041,8 +3041,8 @@ skip_prologue_sal (struct symtab_and_line *sal)
    beginning of the substring of the operator text.
    Otherwise, return "".  */
 
-static char *
-operator_chars (char *p, char **end)
+static const char *
+operator_chars (const char *p, const char **end)
 {
   *end = "";
   if (strncmp (p, "operator", 8))
@@ -3062,7 +3062,7 @@ operator_chars (char *p, char **end)
 
   if (isalpha (*p) || *p == '_' || *p == '$')
     {
-      char *q = p + 1;
+      const char *q = p + 1;
 
       while (isalnum (*q) || *q == '_' || *q == '$')
        q++;
@@ -3341,7 +3341,7 @@ sources_info (char *ignore, int from_tty)
    non-zero compare only lbasename of FILES.  */
 
 static int
-file_matches (const char *file, char *files[], int nfiles, int basenames)
+file_matches (const char *file, const char *files[], int nfiles, int basenames)
 {
   int i;
 
@@ -3466,7 +3466,7 @@ sort_search_symbols_remove_dups (struct symbol_search *found, int nfound,
 struct search_symbols_data
 {
   int nfiles;
-  char **files;
+  const char **files;
 
   /* It is true if PREG contains valid data, false otherwise.  */
   unsigned preg_p : 1;
@@ -3511,8 +3511,8 @@ search_symbols_name_matches (const char *symname, void *user_data)
    Duplicate entries are removed.  */
 
 void
-search_symbols (char *regexp, enum search_domain kind,
-               int nfiles, char *files[],
+search_symbols (const char *regexp, enum search_domain kind,
+               int nfiles, const char *files[],
                struct symbol_search **matches)
 {
   struct symtab *s;
@@ -3562,8 +3562,8 @@ search_symbols (char *regexp, enum search_domain kind,
          This is just a courtesy to make the matching less sensitive
          to how many spaces the user leaves between 'operator'
          and <TYPENAME> or <OPERATOR>.  */
-      char *opend;
-      char *opname = operator_chars (regexp, &opend);
+      const char *opend;
+      const char *opname = operator_chars (regexp, &opend);
       int errcode;
 
       if (*opname)
@@ -3871,7 +3871,7 @@ symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
   gdb_assert (kind <= TYPES_DOMAIN);
 
   /* Must make sure that if we're interrupted, symbols gets freed.  */
-  search_symbols (regexp, kind, 0, (char **) NULL, &symbols);
+  search_symbols (regexp, kind, 0, NULL, &symbols);
   old_chain = make_cleanup_free_search_symbols (&symbols);
 
   if (regexp != NULL)
@@ -3950,7 +3950,8 @@ rbreak_command (char *regexp, int from_tty)
   struct cleanup *old_chain;
   char *string = NULL;
   int len = 0;
-  char **files = NULL, *file_name;
+  const char **files = NULL;
+  const char *file_name;
   int nfiles = 0;
 
   if (regexp)
@@ -3960,13 +3961,15 @@ rbreak_command (char *regexp, int from_tty)
       if (colon && *(colon + 1) != ':')
        {
          int colon_index;
+         char *local_name;
 
          colon_index = colon - regexp;
-         file_name = alloca (colon_index + 1);
-         memcpy (file_name, regexp, colon_index);
-         file_name[colon_index--] = 0;
-         while (isspace (file_name[colon_index]))
-           file_name[colon_index--] = 0; 
+         local_name = alloca (colon_index + 1);
+         memcpy (local_name, regexp, colon_index);
+         local_name[colon_index--] = 0;
+         while (isspace (local_name[colon_index]))
+           local_name[colon_index--] = 0;
+         file_name = local_name;
          files = &file_name;
          nfiles = 1;
          regexp = skip_spaces (colon + 1);
index 5a6f831..399ae54 100644 (file)
@@ -1356,8 +1356,8 @@ struct symbol_search
   struct symbol_search *next;
 };
 
-extern void search_symbols (char *, enum search_domain, int, char **,
-                           struct symbol_search **);
+extern void search_symbols (const char *, enum search_domain, int,
+                           const char **, struct symbol_search **);
 extern void free_search_symbols (struct symbol_search *);
 extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
                                                         **);