aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppfiles.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>1999-01-05 19:11:22 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>1999-01-05 19:11:22 +0000
commit460ee1120c62c6c543e8bdfac4ee287e754e3a61 (patch)
treef98dde49db8ef6f1d425e196eb7db84dab10c8b4 /gcc/cppfiles.c
parent258ce95eb63d074fc9d39d7e1f82316a4fb7874d (diff)
downloadgcc-460ee1120c62c6c543e8bdfac4ee287e754e3a61.zip
gcc-460ee1120c62c6c543e8bdfac4ee287e754e3a61.tar.gz
gcc-460ee1120c62c6c543e8bdfac4ee287e754e3a61.tar.bz2
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h. * cccp.c: Include prefix.h, don't prototype prefix.c functions. (new_include_prefix): Constify char* parameters. * cppfiles.c (read_name_map): Likewise. (append_include_chain): Likewise. Also, use a writable char* copy of parameter `dir' which we then modify, rather than using the parameter itself to store the new writable string. (remap_filename): Constify some variables. Also, use a writable char* to store an allocated string which we will be modifying. * cpplib.c: Include prefix.h, don't prototype prefix.c functions. (cpp_start_read): Constify variable `str'. * cpplib.h (append_include_chain): Constify a char* parameter. * gcc.c Include prefix.h, don't prototype prefix.c functions. (add_prefix, save_string): Constify char* parameters. (fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes. * prefix.c: Include prefix.h. (get_key_value, translate_name, save_string, update_path, set_std_prefix): Constify various char* parameters and variables. (save_string): Use xmalloc, not malloc. (translate_name): Use a writable temporary variable to create and modify a string before setting it to a const char*. * prefix.h: New file to prototype functions exported from prefix.c. From-SVN: r24498
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r--gcc/cppfiles.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 108bf87..169809d 100644
--- a/gcc/cppfiles.c
+++ b/gcc/cppfiles.c
@@ -36,7 +36,8 @@ static struct include_hash *redundant_include_p
PROTO ((cpp_reader *,
struct include_hash *,
struct file_name_list *));
-static struct file_name_map *read_name_map PROTO ((cpp_reader *, char *));
+static struct file_name_map *read_name_map PROTO ((cpp_reader *,
+ const char *));
static char *read_filename_string PROTO ((int, FILE *));
static char *remap_filename PROTO ((cpp_reader *, char *,
struct file_name_list *));
@@ -67,35 +68,35 @@ void
append_include_chain (pfile, list, dir, sysp)
cpp_reader *pfile;
struct file_name_list **list;
- char *dir;
+ const char *dir;
int sysp;
{
struct file_name_list *new;
struct stat st;
unsigned int len;
+ char * newdir = xstrdup (dir);
- dir = xstrdup (dir);
- simplify_pathname (dir);
- if (stat (dir, &st))
+ simplify_pathname (newdir);
+ if (stat (newdir, &st))
{
/* Dirs that don't exist are silently ignored. */
if (errno != ENOENT)
- cpp_perror_with_name (pfile, dir);
+ cpp_perror_with_name (pfile, newdir);
return;
}
if (!S_ISDIR (st.st_mode))
{
- cpp_message (pfile, 1, "%s: %s: Not a directory", progname, dir);
+ cpp_message (pfile, 1, "%s: %s: Not a directory", progname, newdir);
return;
}
- len = strlen(dir);
+ len = strlen(newdir);
if (len > pfile->max_include_len)
pfile->max_include_len = len;
new = (struct file_name_list *)xmalloc (sizeof (struct file_name_list));
- new->name = dir;
+ new->name = newdir;
new->nlen = len;
new->next = *list;
new->ino = st.st_ino;
@@ -526,7 +527,7 @@ struct file_name_map_list
static struct file_name_map *
read_name_map (pfile, dirname)
cpp_reader *pfile;
- char *dirname;
+ const char *dirname;
{
register struct file_name_map_list *map_list_ptr;
char *name;
@@ -607,8 +608,7 @@ remap_filename (pfile, name, loc)
struct file_name_list *loc;
{
struct file_name_map *map;
- char *from;
- char *p, *dir;
+ const char *from, *p, *dir;
if (! loc->name_map)
loc->name_map = read_name_map (pfile,
@@ -644,9 +644,10 @@ remap_filename (pfile, name, loc)
}
else
{
- dir = (char *) alloca (p - name + 1);
- bcopy (name, dir, p - name);
- dir[p - name] = '\0';
+ char * newdir = (char *) alloca (p - name + 1);
+ bcopy (name, newdir, p - name);
+ newdir[p - name] = '\0';
+ dir = newdir;
from = p + 1;
}