]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
merge from gcc
authorDJ Delorie <dj@redhat.com>
Tue, 4 Sep 2001 21:33:56 +0000 (21:33 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 4 Sep 2001 21:33:56 +0000 (21:33 +0000)
libiberty/ChangeLog
libiberty/asprintf.c
libiberty/vasprintf.c

index b4866cfaf8f80a4e0e153dee4c854252349112e9..39b32958929cfc321f4220bcd8b94cc9ecfb7de7 100644 (file)
@@ -1,3 +1,12 @@
+2001-09-04  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * asprintf.c: Don't define USE_STDARG.  Use VPARAMS, VA_OPEN,
+       VA_FIXEDARG & VA_CLOSE.
+
+       * vasprintf.c: Check HAVE_STRING_H when including string.h.
+       (checkit): Delete redundant prototype.  Add ATTRIBUTE_PRINTF_1.
+       Use VA_OPEN, VA_FIXEDARG & VA_CLOSE.  Free allocated string.
+
 2001-08-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * concat.c (concat): Use VPARAMS, VA_OPEN, VA_FIXEDARG & VA_CLOSE.
index 5aaf3200f0d59f806aa3583e2f51fe8244416bc3..e09af239ae7d6e45ff271e4bf3091c2634a00672 100644 (file)
@@ -22,36 +22,20 @@ Boston, MA 02111-1307, USA.  */
 #include "ansidecl.h"
 #include "libiberty.h"
 
-#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC)
-#define USE_STDARG
-#endif
-
-#ifdef USE_STDARG
+#ifdef ANSI_PROTOTYPES
 #include <stdarg.h>
 #else
 #include <varargs.h>
 #endif
 
-/* VARARGS */
-#ifdef USE_STDARG
-int
-asprintf (char **buf, const char *fmt, ...)
-#else
 int
-asprintf (buf, fmt, va_alist)
-     char **buf;
-     const char *fmt;
-     va_dcl
-#endif
+asprintf VPARAMS ((char **buf, const char *fmt, ...))
 {
   int status;
-  va_list ap;
-#ifdef USE_STDARG
-  va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
+  VA_OPEN (ap, fmt);
+  VA_FIXEDARG (ap, char **, buf);
+  VA_FIXEDARG (ap, const char *, fmt);
   status = vasprintf (buf, fmt, ap);
-  va_end (ap);
+  VA_CLOSE (ap);
   return status;
 }
index c34585d04987c5efb2fc54f040c15bf71f4d5da7..32faa84a4a2c609c22d7d126fa966c528ae90382 100644 (file)
@@ -28,7 +28,9 @@ Boston, MA 02111-1307, USA.  */
 #include <varargs.h>
 #endif
 #include <stdio.h>
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #else
@@ -142,29 +144,22 @@ vasprintf (result, format, args)
 }
 
 #ifdef TEST
-static void checkit PARAMS ((const char *, ...));
-
-static void
-checkit VPARAMS ((const char* format, ...))
+static void ATTRIBUTE_PRINTF_1
+checkit VPARAMS ((const char *format, ...))
 {
-  va_list args;
   char *result;
-#ifndef ANSI_PROTOTYPES
-  const char *format;
-#endif
-
-  VA_START (args, format);
-
-#ifndef ANSI_PROTOTYPES
-  format = va_arg (args, const char *);
-#endif
-
+  VA_OPEN (args, format);
+  VA_FIXEDARG (args, const char *, format);
   vasprintf (&result, format, args);
+  VA_CLOSE (args);
+
   if (strlen (result) < (size_t) global_total_width)
     printf ("PASS: ");
   else
     printf ("FAIL: ");
   printf ("%d %s\n", global_total_width, result);
+
+  free (result);
 }
 
 extern int main PARAMS ((void));