collect2.c (main): Const-ification.

* collect2.c (main): Const-ification.
	* gcc.c (translate_options, process_command): Use xstrdup in
	lieu of xmalloc/strcpy.
	(main): Use concat in lieu of xmalloc/strcpy/strcat.
cp:
	* mangle.c (mangle_conv_op_name_for_type): Use concat in lieu of
	xmalloc/strcpy/strcat.

From-SVN: r45631
This commit is contained in:
Kaveh R. Ghazi 2001-09-15 14:04:47 +00:00 committed by Kaveh Ghazi
parent 461c166993
commit cb6edbcb19
5 changed files with 49 additions and 52 deletions

View File

@ -1,3 +1,10 @@
2001-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* collect2.c (main): Const-ification.
* gcc.c (translate_options, process_command): Use xstrdup in
lieu of xmalloc/strcpy.
(main): Use concat in lieu of xmalloc/strcpy/strcat.
2001-09-14 Roman Lechtchinsky <rl@cs.tu-berlin.de>
* doc/install.texi (Specific, alphaev5-cray-unicosmk*): Fix

View File

@ -797,21 +797,47 @@ main (argc, argv)
char *argv[];
{
static const char *const ld_suffix = "ld";
const char *full_ld_suffix = ld_suffix;
static const char *const real_ld_suffix = "real-ld";
static const char *const collect_ld_suffix = "collect-ld";
static const char *const nm_suffix = "nm";
const char *full_nm_suffix = nm_suffix;
static const char *const gnm_suffix = "gnm";
const char *full_gnm_suffix = gnm_suffix;
#ifdef LDD_SUFFIX
static const char *const ldd_suffix = LDD_SUFFIX;
const char *full_ldd_suffix = ldd_suffix;
#endif
static const char *const strip_suffix = "strip";
const char *full_strip_suffix = strip_suffix;
static const char *const gstrip_suffix = "gstrip";
const char *full_gstrip_suffix = gstrip_suffix;
#ifdef CROSS_COMPILE
/* If we look for a program in the compiler directories, we just use
the short name, since these directories are already system-specific.
But it we look for a program in the system directories, we need to
qualify the program name with the target machine. */
const char *const full_ld_suffix =
concat(target_machine, "-", ld_suffix, NULL);
const char *const full_nm_suffix =
concat (target_machine, "-", nm_suffix, NULL);
const char *const full_gnm_suffix =
concat (target_machine, "-", gnm_suffix, NULL);
#ifdef LDD_SUFFIX
const char *const full_ldd_suffix =
concat (target_machine, "-", ldd_suffix, NULL);
#endif
const char *const full_strip_suffix =
concat (target_machine, "-", strip_suffix, NULL);
const char *const full_gstrip_suffix =
concat (target_machine, "-", gstrip_suffix, NULL);
#else
const char *const full_ld_suffix = ld_suffix;
const char *const full_nm_suffix = nm_suffix;
const char *const full_gnm_suffix = gnm_suffix;
#ifdef LDD_SUFFIX
const char *const full_ldd_suffix = ldd_suffix;
#endif
const char *const full_strip_suffix = strip_suffix;
const char *const full_gstrip_suffix = gstrip_suffix;
#endif /* CROSS_COMPILE */
const char *arg;
FILE *outf;
#ifdef COLLECT_EXPORT_LIST
@ -936,31 +962,6 @@ main (argc, argv)
prefix_from_env ("COMPILER_PATH", &cpath);
prefix_from_env ("PATH", &path);
#ifdef CROSS_COMPILE
/* If we look for a program in the compiler directories, we just use
the short name, since these directories are already system-specific.
But it we look for a program in the system directories, we need to
qualify the program name with the target machine. */
full_ld_suffix = concat(target_machine, "-", ld_suffix, NULL);
#if 0
full_gld_suffix = concat (target_machine, "-", gld_suffix, NULL);
#endif
full_nm_suffix = concat (target_machine, "-", nm_suffix, NULL);
full_gnm_suffix = concat (target_machine, "-", gnm_suffix, NULL);
#ifdef LDD_SUFFIX
full_ldd_suffix = concat (target_machine, "-", ldd_suffix, NULL);
#endif
full_strip_suffix = concat (target_machine, "-", strip_suffix, NULL);
full_gstrip_suffix = concat (target_machine, "-", gstrip_suffix, NULL);
#endif /* CROSS_COMPILE */
/* Try to discover a valid linker/nm/strip to use. */
/* Maybe we know the right file to use (if not cross). */

View File

@ -1,3 +1,8 @@
2001-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* mangle.c (mangle_conv_op_name_for_type): Use concat in lieu of
xmalloc/strcpy/strcat.
2001-09-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* decl.c (warn_extern_redeclared_static, cp_make_fname_decl):

View File

@ -2392,11 +2392,7 @@ mangle_conv_op_name_for_type (type)
/* Build the mangling for TYPE. */
const char *mangled_type = mangle_type_string (type);
/* Allocate a temporary buffer for the complete name. */
char *op_name = (char *) xmalloc (strlen ("operator ")
+ strlen (mangled_type) + 1);
/* Assemble the mangling. */
strcpy (op_name, "operator ");
strcat (op_name, mangled_type);
char *op_name = concat ("operator ", mangled_type, NULL);
/* Find or create an identifier. */
identifier = get_identifier (op_name);
/* Done with the temporary buffer. */

View File

@ -1011,8 +1011,7 @@ translate_options (argcp, argvp)
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)
{
@ -3910,15 +3909,13 @@ process_command (argc, argv)
/* 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
@ -5812,17 +5809,8 @@ main (argc, argv)
/* 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. */