From 7a98d9b2484ca82269f5f63850606f95c8a77a9c Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 4 Sep 2001 18:19:18 +0000 Subject: asprintf.c: Don't define USE_STDARG. * 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. From-SVN: r45382 --- libiberty/vasprintf.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'libiberty/vasprintf.c') diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c index c34585d..32faa84 100644 --- a/libiberty/vasprintf.c +++ b/libiberty/vasprintf.c @@ -28,7 +28,9 @@ Boston, MA 02111-1307, USA. */ #include #endif #include +#ifdef HAVE_STRING_H #include +#endif #ifdef HAVE_STDLIB_H #include #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)); -- cgit v1.1