OSDN Git Service

merge from gcc
authordj <dj>
Mon, 24 Sep 2001 23:37:52 +0000 (23:37 +0000)
committerdj <dj>
Mon, 24 Sep 2001 23:37:52 +0000 (23:37 +0000)
libiberty/ChangeLog
libiberty/concat.c

index d9dc3dc..22bf58c 100644 (file)
@@ -1,3 +1,7 @@
+2001-09-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * concat.c (reconcat): New function.
+
 2001-09-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * concat.c (vconcat_length, vconcat_copy, concat_length,
index feed0df..136e8be 100644 (file)
@@ -171,6 +171,31 @@ concat VPARAMS ((const char *first, ...))
   return newstr;
 }
 
+char *
+reconcat VPARAMS ((char *optr, const char *first, ...))
+{
+  char *newstr;
+
+  /* First compute the size of the result and get sufficient memory.  */
+  VA_OPEN (args, first);
+  VA_FIXEDARG (args, char *, optr);
+  VA_FIXEDARG (args, const char *, first);
+  newstr = (char *) xmalloc (vconcat_length (first, args) + 1);
+  VA_CLOSE (args);
+
+  /* Now copy the individual pieces to the result string. */
+  VA_OPEN (args, first);
+  VA_FIXEDARG (args, char *, optr);
+  VA_FIXEDARG (args, const char *, first);
+  vconcat_copy (newstr, first, args);
+  VA_CLOSE (args);
+
+  if (optr)
+    free (optr);
+
+  return newstr;
+}
+
 #ifdef MAIN
 #define NULLP (char *)0