summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>1999-01-05 19:11:22 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>1999-01-05 19:11:22 +0000
commit7bcdc3c72acd322469e7e757bd44f03072a93459 (patch)
treef98dde49db8ef6f1d425e196eb7db84dab10c8b4 /gcc
parent34f474122add99e4b033b875f2a2574dbd11e884 (diff)
downloadgcc-7bcdc3c72acd322469e7e757bd44f03072a93459.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24498 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog32
-rw-r--r--gcc/Makefile.in9
-rw-r--r--gcc/cccp.c10
-rw-r--r--gcc/cppfiles.c31
-rw-r--r--gcc/cpplib.c5
-rw-r--r--gcc/cpplib.h2
-rw-r--r--gcc/gcc.c24
-rw-r--r--gcc/prefix.c41
-rw-r--r--gcc/prefix.h9
9 files changed, 103 insertions, 60 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d234ca0678d..caa7e12fb50 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,35 @@
+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
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index feb47dd41ba..754dc26f20e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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)\" \
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 440081c72f0..5271960b580 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -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");
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 108bf8751fb..169809d11ba 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;
}
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index f9990c85125..50187026d18 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -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);
}
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 68c77a1aeab..233eedbe4ce 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -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 *,
diff --git a/gcc/gcc.c b/gcc/gcc.c
index cda78b6dd93..854ed2395a6 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -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);
diff --git a/gcc/prefix.c b/gcc/prefix.c
index 3e98ded4d73..5e4fdb1505e 100644
--- a/gcc/prefix.c
+++ b/gcc/prefix.c
@@ -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);
}
diff --git a/gcc/prefix.h b/gcc/prefix.h
new file mode 100644
index 00000000000..96dd122896a
--- /dev/null
+++ b/gcc/prefix.h
@@ -0,0 +1,9 @@
+/* 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__ */