From 961427268a863e614a79f25449e79d54696690ad Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 28 Mar 2013 11:08:31 -0600 Subject: [PATCH] constify search_symbols This constifies the parameters to search_symbols and fixes up the fallout. Tested by rebuilding. 2014-06-30 Tom Tromey * symtab.c (operator_chars): Make parameters and return type const. (file_matches): Make "files" const. (struct search_symbols_data) : 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 | 12 ++++++++++++ gdb/symtab.c | 35 +++++++++++++++++++---------------- gdb/symtab.h | 4 ++-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8b7c5fa343..8d304ac5fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2014-06-30 Tom Tromey + + * symtab.c (operator_chars): Make parameters and return type + const. + (file_matches): Make "files" const. + (struct search_symbols_data) : 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 * breakpoint.c (check_longjmp_breakpoint_for_call_dummy): diff --git a/gdb/symtab.c b/gdb/symtab.c index 655c6e83ea..09f3114164 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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 or . */ - 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); diff --git a/gdb/symtab.h b/gdb/symtab.h index 5a6f83106d..399ae548c0 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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 **); -- 2.34.1