From 1f8cc6dbc0da3d3248de330289713ab6cebb21f2 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 12 Jun 2001 15:03:04 +0000 Subject: [PATCH] s/char */const char */ --- gdb/ChangeLog | 12 ++++++++++++ gdb/defs.h | 2 +- gdb/source.c | 17 ++++++++++------- gdb/symtab.c | 8 ++++---- gdb/symtab.h | 4 ++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9414c02d5c..6c35cb5a96 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +Mon Jun 11 17:26:43 2001 Andrew Cagney + + * source.c (openp): Make parameters ``path'' and ``string'' + constant. + (openp): Use alloca to safely duplicate ``string''. Make local + variables ``p'' and ``p1'' constant. Delete char* casts. + * defs.h: Update. + + * symtab.c (lookup_symtab_1): Make parameter ``name'' constant. + (lookup_symtab, lookup_partial_symtab): Ditto. + * symtab.h (lookup_symtab, lookup_partial_symtab): Update. + 2001-06-11 Andrew Cagney * ui-out.h (ui_out_table_begin): Make char* parameters constant. diff --git a/gdb/defs.h b/gdb/defs.h index 1694739407..56d8d7b4c8 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -698,7 +698,7 @@ extern void print_address (CORE_ADDR, struct ui_file *); /* From source.c */ -extern int openp (char *, int, char *, int, int, char **); +extern int openp (const char *, int, const char *, int, int, char **); extern int source_full_path_of (char *, char **); diff --git a/gdb/source.c b/gdb/source.c index ebc82dc88f..8d705dba5d 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -515,12 +515,14 @@ source_info (char *ignore, int from_tty) /* >>>> This should only allow files of certain types, >>>> eg executable, non-directory */ int -openp (char *path, int try_cwd_first, char *string, int mode, int prot, +openp (const char *path, int try_cwd_first, const char *string, + int mode, int prot, char **filename_opened) { register int fd; register char *filename; - register char *p, *p1; + const char *p; + const char *p1; register int len; int alloclen; @@ -534,7 +536,8 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, if (try_cwd_first || IS_ABSOLUTE_PATH (string)) { int i; - filename = string; + filename = alloca (strlen (string) + 1); + strcpy (filename, string); fd = open (filename, mode, prot); if (fd >= 0) goto done; @@ -548,11 +551,11 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, string += 2; alloclen = strlen (path) + strlen (string) + 2; - filename = (char *) alloca (alloclen); + filename = alloca (alloclen); fd = -1; for (p = path; p; p = p1 ? p1 + 1 : 0) { - p1 = (char *) strchr (p, DIRNAME_SEPARATOR); + p1 = strchr (p, DIRNAME_SEPARATOR); if (p1) len = p1 - p; else @@ -570,7 +573,7 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, if (newlen > alloclen) { alloclen = newlen; - filename = (char *) alloca (alloclen); + filename = alloca (alloclen); } strcpy (filename, current_directory); } @@ -597,7 +600,7 @@ done: if (filename_opened) { if (fd < 0) - *filename_opened = (char *) 0; + *filename_opened = NULL; else if (IS_ABSOLUTE_PATH (filename)) *filename_opened = savestring (filename, strlen (filename)); else diff --git a/gdb/symtab.c b/gdb/symtab.c index 3b3bb54727..437576384a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -79,7 +79,7 @@ static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *, const char *, int, namespace_enum); -static struct symtab *lookup_symtab_1 (char *); +static struct symtab *lookup_symtab_1 (const char *); static struct symbol *lookup_symbol_aux (const char *name, const struct block *block, const @@ -138,7 +138,7 @@ cplusplus_hint (char *name) in the symtab filename will also work. */ static struct symtab * -lookup_symtab_1 (char *name) +lookup_symtab_1 (const char *name) { register struct symtab *s; register struct partial_symtab *ps; @@ -192,7 +192,7 @@ got_symtab: of variations if the first lookup doesn't work. */ struct symtab * -lookup_symtab (char *name) +lookup_symtab (const char *name) { register struct symtab *s; #if 0 @@ -229,7 +229,7 @@ lookup_symtab (char *name) in the psymtab filename will also work. */ struct partial_symtab * -lookup_partial_symtab (char *name) +lookup_partial_symtab (const char *name) { register struct partial_symtab *pst; register struct objfile *objfile; diff --git a/gdb/symtab.h b/gdb/symtab.h index f76062806d..d85add3b3e 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1072,7 +1072,7 @@ extern int asm_demangle; /* lookup a symbol table by source file name */ -extern struct symtab *lookup_symtab (char *); +extern struct symtab *lookup_symtab (const char *); /* lookup a symbol by name (optional block, optional symtab) */ @@ -1122,7 +1122,7 @@ find_pc_sect_partial_function (CORE_ADDR, asection *, /* lookup partial symbol table by filename */ -extern struct partial_symtab *lookup_partial_symtab (char *); +extern struct partial_symtab *lookup_partial_symtab (const char *); /* lookup partial symbol table by address */