From patchwork Fri Jun 20 17:24:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1619 Received: (qmail 1321 invoked by alias); 20 Jun 2014 17:24:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 1290 invoked by uid 89); 20 Jun 2014 17:24:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 20 Jun 2014 17:24:28 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5KHOQFJ010592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 20 Jun 2014 13:24:26 -0400 Received: from barimba.redhat.com (ovpn-113-103.phx2.redhat.com [10.3.113.103]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5KHOQhH022123; Fri, 20 Jun 2014 13:24:26 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] constify search_symbols Date: Fri, 20 Jun 2014 11:24:20 -0600 Message-Id: <1403285060-5556-1-git-send-email-tromey@redhat.com> This constifies the parameters to search_symbols and fixes up the fallout. Tested by rebuilding. 2014-06-20 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/symtab.c b/gdb/symtab.c index 655c6e8..09f3114 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 5a6f831..399ae54 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 **);