s/char */const char */

This commit is contained in:
Andrew Cagney 2001-06-12 15:03:04 +00:00
parent 11f6f21d46
commit 1f8cc6dbc0
5 changed files with 29 additions and 14 deletions

View file

@ -1,3 +1,15 @@
Mon Jun 11 17:26:43 2001 Andrew Cagney <cagney@b1.cygnus.com>
* 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 <ac131313@redhat.com> 2001-06-11 Andrew Cagney <ac131313@redhat.com>
* ui-out.h (ui_out_table_begin): Make char* parameters constant. * ui-out.h (ui_out_table_begin): Make char* parameters constant.

View file

@ -698,7 +698,7 @@ extern void print_address (CORE_ADDR, struct ui_file *);
/* From source.c */ /* 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 **); extern int source_full_path_of (char *, char **);

View file

@ -515,12 +515,14 @@ source_info (char *ignore, int from_tty)
/* >>>> This should only allow files of certain types, /* >>>> This should only allow files of certain types,
>>>> eg executable, non-directory */ >>>> eg executable, non-directory */
int 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) char **filename_opened)
{ {
register int fd; register int fd;
register char *filename; register char *filename;
register char *p, *p1; const char *p;
const char *p1;
register int len; register int len;
int alloclen; 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)) if (try_cwd_first || IS_ABSOLUTE_PATH (string))
{ {
int i; int i;
filename = string; filename = alloca (strlen (string) + 1);
strcpy (filename, string);
fd = open (filename, mode, prot); fd = open (filename, mode, prot);
if (fd >= 0) if (fd >= 0)
goto done; goto done;
@ -548,11 +551,11 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot,
string += 2; string += 2;
alloclen = strlen (path) + strlen (string) + 2; alloclen = strlen (path) + strlen (string) + 2;
filename = (char *) alloca (alloclen); filename = alloca (alloclen);
fd = -1; fd = -1;
for (p = path; p; p = p1 ? p1 + 1 : 0) for (p = path; p; p = p1 ? p1 + 1 : 0)
{ {
p1 = (char *) strchr (p, DIRNAME_SEPARATOR); p1 = strchr (p, DIRNAME_SEPARATOR);
if (p1) if (p1)
len = p1 - p; len = p1 - p;
else else
@ -570,7 +573,7 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot,
if (newlen > alloclen) if (newlen > alloclen)
{ {
alloclen = newlen; alloclen = newlen;
filename = (char *) alloca (alloclen); filename = alloca (alloclen);
} }
strcpy (filename, current_directory); strcpy (filename, current_directory);
} }
@ -597,7 +600,7 @@ done:
if (filename_opened) if (filename_opened)
{ {
if (fd < 0) if (fd < 0)
*filename_opened = (char *) 0; *filename_opened = NULL;
else if (IS_ABSOLUTE_PATH (filename)) else if (IS_ABSOLUTE_PATH (filename))
*filename_opened = savestring (filename, strlen (filename)); *filename_opened = savestring (filename, strlen (filename));
else else

View file

@ -79,7 +79,7 @@ static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
const char *, int, const char *, int,
namespace_enum); 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 static struct symbol *lookup_symbol_aux (const char *name, const
struct block *block, const struct block *block, const
@ -138,7 +138,7 @@ cplusplus_hint (char *name)
in the symtab filename will also work. */ in the symtab filename will also work. */
static struct symtab * static struct symtab *
lookup_symtab_1 (char *name) lookup_symtab_1 (const char *name)
{ {
register struct symtab *s; register struct symtab *s;
register struct partial_symtab *ps; register struct partial_symtab *ps;
@ -192,7 +192,7 @@ got_symtab:
of variations if the first lookup doesn't work. */ of variations if the first lookup doesn't work. */
struct symtab * struct symtab *
lookup_symtab (char *name) lookup_symtab (const char *name)
{ {
register struct symtab *s; register struct symtab *s;
#if 0 #if 0
@ -229,7 +229,7 @@ lookup_symtab (char *name)
in the psymtab filename will also work. */ in the psymtab filename will also work. */
struct partial_symtab * struct partial_symtab *
lookup_partial_symtab (char *name) lookup_partial_symtab (const char *name)
{ {
register struct partial_symtab *pst; register struct partial_symtab *pst;
register struct objfile *objfile; register struct objfile *objfile;

View file

@ -1072,7 +1072,7 @@ extern int asm_demangle;
/* lookup a symbol table by source file name */ /* 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) */ /* 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 */ /* 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 */ /* lookup partial symbol table by address */