#if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX)
#define HAVE_TARGET_EXECUTABLE_SUFFIX
#else
+#undef TARGET_EXECUTABLE_SUFFIX
#define TARGET_EXECUTABLE_SUFFIX ""
#endif
#endif /* DIR_UP */
#endif /* VMS */
-static char dir_separator_str[] = { DIR_SEPARATOR, 0 };
+static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
switch. The only case we support now is simply appending or deleting a
string to or from the end of the first part of the configuration name. */
-struct modify_target
+const struct modify_target
{
- const char *sw;
- enum add_del {ADD, DELETE} add_del;
- const char *str;
+ const char *const sw;
+ const enum add_del {ADD, DELETE} add_del;
+ const char *const str;
}
modify_target[] = MODIFY_TARGET_NAME;
#endif
static void clear_args PARAMS ((void));
static void fatal_error PARAMS ((int));
static void set_input PARAMS ((const char *));
+#ifdef ENABLE_SHARED_LIBGCC
static void init_gcc_specs PARAMS ((struct obstack *,
const char *,
const char *));
+#endif
+#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+static const char *convert_filename PARAMS ((const char *, int));
+#endif
\f
/* The Specs Language
specified to CC. Note that the tail part of the -S option
(i.e. the part matched by the `*') will be substituted for each
occurrence of %* within X.
- %{<S} remove all occurences of -S from the command line.
+ %{<S} remove all occurrences of -S from the command line.
Note - this option is position dependent. % commands in the
spec string before this option will see -S, % commands in the
spec string after this option will not.
{".cc", "#C++", 0}, {".cxx", "#C++", 0}, {".cpp", "#C++", 0},
{".cp", "#C++", 0}, {".c++", "#C++", 0}, {".C", "#C++", 0},
{".ii", "#C++", 0},
- {".ads", "#Ada", 0}, {".adb", "#Ada", 0}, {".ada", "#Ada", 0},
+ {".ads", "#Ada", 0}, {".adb", "#Ada", 0},
{".f", "#Fortran", 0}, {".for", "#Fortran", 0}, {".fpp", "#Fortran", 0},
{".F", "#Fortran", 0}, {".FOR", "#Fortran", 0}, {".FPP", "#Fortran", 0},
{".r", "#Ratfor", 0},
struct option_map
{
/* The long option's name. */
- const char *name;
+ const char *const name;
/* The equivalent short option. */
- const char *equivalent;
+ const char *const equivalent;
/* Argument info. A string of flag chars; NULL equals no options.
a => argument required.
o => argument optional.
j => join argument to equivalent, making one word.
* => require other text after NAME as an argument. */
- const char *arg_info;
+ const char *const arg_info;
};
/* This is the table of mappings. Mappings are tried sequentially
for each option encountered; the first one that matches, wins. */
-struct option_map option_map[] =
+static const struct option_map option_map[] =
{
{"--all-warnings", "-Wall", 0},
{"--ansi", "-ansi", 0},
\f
#ifdef TARGET_OPTION_TRANSLATE_TABLE
-static struct {
- const char *option_found;
- const char *replacements;
+static const struct {
+ const char *const option_found;
+ const char *const replacements;
} target_option_translations[] =
{
TARGET_OPTION_TRANSLATE_TABLE,
newv = (const char **) xrealloc (newv, newvsize);
sp = target_option_translations[tott_idx].replacements;
- np = (char *) xmalloc (strlen (sp) + 1);
- strcpy (np, sp);
+ np = xstrdup (sp);
while (1)
{
struct prefix_list
{
- char *prefix; /* String to prepend to the path. */
+ const char *prefix; /* String to prepend to the path. */
struct prefix_list *next; /* Next in linked list. */
int require_machine_suffix; /* Don't use without machine_suffix. */
/* 2 means try both machine_suffix and just_machine_suffix. */
#define STANDARD_BINDIR_PREFIX "/usr/local/bin"
#endif
-static const char *standard_exec_prefix = STANDARD_EXEC_PREFIX;
-static const char *standard_exec_prefix_1 = "/usr/lib/gcc/";
+static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
+static const char *const standard_exec_prefix_1 = "/usr/lib/gcc/";
static const char *md_exec_prefix = MD_EXEC_PREFIX;
static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
-static const char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
-static const char *standard_startfile_prefix_1 = "/lib/";
-static const char *standard_startfile_prefix_2 = "/usr/lib/";
+static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
+static const char *const standard_startfile_prefix_1 = "/lib/";
+static const char *const standard_startfile_prefix_2 = "/usr/lib/";
-static const char *tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
+static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
static const char *tooldir_prefix;
-static const char *standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
+static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
/* Subdirectory to use for locating libraries. Set by
set_multilib_dir based on the compilation options. */
That is all that the EXTRA_SPECS macro gives us. */
struct spec_list_1
{
- const char *name;
- const char *ptr;
+ const char *const name;
+ const char *const ptr;
};
-static struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
+static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
static struct spec_list *extra_specs = (struct spec_list *) 0;
#endif
/* Add appropriate libgcc specs to OBSTACK, taking into account
various permutations of -shared-libgcc, -shared, and such. */
+#ifdef ENABLE_SHARED_LIBGCC
static void
init_gcc_specs (obstack, shared_name, static_name)
struct obstack *obstack;
static_name);
obstack_grow (obstack, buffer, strlen (buffer));
}
+#endif /* ENABLE_SHARED_LIBGCC */
/* Initialize the specs lookup routines. */
(3) For each ET_DYN we're linking against (either through -lfoo
or /some/path/foo.so), check to see whether it or one of
- its dependancies depends on a shared libgcc.
+ its dependencies depends on a shared libgcc.
(4) If "-shared"
#ifdef USE_AS_TRADITIONAL_FORMAT
/* Prepend "--traditional-format" to whatever asm_spec we had before. */
{
- static char tf[] = "--traditional-format ";
+ static const char tf[] = "--traditional-format ";
obstack_grow (&obstack, tf, sizeof(tf) - 1);
obstack_grow0 (&obstack, asm_spec, strlen (asm_spec));
asm_spec = obstack_finish (&obstack);
record_temp_file (arg, delete_always, delete_failure);
}
\f
-/* Load specs from a file name named FILENAME, replacing occurances of
+/* Load specs from a file name named FILENAME, replacing occurrences of
various different types of line-endings, \r\n, \n\r and just \r, with
a single \n. */
int main_p;
{
char *buffer;
- register char *p;
+ char *p;
buffer = load_specs (filename);
int always_delete;
int fail_delete;
{
- register char *const name = xstrdup (filename);
+ char *const name = xstrdup (filename);
if (always_delete)
{
- register struct temp_file *temp;
+ struct temp_file *temp;
for (temp = always_delete_queue; temp; temp = temp->next)
if (! strcmp (name, temp->name))
goto already1;
if (fail_delete)
{
- register struct temp_file *temp;
+ struct temp_file *temp;
for (temp = failure_delete_queue; temp; temp = temp->next)
if (! strcmp (name, temp->name))
goto already2;
static void
delete_temp_files ()
{
- register struct temp_file *temp;
+ struct temp_file *temp;
for (temp = always_delete_queue; temp; temp = temp->next)
delete_if_ordinary (temp->name);
static void
delete_failure_queue ()
{
- register struct temp_file *temp;
+ struct temp_file *temp;
for (temp = failure_delete_queue; temp; temp = temp->next)
delete_if_ordinary (temp->name);
int mode;
{
char *temp;
- const char *file_suffix = ((mode & X_OK) != 0 ? HOST_EXECUTABLE_SUFFIX : "");
+ const char *const file_suffix =
+ ((mode & X_OK) != 0 ? HOST_EXECUTABLE_SUFFIX : "");
struct prefix_list *pl;
int len = pprefix->max_len + strlen (name) + strlen (file_suffix) + 1;
/* Convert NAME to a new name if it is the standard suffix. DO_EXE
is true if we should look for an executable suffix as well. */
-static char *
+static const char *
convert_filename (name, do_exe)
- char *name;
- int do_exe;
+ const char *name;
+ int do_exe ATTRIBUTE_UNUSED;
{
+#if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
int i;
+#endif
int len;
if (name == NULL)
int argc;
const char *const *argv;
{
- register int i;
+ int i;
const char *temp;
char *temp1;
const char *spec_lang = 0;
report_times = 1;
else if (argv[i][0] == '-' && argv[i][1] != 0)
{
- register const char *p = &argv[i][1];
- register int c = *p;
+ const char *p = &argv[i][1];
+ int c = *p;
switch (c)
{
len = strlen (value);
/* Catch the case where the user has forgotten to append a
- directory seperator to the path. Note, they may be using
+ directory separator to the path. Note, they may be using
-B to add an executable name prefix, eg "i386-elf-", in
order to distinguish between multiple installations of
GCC in the same directory. Hence we must check to see
have_c = 1;
break;
}
- else if (skip = SWITCH_TAKES_ARG (argv[j][1]))
+ else if ((skip = SWITCH_TAKES_ARG (argv[j][1])))
j += skip - (argv[j][2] != 0);
- else if (skip = WORD_SWITCH_TAKES_ARG (argv[j] + 1))
+ else if ((skip = WORD_SWITCH_TAKES_ARG (argv[j] + 1)))
j += skip;
}
j++;
/* On some systems, ld cannot handle some options without
a space. So split the option from its argument. */
char *part1 = (char *) xmalloc (2);
- char *tmp;
part1[0] = c;
part1[1] = '\0';
switches[n_switches].part1 = part1;
switches[n_switches].args
= (const char **) xmalloc (2 * sizeof (const char *));
- switches[n_switches].args[0] = tmp = xmalloc (strlen (p));
- strcpy (tmp, &p[1]);
+ switches[n_switches].args[0] = xstrdup (p+1);
switches[n_switches].args[1] = 0;
}
else
int inswitch;
const char *soft_matched_part;
{
- register const char *p = spec;
- register int c;
+ const char *p = spec;
+ int c;
int i;
const char *string;
int value;
case 'C':
{
- const char* spec
+ const char *const spec
= (input_file_compiler->cpp_spec
? input_file_compiler->cpp_spec
: cpp_spec);
static const char *
handle_braces (p)
- register const char *p;
+ const char *p;
{
const char *filter, *body = NULL, *endbody = NULL;
int pipe_p = 0;
{
if (*p != '}' && *p != '&')
{
- register int count = 1;
- register const char *q = p;
+ int count = 1;
+ const char *q = p;
while (*q++ != ':')
continue;
else if (*q == '}')
count--;
else if (*q == 0)
- abort ();
+ fatal ("Mismatched braces in specs");
q++;
}
endbody = q;
else if (p[-1] == '*' && (p[0] == '}' || p[0] == '&'))
{
/* Substitute all matching switches as separate args. */
- register int i;
+ int i;
for (i = 0; i < n_switches; i++)
if (!strncmp (switches[i].part1, filter, p - 1 - filter)
else
{
/* Test for presence of the specified switch. */
- register int i;
+ int i;
int present = 0;
/* If name specified ends in *, as in {x*:...},
/* Try multilib_dir if it is defined. */
if (multilib_dir != NULL)
{
- char *try;
-
- try = (char *) alloca (strlen (multilib_dir) + strlen (name) + 2);
- strcpy (try, multilib_dir);
- strcat (try, dir_separator_str);
- strcat (try, name);
+ const char *const try = ACONCAT ((multilib_dir, dir_separator_str, name, NULL));
newname = find_a_file (&startfile_prefixes, try, R_OK);
set_input (filename)
const char *filename;
{
- register const char *p;
+ const char *p;
input_filename = filename;
input_filename_length = strlen (input_filename);
xmalloc_set_program_name (programname);
#ifdef GCC_DRIVER_HOST_INITIALIZATION
- /* Perform host dependant initialization when needed. */
+ /* Perform host dependent initialization when needed. */
GCC_DRIVER_HOST_INITIALIZATION;
#endif
-/* LC_CTYPE determines the character set used by the terminal so it has be set
- to output messages correctly. */
-
-#ifdef HAVE_LC_MESSAGES
- setlocale (LC_CTYPE, "");
- setlocale (LC_MESSAGES, "");
-#else
- setlocale (LC_ALL, "");
-#endif
-
- (void) bindtextdomain (PACKAGE, localedir);
- (void) textdomain (PACKAGE);
+ gcc_init_libintl ();
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
signal (SIGINT, fatal_error);
/* If we have a GCC_EXEC_PREFIX envvar, modify it for cpp's sake. */
if (gcc_exec_prefix)
- {
- char *temp = (char *) xmalloc (strlen (gcc_exec_prefix)
- + strlen (spec_version)
- + strlen (spec_machine) + 3);
- strcpy (temp, gcc_exec_prefix);
- strcat (temp, spec_machine);
- strcat (temp, dir_separator_str);
- strcat (temp, spec_version);
- strcat (temp, dir_separator_str);
- gcc_exec_prefix = temp;
- }
+ gcc_exec_prefix = concat (gcc_exec_prefix, spec_machine, dir_separator_str,
+ spec_version, dir_separator_str, NULL);
/* Now we have the specs.
Set the `valid' bits for switches that match anything in any spec. */
/* We do not exit here. Instead we have created a fake input file
called 'help-dummy' which needs to be compiled, and we pass this
- on the the various sub-processes, along with the --help switch. */
+ on the various sub-processes, along with the --help switch. */
}
if (verbose_flag)
/* Ok, we found an applicable compiler. Run its spec. */
if (input_file_compiler->spec[0] == '#')
- error ("%s: %s compiler not installed on this system",
- input_filename, &input_file_compiler->spec[1]);
- value = do_spec (input_file_compiler->spec);
- if (value < 0)
- this_file_error = 1;
+ {
+ error ("%s: %s compiler not installed on this system",
+ input_filename, &input_file_compiler->spec[1]);
+ this_file_error = 1;
+ }
+ else
+ {
+ value = do_spec (input_file_compiler->spec);
+ if (value < 0)
+ this_file_error = 1;
+ }
}
/* If this file's name does not contain a recognized suffix,
const char *s;
int len;
{
- register char *result = xmalloc (len + 1);
+ char *result = xmalloc (len + 1);
memcpy (result, s, len);
result[len] = 0;
void
fatal VPARAMS ((const char *msgid, ...))
{
-#ifndef ANSI_PROTOTYPES
- const char *msgid;
-#endif
- va_list ap;
-
- VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
- msgid = va_arg (ap, const char *);
-#endif
+ VA_OPEN (ap, msgid);
+ VA_FIXEDARG (ap, const char *, msgid);
fprintf (stderr, "%s: ", programname);
vfprintf (stderr, _(msgid), ap);
- va_end (ap);
+ VA_CLOSE (ap);
fprintf (stderr, "\n");
delete_temp_files ();
exit (1);
void
error VPARAMS ((const char *msgid, ...))
{
-#ifndef ANSI_PROTOTYPES
- const char *msgid;
-#endif
- va_list ap;
-
- VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
- msgid = va_arg (ap, const char *);
-#endif
+ VA_OPEN (ap, msgid);
+ VA_FIXEDARG (ap, const char *, msgid);
fprintf (stderr, "%s: ", programname);
vfprintf (stderr, _(msgid), ap);
- va_end (ap);
+ VA_CLOSE (ap);
fprintf (stderr, "\n");
}
static void
notice VPARAMS ((const char *msgid, ...))
{
-#ifndef ANSI_PROTOTYPES
- const char *msgid;
-#endif
- va_list ap;
-
- VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
- msgid = va_arg (ap, const char *);
-#endif
+ VA_OPEN (ap, msgid);
+ VA_FIXEDARG (ap, const char *, msgid);
vfprintf (stderr, _(msgid), ap);
- va_end (ap);
+ VA_CLOSE (ap);
}
\f
static void
validate_all_switches ()
{
struct compiler *comp;
- register const char *p;
- register char c;
+ const char *p;
+ char c;
struct spec_list *spec;
for (comp = compilers; comp->spec; comp++)
validate_switches (start)
const char *start;
{
- register const char *p = start;
+ const char *p = start;
const char *filter;
- register int i;
+ int i;
int suffix;
if (*p == '|')