Commit 460ee112 by Kaveh R. Ghazi Committed by Kaveh Ghazi

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
parent 258ce95e
Tue Jan 5 21:57:42 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* 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.
Mon Jan 4 15:37:30 1999 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c (skip_if_group): Split out the logic that handles
......
......@@ -1365,7 +1365,7 @@ DRIVER_DEFINES = \
-DDEFAULT_TARGET_VERSION=\"$(version)\" \
-DDEFAULT_TARGET_MACHINE=\"$(target_alias)\" \
-DTOOLDIR_BASE_PREFIX=\"$(exec_prefix)/\"
gcc.o: gcc.c $(CONFIG_H) system.h multilib.h Makefile \
gcc.o: gcc.c $(CONFIG_H) system.h multilib.h Makefile prefix.h \
$(lang_specs_files)
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(DRIVER_DEFINES) \
......@@ -1402,7 +1402,7 @@ mkstemp.o: $(srcdir)/../libiberty/mkstemp.c $(CONFIG_H) system.h
$(LN_S) $(srcdir)/../libiberty/mkstemp.c mkstemp.c
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) mkstemp.c
prefix.o: prefix.c $(CONFIG_H) system.h Makefile
prefix.o: prefix.c $(CONFIG_H) system.h Makefile prefix.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DPREFIX=\"$(prefix)\" \
-c `echo $(srcdir)/prefix.c | sed 's,^\./,,'`
......@@ -1882,7 +1882,7 @@ $(srcdir)/cexp.c: $(srcdir)/cexp.y
# We use $(libsubdir)/$(unlibsubdir) to match the
# -iprefix argument which gcc will pass if GCC_EXEC_PREFIX is used.
cccp.o: cccp.c $(CONFIG_H) pcp.h version.c config.status system.h \
mbchar.h
mbchar.h prefix.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-DGPLUSPLUS_INCLUDE_DIR=\"$(gxx_include_dir)\" \
......@@ -1910,7 +1910,8 @@ cppmain$(exeext): cppmain.o libcpp.a $(LIBDEPS)
cppmain.o: cppmain.c $(CONFIG_H) cpplib.h machmode.h system.h
cpplib.o: cpplib.c $(CONFIG_H) cpplib.h machmode.h cpphash.h config.status system.h
cpplib.o: cpplib.c $(CONFIG_H) cpplib.h machmode.h cpphash.h config.status \
system.h prefix.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-DGPLUSPLUS_INCLUDE_DIR=\"$(gxx_include_dir)\" \
......
......@@ -37,6 +37,7 @@ Boston, MA 02111-1307, USA. */
typedef unsigned char U_CHAR;
#include "pcp.h"
#include "prefix.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
......@@ -122,7 +123,6 @@ static int hack_vms_include_specification ();
/* External declarations. */
extern char *version_string;
extern char *update_path PROTO((char *, char *));
HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));
HOST_WIDE_INT parse_c_expression PROTO((char *, int));
......@@ -1029,7 +1029,7 @@ static void make_undef PROTO((char *, FILE_BUF *));
static void make_assertion PROTO((char *, char *));
static struct file_name_list *new_include_prefix PROTO((struct file_name_list *, char *, char *, char *));
static struct file_name_list *new_include_prefix PROTO((struct file_name_list *, const char *, const char *, const char *));
static void append_include_chain PROTO((struct file_name_list *, struct file_name_list *));
static int quote_string_for_make PROTO((char *, char *));
......@@ -10436,9 +10436,9 @@ make_assertion (option, str)
static struct file_name_list *
new_include_prefix (prev_file_name, component, prefix, name)
struct file_name_list *prev_file_name;
char *component;
char *prefix;
char *name;
const char *component;
const char *prefix;
const char *name;
{
if (name == 0)
fatal ("Directory name missing after command line option");
......
......@@ -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;
}
......
......@@ -38,13 +38,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpplib.h"
#include "cpphash.h"
#include "output.h"
#include "prefix.h"
#ifndef GET_ENV_PATH_LIST
#define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
#endif
extern char *update_path PARAMS ((char *, char *));
/* By default, colon separates directories in a path. */
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR ':'
......@@ -4942,7 +4941,7 @@ cpp_start_read (pfile, fname)
/* Some standard dirs are only for C++. */
if (!p->cplusplus
|| (opts->cplusplus && !opts->no_standard_cplusplus_includes)) {
char *str = update_path (p->fname, p->component);
const char *str = update_path (p->fname, p->component);
append_include_chain (pfile, &opts->system_include,
str, !p->cxx_aware);
}
......
......@@ -714,7 +714,7 @@ extern void cpp_print_containing_files PROTO ((cpp_reader *));
/* In cppfiles.c */
extern void append_include_chain PROTO ((cpp_reader *,
struct file_name_list **,
char *, int));
const char *, int));
extern void merge_include_chains PROTO ((struct cpp_options *));
extern int find_include_file PROTO ((cpp_reader *, char *,
struct file_name_list *,
......
......@@ -36,10 +36,7 @@ compilation is specified by a string called a "spec". */
#include <signal.h>
#include "obstack.h"
/* ??? Need to find a GCC header to put these in. */
extern char *update_path PROTO((char *, char *));
extern void set_std_prefix PROTO((char *, int));
#include "prefix.h"
#ifdef VMS
#define exit __posix_exit
......@@ -174,8 +171,8 @@ static struct compiler *lookup_compiler PROTO((char *, size_t, char *));
static char *build_search_list PROTO((struct path_prefix *, char *, int));
static void putenv_from_prefixes PROTO((struct path_prefix *, char *));
static char *find_a_file PROTO((struct path_prefix *, char *, int));
static void add_prefix PROTO((struct path_prefix *, char *, char *,
int, int, int *));
static void add_prefix PROTO((struct path_prefix *, const char *,
const char *, int, int, int *));
static char *skip_whitespace PROTO((char *));
static void record_temp_file PROTO((char *, int, int));
static void delete_if_ordinary PROTO((char *));
......@@ -184,7 +181,7 @@ static void delete_failure_queue PROTO((void));
static void clear_failure_queue PROTO((void));
static int check_live_switch PROTO((int, int));
static char *handle_braces PROTO((char *));
static char *save_string PROTO((char *, int));
static char *save_string PROTO((const char *, int));
extern int do_spec PROTO((char *));
static int do_spec_1 PROTO((char *, int, char *));
static char *find_file PROTO((char *));
......@@ -199,8 +196,9 @@ static void print_multilib_info PROTO((void));
static void pfatal_with_name PROTO((char *)) ATTRIBUTE_NORETURN;
static void perror_with_name PROTO((char *));
static void pfatal_pexecute PROTO((char *, char *)) ATTRIBUTE_NORETURN;
static void fatal PVPROTO((char *, ...)) ATTRIBUTE_NORETURN;
static void error PVPROTO((char *, ...));
static void fatal PVPROTO((char *, ...))
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
static void error PVPROTO((char *, ...)) ATTRIBUTE_PRINTF_1;
static void display_help PROTO((void));
void fancy_abort PROTO((void)) ATTRIBUTE_NORETURN;
......@@ -2101,8 +2099,8 @@ find_a_file (pprefix, name, mode)
static void
add_prefix (pprefix, prefix, component, first, require_machine_suffix, warn)
struct path_prefix *pprefix;
char *prefix;
char *component;
const char *prefix;
const char *component;
int first;
int require_machine_suffix;
int *warn;
......@@ -5233,8 +5231,8 @@ xrealloc (ptr, size)
static char *
save_string (s, len)
char *s;
int len;
const char *s;
int len;
{
register char *result = xmalloc (len + 1);
......
......@@ -68,12 +68,13 @@ Boston, MA 02111-1307, USA. */
#ifdef _WIN32
#include <windows.h>
#endif
#include "prefix.h"
static char *std_prefix = PREFIX;
static const char *std_prefix = PREFIX;
static char *get_key_value PROTO((char *));
static char *translate_name PROTO((char *));
static char *save_string PROTO((char *, int));
static const char *get_key_value PROTO((char *));
static const char *translate_name PROTO((const char *));
static char *save_string PROTO((const char *, int));
#ifdef _WIN32
static char *lookup_key PROTO((char *));
......@@ -82,11 +83,11 @@ static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
/* Given KEY, as above, return its value. */
static char *
static const char *
get_key_value (key)
char *key;
{
char *prefix = 0;
const char *prefix = 0;
char *temp = 0;
#ifdef _WIN32
......@@ -165,10 +166,10 @@ concat VPROTO((const char *first, ...))
static char *
save_string (s, len)
char *s;
int len;
const char *s;
int len;
{
register char *result = (char *) malloc (len + 1);
register char *result = xmalloc (len + 1);
bcopy (s, result, len);
result[len] = 0;
......@@ -227,12 +228,13 @@ lookup_key (key)
/* If NAME starts with a '@' or '$', apply the translation rules above
and return a new name. Otherwise, return the given name. */
static char *
static const char *
translate_name (name)
char *name;
const char *name;
{
char code = name[0];
char *key, *prefix = 0;
char *key;
const char *prefix = 0;
int keylen;
if (code != '@' && code != '$')
......@@ -272,8 +274,9 @@ translate_name (name)
#endif
)
{
prefix = save_string (prefix, strlen (prefix));
prefix[strlen (prefix) - 1] = 0;
char * temp = save_string (prefix, strlen (prefix));
temp[strlen (temp) - 1] = 0;
prefix = temp;
}
return concat (prefix, name, NULL_PTR);
......@@ -281,10 +284,10 @@ translate_name (name)
/* Update PATH using KEY if PATH starts with PREFIX. */
char *
const char *
update_path (path, key)
char *path;
char *key;
const char *path;
const char *key;
{
if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0)
{
......@@ -316,8 +319,8 @@ update_path (path, key)
/* Reset the standard prefix */
void
set_std_prefix (prefix, len)
char *prefix;
int len;
const char *prefix;
int len;
{
std_prefix = save_string (prefix, len);
}
/* Provide prototypes for functions exported from prefix.c. */
#ifndef __GCC_PREFIX_H__
#define __GCC_PREFIX_H__
extern const char *update_path PARAMS ((const char *, const char *));
extern void set_std_prefix PARAMS ((const char *, int));
#endif /* ! __GCC_PREFIX_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment