• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision281e9aa624806dfde63d006d7706dd84d54788d1 (tree)
l'heure2014-01-22 00:52:09
Auteurtromey <tromey@138b...>
CommiterTom Tromey

Message de Log

[PATCH] include * ansidecl.h (ANSI_PROTOTYPES, PTRCONST, LONG_DOUBLE, PARAMS) (VPARAMS, VA_START, VA_OPEN, VA_CLOSE, VA_FIXEDARG, CONST) (VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID, AND, DOTS) (NOARGS): Don't define. * libiberty.h (expandargv, writeargv): Don't use PARAMS. libiberty * _doprint.c (checkit): Use stdarg, not VA_* macros. * asprintf.c (asprintf): Use stdarg, not VA_* macros. * concat.c (concat_length, concat_copy, concat_copy2, concat) (reconcat): Use stdarg, not VA_* macros. * snprintf.c (snprintf): Use stdarg, not VA_* macros. * vasprintf.c (checkit): Use stdarg, not VA_* macros. * vsnprintf.c (checkit): Use stdarg, not VA_* macros.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206881 138bc75d-0d04-0410-961f-82ee72b054a4

Change Summary

Modification

--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,11 @@
1+2014-01-21 Tom Tromey <tromey@redhat.com>
2+
3+ * ansidecl.h (ANSI_PROTOTYPES, PTRCONST, LONG_DOUBLE, PARAMS)
4+ (VPARAMS, VA_START, VA_OPEN, VA_CLOSE, VA_FIXEDARG, CONST)
5+ (VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID, AND, DOTS)
6+ (NOARGS): Don't define.
7+ * libiberty.h (expandargv, writeargv): Don't use PARAMS.
8+
19 2014-01-09 Tom Tromey <tromey@redhat.com>
210
311 * gdbm.h: Remove.
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -1,6 +1,6 @@
11 /* ANSI and traditional C compatability macros
22 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
3- 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
3+ 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2013
44 Free Software Foundation, Inc.
55 This file is part of the GNU C Library.
66
@@ -24,93 +24,16 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
2424
2525 Macro ANSI C definition Traditional C definition
2626 ----- ---- - ---------- ----------- - ----------
27- ANSI_PROTOTYPES 1 not defined
2827 PTR `void *' `char *'
29- PTRCONST `void *const' `char *'
30- LONG_DOUBLE `long double' `double'
3128 const not defined `'
3229 volatile not defined `'
3330 signed not defined `'
34- VA_START(ap, var) va_start(ap, var) va_start(ap)
35-
36- Note that it is safe to write "void foo();" indicating a function
37- with no return value, in all K+R compilers we have been able to test.
38-
39- For declaring functions with prototypes, we also provide these:
40-
41- PARAMS ((prototype))
42- -- for functions which take a fixed number of arguments. Use this
43- when declaring the function. When defining the function, write a
44- K+R style argument list. For example:
45-
46- char *strcpy PARAMS ((char *dest, char *source));
47- ...
48- char *
49- strcpy (dest, source)
50- char *dest;
51- char *source;
52- { ... }
53-
54-
55- VPARAMS ((prototype, ...))
56- -- for functions which take a variable number of arguments. Use
57- PARAMS to declare the function, VPARAMS to define it. For example:
58-
59- int printf PARAMS ((const char *format, ...));
60- ...
61- int
62- printf VPARAMS ((const char *format, ...))
63- {
64- ...
65- }
66-
67- For writing functions which take variable numbers of arguments, we
68- also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros. These
69- hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
70- thoroughly than the simple VA_START() macro mentioned above.
71-
72- VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
73- Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
74- corresponding to the list of fixed arguments. Then use va_arg
75- normally to get the variable arguments, or pass your va_list object
76- around. You do not declare the va_list yourself; VA_OPEN does it
77- for you.
78-
79- Here is a complete example:
80-
81- int
82- printf VPARAMS ((const char *format, ...))
83- {
84- int result;
85-
86- VA_OPEN (ap, format);
87- VA_FIXEDARG (ap, const char *, format);
88-
89- result = vfprintf (stdout, format, ap);
90- VA_CLOSE (ap);
91-
92- return result;
93- }
94-
95-
96- You can declare variables either before or after the VA_OPEN,
97- VA_FIXEDARG sequence. Also, VA_OPEN and VA_CLOSE are the beginning
98- and end of a block. They must appear at the same nesting level,
99- and any variables declared after VA_OPEN go out of scope at
100- VA_CLOSE. Unfortunately, with a K+R compiler, that includes the
101- argument list. You can have multiple instances of VA_OPEN/VA_CLOSE
102- pairs in a single function in case you need to traverse the
103- argument list more than once.
10431
10532 For ease of writing code which uses GCC extensions but needs to be
10633 portable to other compilers, we provide the GCC_VERSION macro that
10734 simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
10835 wrappers around __attribute__. Also, __extension__ will be #defined
109- to nothing if it doesn't work. See below.
110-
111- This header also defines a lot of obsolete macros:
112- CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
113- AND, DOTS, NOARGS. Don't use them. */
36+ to nothing if it doesn't work. See below. */
11437
11538 #ifndef _ANSIDECL_H
11639 #define _ANSIDECL_H 1
@@ -149,28 +72,8 @@ So instead we use the macro below and test it against specific values. */
14972 C++ compilers, does not define __STDC__, though it acts as if this
15073 was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
15174
152-#define ANSI_PROTOTYPES 1
15375 #define PTR void *
154-#define PTRCONST void *const
155-#define LONG_DOUBLE long double
15676
157-/* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in
158- a #ifndef. */
159-#ifndef PARAMS
160-#define PARAMS(ARGS) ARGS
161-#endif
162-
163-#define VPARAMS(ARGS) ARGS
164-#define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR)
165-
166-/* variadic function helper macros */
167-/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
168- use without inhibiting further decls and without declaring an
169- actual variable. */
170-#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP, VAR); { struct Qdmy
171-#define VA_CLOSE(AP) } va_end(AP); }
172-#define VA_FIXEDARG(AP, T, N) struct Qdmy
173-
17477 #undef const
17578 #undef volatile
17679 #undef signed
@@ -188,35 +91,9 @@ So instead we use the macro below and test it against specific values. */
18891 # endif
18992 #endif
19093
191-/* These are obsolete. Do not use. */
192-#ifndef IN_GCC
193-#define CONST const
194-#define VOLATILE volatile
195-#define SIGNED signed
196-
197-#define PROTO(type, name, arglist) type name arglist
198-#define EXFUN(name, proto) name proto
199-#define DEFUN(name, arglist, args) name(args)
200-#define DEFUN_VOID(name) name(void)
201-#define AND ,
202-#define DOTS , ...
203-#define NOARGS void
204-#endif /* ! IN_GCC */
205-
20694 #else /* Not ANSI C. */
20795
208-#undef ANSI_PROTOTYPES
20996 #define PTR char *
210-#define PTRCONST PTR
211-#define LONG_DOUBLE double
212-
213-#define PARAMS(args) ()
214-#define VPARAMS(args) (va_alist) va_dcl
215-#define VA_START(va_list, var) va_start(va_list)
216-
217-#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP); { struct Qdmy
218-#define VA_CLOSE(AP) } va_end(AP); }
219-#define VA_FIXEDARG(AP, TYPE, NAME) TYPE NAME = va_arg(AP, TYPE)
22097
22198 /* some systems define these in header files for non-ansi mode */
22299 #undef const
@@ -228,20 +105,6 @@ So instead we use the macro below and test it against specific values. */
228105 #define signed
229106 #define inline
230107
231-#ifndef IN_GCC
232-#define CONST
233-#define VOLATILE
234-#define SIGNED
235-
236-#define PROTO(type, name, arglist) type name ()
237-#define EXFUN(name, proto) name()
238-#define DEFUN(name, arglist, args) name arglist args;
239-#define DEFUN_VOID(name) name()
240-#define AND ;
241-#define DOTS
242-#define NOARGS
243-#endif /* ! IN_GCC */
244-
245108 #endif /* ANSI C. */
246109
247110 /* Define macros for some gcc attributes. This permits us to use the
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -1,7 +1,7 @@
11 /* Function declarations for libiberty.
22
33 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4- 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4+ 2006, 2007, 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
55
66 Note - certain prototypes declared in this header file are for
77 functions whoes implementation copyright does not belong to the
@@ -85,11 +85,11 @@ extern char **dupargv (char **) ATTRIBUTE_MALLOC;
8585
8686 /* Expand "@file" arguments in argv. */
8787
88-extern void expandargv PARAMS ((int *, char ***));
88+extern void expandargv (int *, char ***);
8989
9090 /* Write argv to an @-file, inserting necessary quoting. */
9191
92-extern int writeargv PARAMS ((char **, FILE *));
92+extern int writeargv (char **, FILE *);
9393
9494 /* Return the number of elements in argv. */
9595
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,13 @@
1+2014-01-21 Tom Tromey <tromey@redhat.com>
2+
3+ * _doprint.c (checkit): Use stdarg, not VA_* macros.
4+ * asprintf.c (asprintf): Use stdarg, not VA_* macros.
5+ * concat.c (concat_length, concat_copy, concat_copy2, concat)
6+ (reconcat): Use stdarg, not VA_* macros.
7+ * snprintf.c (snprintf): Use stdarg, not VA_* macros.
8+ * vasprintf.c (checkit): Use stdarg, not VA_* macros.
9+ * vsnprintf.c (checkit): Use stdarg, not VA_* macros.
10+
111 2014-01-06 Mike Frysinger <vapier@gentoo.org>
212
313 PR other/56780
--- a/libiberty/_doprnt.c
+++ b/libiberty/_doprnt.c
@@ -222,11 +222,11 @@ static int
222222 checkit (const char* format, ...)
223223 {
224224 int result;
225- VA_OPEN (args, format);
226- VA_FIXEDARG (args, char *, format);
225+ va_list args;
226+ va_start (args, format);
227227
228228 result = _doprnt (format, args, stdout);
229- VA_CLOSE (args);
229+ va_end (args);
230230
231231 return result;
232232 }
--- a/libiberty/asprintf.c
+++ b/libiberty/asprintf.c
@@ -1,6 +1,6 @@
11 /* Like sprintf but provides a pointer to malloc'd storage, which must
22 be freed by the caller.
3- Copyright (C) 1997, 2003 Free Software Foundation, Inc.
3+ Copyright (C) 1997, 2003, 2013 Free Software Foundation, Inc.
44 Contributed by Cygnus Solutions.
55
66 This file is part of the libiberty library.
@@ -47,10 +47,9 @@ int
4747 asprintf (char **buf, const char *fmt, ...)
4848 {
4949 int status;
50- VA_OPEN (ap, fmt);
51- VA_FIXEDARG (ap, char **, buf);
52- VA_FIXEDARG (ap, const char *, fmt);
50+ va_list ap;
51+ va_start (ap, fmt);
5352 status = vasprintf (buf, fmt, ap);
54- VA_CLOSE (ap);
53+ va_end (ap);
5554 return status;
5655 }
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -1,5 +1,5 @@
11 /* Concatenate variable number of strings.
2- Copyright (C) 1991, 1994, 2001, 2011 Free Software Foundation, Inc.
2+ Copyright (C) 1991, 1994, 2001, 2011, 2013 Free Software Foundation, Inc.
33 Written by Fred Fish @ Cygnus Support
44
55 This file is part of the libiberty library.
@@ -90,11 +90,11 @@ unsigned long
9090 concat_length (const char *first, ...)
9191 {
9292 unsigned long length;
93+ va_list args;
9394
94- VA_OPEN (args, first);
95- VA_FIXEDARG (args, const char *, first);
95+ va_start (args, first);
9696 length = vconcat_length (first, args);
97- VA_CLOSE (args);
97+ va_end (args);
9898
9999 return length;
100100 }
@@ -105,13 +105,12 @@ char *
105105 concat_copy (char *dst, const char *first, ...)
106106 {
107107 char *save_dst;
108+ va_list args;
108109
109- VA_OPEN (args, first);
110- VA_FIXEDARG (args, char *, dst);
111- VA_FIXEDARG (args, const char *, first);
110+ va_start (args, first);
112111 vconcat_copy (dst, first, args);
113112 save_dst = dst; /* With K&R C, dst goes out of scope here. */
114- VA_CLOSE (args);
113+ va_end (args);
115114
116115 return save_dst;
117116 }
@@ -129,10 +128,10 @@ char *libiberty_concat_ptr;
129128 char *
130129 concat_copy2 (const char *first, ...)
131130 {
132- VA_OPEN (args, first);
133- VA_FIXEDARG (args, const char *, first);
131+ va_list args;
132+ va_start (args, first);
134133 vconcat_copy (libiberty_concat_ptr, first, args);
135- VA_CLOSE (args);
134+ va_end (args);
136135
137136 return libiberty_concat_ptr;
138137 }
@@ -141,18 +140,17 @@ char *
141140 concat (const char *first, ...)
142141 {
143142 char *newstr;
143+ va_list args;
144144
145145 /* First compute the size of the result and get sufficient memory. */
146- VA_OPEN (args, first);
147- VA_FIXEDARG (args, const char *, first);
146+ va_start (args, first);
148147 newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
149- VA_CLOSE (args);
148+ va_end (args);
150149
151150 /* Now copy the individual pieces to the result string. */
152- VA_OPEN (args, first);
153- VA_FIXEDARG (args, const char *, first);
151+ va_start (args, first);
154152 vconcat_copy (newstr, first, args);
155- VA_CLOSE (args);
153+ va_end (args);
156154
157155 return newstr;
158156 }
@@ -179,22 +177,19 @@ char *
179177 reconcat (char *optr, const char *first, ...)
180178 {
181179 char *newstr;
180+ va_list args;
182181
183182 /* First compute the size of the result and get sufficient memory. */
184- VA_OPEN (args, first);
185- VA_FIXEDARG (args, char *, optr);
186- VA_FIXEDARG (args, const char *, first);
183+ va_start (args, first);
187184 newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
188- VA_CLOSE (args);
185+ va_end (args);
189186
190187 /* Now copy the individual pieces to the result string. */
191- VA_OPEN (args, first);
192- VA_FIXEDARG (args, char *, optr);
193- VA_FIXEDARG (args, const char *, first);
188+ va_start (args, first);
194189 vconcat_copy (newstr, first, args);
195190 if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C. */
196191 free (optr);
197- VA_CLOSE (args);
192+ va_end (args);
198193
199194 return newstr;
200195 }
--- a/libiberty/snprintf.c
+++ b/libiberty/snprintf.c
@@ -1,5 +1,5 @@
11 /* Implement the snprintf function.
2- Copyright (C) 2003, 2011 Free Software Foundation, Inc.
2+ Copyright (C) 2003, 2011, 2013 Free Software Foundation, Inc.
33 Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
44
55 This file is part of the libiberty library. This library is free
@@ -53,11 +53,9 @@ int
5353 snprintf (char *s, size_t n, const char *format, ...)
5454 {
5555 int result;
56- VA_OPEN (ap, format);
57- VA_FIXEDARG (ap, char *, s);
58- VA_FIXEDARG (ap, size_t, n);
59- VA_FIXEDARG (ap, const char *, format);
56+ va_list ap;
57+ va_start (ap, format);
6058 result = vsnprintf (s, n, format, ap);
61- VA_CLOSE (ap);
59+ va_end (ap);
6260 return result;
6361 }
--- a/libiberty/vasprintf.c
+++ b/libiberty/vasprintf.c
@@ -1,6 +1,6 @@
11 /* Like vsprintf but provides a pointer to malloc'd storage, which must
22 be freed by the caller.
3- Copyright (C) 1994, 2003, 2011 Free Software Foundation, Inc.
3+ Copyright (C) 1994, 2003, 2011, 2013 Free Software Foundation, Inc.
44
55 This file is part of the libiberty library.
66 Libiberty is free software; you can redistribute it and/or
@@ -165,10 +165,10 @@ static void ATTRIBUTE_PRINTF_1
165165 checkit (const char *format, ...)
166166 {
167167 char *result;
168- VA_OPEN (args, format);
169- VA_FIXEDARG (args, const char *, format);
168+ va_list args;
169+ va_start (args, format);
170170 vasprintf (&result, format, args);
171- VA_CLOSE (args);
171+ va_end (args);
172172
173173 if (strlen (result) < (size_t) global_total_width)
174174 printf ("PASS: ");
--- a/libiberty/vsnprintf.c
+++ b/libiberty/vsnprintf.c
@@ -1,5 +1,5 @@
11 /* Implement the vsnprintf function.
2- Copyright (C) 2003, 2004, 2005, 2011 Free Software Foundation, Inc.
2+ Copyright (C) 2003, 2004, 2005, 2011, 2013 Free Software Foundation, Inc.
33 Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
44
55 This file is part of the libiberty library. This library is free
@@ -95,12 +95,10 @@ static int ATTRIBUTE_PRINTF_3
9595 checkit (char *s, size_t n, const char *format, ...)
9696 {
9797 int result;
98- VA_OPEN (ap, format);
99- VA_FIXEDARG (ap, char *, s);
100- VA_FIXEDARG (ap, size_t, n);
101- VA_FIXEDARG (ap, const char *, format);
98+ va_list ap;
99+ va_start (ap, format);
102100 result = vsnprintf (s, n, format, ap);
103- VA_CLOSE (ap);
101+ va_end (ap);
104102 return result;
105103 }
106104