From e2dff3f2f6bbc434bf9ae0ad1701594fb24d85cf Mon Sep 17 00:00:00 2001
From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Date: Mon, 27 Aug 2001 19:10:39 +0000
Subject: [PATCH] ansidecl.h (VA_OPEN, VA_CLOSE): Allow multiple uses.

include:
	* ansidecl.h (VA_OPEN, VA_CLOSE): Allow multiple uses.

libiberty:
	* concat.c (concat): Use VPARAMS, VA_OPEN, VA_FIXEDARG & VA_CLOSE.

From-SVN: r45204
---
 include/ChangeLog   |  4 ++++
 include/ansidecl.h  |  8 ++++----
 libiberty/ChangeLog |  4 ++++
 libiberty/concat.c  | 35 ++++++++---------------------------
 4 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index e7a3bcf78224..23ba4fb7983d 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2001-08-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* ansidecl.h (VA_OPEN, VA_CLOSE): Allow multiple uses.
+
 2001-08-23  Lars Brinkhoff  <lars@nocrew.org>
 
 	* dyn-string.h, fibheap.h, partition.h, sort.h, splay-tree.h:
diff --git a/include/ansidecl.h b/include/ansidecl.h
index b7c4c40abff9..4c63fa66e498 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -152,8 +152,8 @@ So instead we use the macro below and test it against specific values.  */
 /* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
    use without inhibiting further decls and without declaring an
    actual variable.  */
-#define VA_OPEN(AP, VAR)	va_list AP; va_start(AP, VAR); { struct Qdmy
-#define VA_CLOSE(AP)		} va_end(AP)
+#define VA_OPEN(AP, VAR)	{ va_list AP; va_start(AP, VAR); { struct Qdmy
+#define VA_CLOSE(AP)		} va_end(AP); }
 #define VA_FIXEDARG(AP, T, N)	struct Qdmy
  
 #undef const
@@ -199,8 +199,8 @@ So instead we use the macro below and test it against specific values.  */
 #define VPARAMS(args)		(va_alist) va_dcl
 #define VA_START(va_list, var)	va_start(va_list)
 
-#define VA_OPEN(AP, VAR)		va_list AP; va_start(AP); { struct Qdmy
-#define VA_CLOSE(AP)			} va_end(AP)
+#define VA_OPEN(AP, VAR)		{ va_list AP; va_start(AP); { struct Qdmy
+#define VA_CLOSE(AP)			} va_end(AP); }
 #define VA_FIXEDARG(AP, TYPE, NAME)	TYPE NAME = va_arg(AP, TYPE)
 
 /* some systems define these in header files for non-ansi mode */
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index f6c1f7955515..0b3ed2e0d159 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2001-08-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* concat.c (concat): Use VPARAMS, VA_OPEN, VA_FIXEDARG & VA_CLOSE.
+
 2001-08-23  Ulrich Drepper  <drepper@redhat.com>
 
 	* regex.c (truncate_wchar): Use wcrtomb not wctomb.
diff --git a/libiberty/concat.c b/libiberty/concat.c
index 01270eadcf2d..2e31e833f4db 100644
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -74,48 +74,29 @@ NOTES
 #  endif
 # endif
 
-/* VARARGS */
-#ifdef ANSI_PROTOTYPES
-char *
-concat (const char *first, ...)
-#else
 char *
-concat (va_alist)
-     va_dcl
-#endif
+concat VPARAMS ((const char *first, ...))
 {
   register size_t length;
   register char *newstr;
   register char *end;
   register const char *arg;
-  va_list args;
-#ifndef ANSI_PROTOTYPES
-  const char *first;
-#endif
 
   /* First compute the size of the result and get sufficient memory.  */
-#ifdef ANSI_PROTOTYPES
-  va_start (args, first);
-#else
-  va_start (args);
-  first = va_arg (args, const char *);
-#endif
-
+  VA_OPEN (args, first);
+  VA_FIXEDARG (args, const char *, first);
+  
   length = 0;
   for (arg = first; arg ; arg = va_arg (args, const char *))
     length += strlen (arg);
 
-  va_end (args);
+  VA_CLOSE (args);
 
   newstr = (char *) xmalloc (length + 1);
 
   /* Now copy the individual pieces to the result string. */
-#ifdef ANSI_PROTOTYPES
-  va_start (args, first);
-#else
-  va_start (args);
-  first = va_arg (args, const char *);
-#endif
+  VA_OPEN (args, first);
+  VA_FIXEDARG (args, const char *, first);
 
   end = newstr;
   for (arg = first; arg ; arg = va_arg (args, const char *))
@@ -125,7 +106,7 @@ concat (va_alist)
       end += length;
     }
   *end = '\000';
-  va_end (args);
+  VA_CLOSE (args);
 
   return newstr;
 }
-- 
GitLab