+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>
* ui-out.h (ui_out_table_begin): Make char* parameters constant.
/* 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 **);
/* >>>> 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;
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;
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
if (newlen > alloclen)
{
alloclen = newlen;
- filename = (char *) alloca (alloclen);
+ filename = alloca (alloclen);
}
strcpy (filename, current_directory);
}
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
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
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;
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
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;
/* 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 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 */