collect2.c (main): Const-ification.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Sat, 15 Sep 2001 14:04:47 +0000 (14:04 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Sat, 15 Sep 2001 14:04:47 +0000 (14:04 +0000)
* 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

gcc/ChangeLog
gcc/collect2.c
gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/gcc.c

index 6ea0c949f9cb77ca1d49ee51324dff47e741a3f2..70d0494f7e042bd1ddc0d6c8ff7f5934fe66d3f2 100644 (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
index 4877790eaf550c82002f59f12e48368291b4d316..dc3b7f8f25880e75da6432e8fc4eef0abb2ea26f 100644 (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).  */
index ef48dc301cf2ab3b35662408784e0acc3d1bbff5..38358428658b1796d6866a69fe704d60a82e6bdb 100644 (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):
index 6e94681e51eae6e58b421a6892418e8abf58e9f8..6ad9ffa3f2607bb962aa0a763bc0c8efe743de1e 100644 (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.  */
index 9b6c1e50ff448c7801d5564e9fd713d2dfec85a8..55188cf6359009ce258206c2e34c2375313575ca 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -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.  */