OSDN Git Service

Workaround for Itanium A/B step errata
[pf3gnuchains/gcc-fork.git] / gcc / prefix.c
index 88cff94..c43e578 100644 (file)
@@ -139,7 +139,7 @@ concat VPARAMS ((const char *first, ...))
       arg = va_arg (args, const char *);
     }
 
-  newstr = (char *) malloc (length + 1);
+  newstr = (char *) xmalloc (length + 1);
   va_end (args);
 
   /* Now copy the individual pieces to the result string.  */
@@ -172,7 +172,7 @@ save_string (s, len)
 {
   register char *result = xmalloc (len + 1);
 
-  bcopy (s, result, len);
+  memcpy (result, s, len);
   result[len] = 0;
   return result;
 }
@@ -211,12 +211,12 @@ lookup_key (key)
     }
 
   size = 32;
-  dst = (char *) malloc (size);
+  dst = (char *) xmalloc (size);
 
   res = RegQueryValueExA (reg_key, key, 0, &type, dst, &size);
   if (res == ERROR_MORE_DATA && type == REG_SZ)
     {
-      dst = (char *) realloc (dst, size);
+      dst = (char *) xrealloc (dst, size);
       res = RegQueryValueExA (reg_key, key, 0, &type, dst, &size);
     }
 
@@ -268,14 +268,10 @@ translate_name (name)
   if (prefix == 0)
     prefix = PREFIX;
 
-  /* Remove any trailing directory separator from what we got. First check
-     for an empty prefix.  */
-  if (prefix[0] && IS_DIR_SEPARATOR (prefix[strlen (prefix) - 1]))
-    {
-      char * temp = xstrdup (prefix);
-      temp[strlen (temp) - 1] = 0;
-      prefix = temp;
-    }
+  /* We used to strip trailing DIR_SEPARATORs here, but that can
+     sometimes yield a result with no separator when one was coded
+     and intended by the user, causing two path components to run
+     together.  */
 
   return concat (prefix, name, NULL_PTR);
 }
@@ -298,6 +294,11 @@ update_path (path, key)
        path = translate_name (path);
     }
 
+#ifdef UPDATE_PATH_HOST_CANONICALIZE
+/* Perform host dependant canonicalization when needed.  */
+UPDATE_PATH_HOST_CANONICALIZE (path, key);
+#endif
+
 #ifdef DIR_SEPARATOR_2
   /* Convert DIR_SEPARATOR_2 to DIR_SEPARATOR. */
   if (DIR_SEPARATOR != DIR_SEPARATOR_2)