Révision | 281e9aa624806dfde63d006d7706dd84d54788d1 (tree) |
---|---|
l'heure | 2014-01-22 00:52:09 |
Auteur | tromey <tromey@138b...> |
Commiter | Tom Tromey |
[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
@@ -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 | + | |
1 | 9 | 2014-01-09 Tom Tromey <tromey@redhat.com> |
2 | 10 | |
3 | 11 | * gdbm.h: Remove. |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* ANSI and traditional C compatability macros |
2 | 2 | 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 | |
4 | 4 | Free Software Foundation, Inc. |
5 | 5 | This file is part of the GNU C Library. |
6 | 6 |
@@ -24,93 +24,16 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. | ||
24 | 24 | |
25 | 25 | Macro ANSI C definition Traditional C definition |
26 | 26 | ----- ---- - ---------- ----------- - ---------- |
27 | - ANSI_PROTOTYPES 1 not defined | |
28 | 27 | PTR `void *' `char *' |
29 | - PTRCONST `void *const' `char *' | |
30 | - LONG_DOUBLE `long double' `double' | |
31 | 28 | const not defined `' |
32 | 29 | volatile not defined `' |
33 | 30 | 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. | |
104 | 31 | |
105 | 32 | For ease of writing code which uses GCC extensions but needs to be |
106 | 33 | portable to other compilers, we provide the GCC_VERSION macro that |
107 | 34 | simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various |
108 | 35 | 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. */ | |
114 | 37 | |
115 | 38 | #ifndef _ANSIDECL_H |
116 | 39 | #define _ANSIDECL_H 1 |
@@ -149,28 +72,8 @@ So instead we use the macro below and test it against specific values. */ | ||
149 | 72 | C++ compilers, does not define __STDC__, though it acts as if this |
150 | 73 | was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */ |
151 | 74 | |
152 | -#define ANSI_PROTOTYPES 1 | |
153 | 75 | #define PTR void * |
154 | -#define PTRCONST void *const | |
155 | -#define LONG_DOUBLE long double | |
156 | 76 | |
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 | - | |
174 | 77 | #undef const |
175 | 78 | #undef volatile |
176 | 79 | #undef signed |
@@ -188,35 +91,9 @@ So instead we use the macro below and test it against specific values. */ | ||
188 | 91 | # endif |
189 | 92 | #endif |
190 | 93 | |
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 | - | |
206 | 94 | #else /* Not ANSI C. */ |
207 | 95 | |
208 | -#undef ANSI_PROTOTYPES | |
209 | 96 | #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) | |
220 | 97 | |
221 | 98 | /* some systems define these in header files for non-ansi mode */ |
222 | 99 | #undef const |
@@ -228,20 +105,6 @@ So instead we use the macro below and test it against specific values. */ | ||
228 | 105 | #define signed |
229 | 106 | #define inline |
230 | 107 | |
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 | - | |
245 | 108 | #endif /* ANSI C. */ |
246 | 109 | |
247 | 110 | /* Define macros for some gcc attributes. This permits us to use the |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* Function declarations for libiberty. |
2 | 2 | |
3 | 3 | 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. | |
5 | 5 | |
6 | 6 | Note - certain prototypes declared in this header file are for |
7 | 7 | functions whoes implementation copyright does not belong to the |
@@ -85,11 +85,11 @@ extern char **dupargv (char **) ATTRIBUTE_MALLOC; | ||
85 | 85 | |
86 | 86 | /* Expand "@file" arguments in argv. */ |
87 | 87 | |
88 | -extern void expandargv PARAMS ((int *, char ***)); | |
88 | +extern void expandargv (int *, char ***); | |
89 | 89 | |
90 | 90 | /* Write argv to an @-file, inserting necessary quoting. */ |
91 | 91 | |
92 | -extern int writeargv PARAMS ((char **, FILE *)); | |
92 | +extern int writeargv (char **, FILE *); | |
93 | 93 | |
94 | 94 | /* Return the number of elements in argv. */ |
95 | 95 |
@@ -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 | + | |
1 | 11 | 2014-01-06 Mike Frysinger <vapier@gentoo.org> |
2 | 12 | |
3 | 13 | PR other/56780 |
@@ -222,11 +222,11 @@ static int | ||
222 | 222 | checkit (const char* format, ...) |
223 | 223 | { |
224 | 224 | int result; |
225 | - VA_OPEN (args, format); | |
226 | - VA_FIXEDARG (args, char *, format); | |
225 | + va_list args; | |
226 | + va_start (args, format); | |
227 | 227 | |
228 | 228 | result = _doprnt (format, args, stdout); |
229 | - VA_CLOSE (args); | |
229 | + va_end (args); | |
230 | 230 | |
231 | 231 | return result; |
232 | 232 | } |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* Like sprintf but provides a pointer to malloc'd storage, which must |
2 | 2 | be freed by the caller. |
3 | - Copyright (C) 1997, 2003 Free Software Foundation, Inc. | |
3 | + Copyright (C) 1997, 2003, 2013 Free Software Foundation, Inc. | |
4 | 4 | Contributed by Cygnus Solutions. |
5 | 5 | |
6 | 6 | This file is part of the libiberty library. |
@@ -47,10 +47,9 @@ int | ||
47 | 47 | asprintf (char **buf, const char *fmt, ...) |
48 | 48 | { |
49 | 49 | 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); | |
53 | 52 | status = vasprintf (buf, fmt, ap); |
54 | - VA_CLOSE (ap); | |
53 | + va_end (ap); | |
55 | 54 | return status; |
56 | 55 | } |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* 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. | |
3 | 3 | Written by Fred Fish @ Cygnus Support |
4 | 4 | |
5 | 5 | This file is part of the libiberty library. |
@@ -90,11 +90,11 @@ unsigned long | ||
90 | 90 | concat_length (const char *first, ...) |
91 | 91 | { |
92 | 92 | unsigned long length; |
93 | + va_list args; | |
93 | 94 | |
94 | - VA_OPEN (args, first); | |
95 | - VA_FIXEDARG (args, const char *, first); | |
95 | + va_start (args, first); | |
96 | 96 | length = vconcat_length (first, args); |
97 | - VA_CLOSE (args); | |
97 | + va_end (args); | |
98 | 98 | |
99 | 99 | return length; |
100 | 100 | } |
@@ -105,13 +105,12 @@ char * | ||
105 | 105 | concat_copy (char *dst, const char *first, ...) |
106 | 106 | { |
107 | 107 | char *save_dst; |
108 | + va_list args; | |
108 | 109 | |
109 | - VA_OPEN (args, first); | |
110 | - VA_FIXEDARG (args, char *, dst); | |
111 | - VA_FIXEDARG (args, const char *, first); | |
110 | + va_start (args, first); | |
112 | 111 | vconcat_copy (dst, first, args); |
113 | 112 | save_dst = dst; /* With K&R C, dst goes out of scope here. */ |
114 | - VA_CLOSE (args); | |
113 | + va_end (args); | |
115 | 114 | |
116 | 115 | return save_dst; |
117 | 116 | } |
@@ -129,10 +128,10 @@ char *libiberty_concat_ptr; | ||
129 | 128 | char * |
130 | 129 | concat_copy2 (const char *first, ...) |
131 | 130 | { |
132 | - VA_OPEN (args, first); | |
133 | - VA_FIXEDARG (args, const char *, first); | |
131 | + va_list args; | |
132 | + va_start (args, first); | |
134 | 133 | vconcat_copy (libiberty_concat_ptr, first, args); |
135 | - VA_CLOSE (args); | |
134 | + va_end (args); | |
136 | 135 | |
137 | 136 | return libiberty_concat_ptr; |
138 | 137 | } |
@@ -141,18 +140,17 @@ char * | ||
141 | 140 | concat (const char *first, ...) |
142 | 141 | { |
143 | 142 | char *newstr; |
143 | + va_list args; | |
144 | 144 | |
145 | 145 | /* 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); | |
148 | 147 | newstr = XNEWVEC (char, vconcat_length (first, args) + 1); |
149 | - VA_CLOSE (args); | |
148 | + va_end (args); | |
150 | 149 | |
151 | 150 | /* 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); | |
154 | 152 | vconcat_copy (newstr, first, args); |
155 | - VA_CLOSE (args); | |
153 | + va_end (args); | |
156 | 154 | |
157 | 155 | return newstr; |
158 | 156 | } |
@@ -179,22 +177,19 @@ char * | ||
179 | 177 | reconcat (char *optr, const char *first, ...) |
180 | 178 | { |
181 | 179 | char *newstr; |
180 | + va_list args; | |
182 | 181 | |
183 | 182 | /* 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); | |
187 | 184 | newstr = XNEWVEC (char, vconcat_length (first, args) + 1); |
188 | - VA_CLOSE (args); | |
185 | + va_end (args); | |
189 | 186 | |
190 | 187 | /* 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); | |
194 | 189 | vconcat_copy (newstr, first, args); |
195 | 190 | if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C. */ |
196 | 191 | free (optr); |
197 | - VA_CLOSE (args); | |
192 | + va_end (args); | |
198 | 193 | |
199 | 194 | return newstr; |
200 | 195 | } |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* Implement the snprintf function. |
2 | - Copyright (C) 2003, 2011 Free Software Foundation, Inc. | |
2 | + Copyright (C) 2003, 2011, 2013 Free Software Foundation, Inc. | |
3 | 3 | Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. |
4 | 4 | |
5 | 5 | This file is part of the libiberty library. This library is free |
@@ -53,11 +53,9 @@ int | ||
53 | 53 | snprintf (char *s, size_t n, const char *format, ...) |
54 | 54 | { |
55 | 55 | 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); | |
60 | 58 | result = vsnprintf (s, n, format, ap); |
61 | - VA_CLOSE (ap); | |
59 | + va_end (ap); | |
62 | 60 | return result; |
63 | 61 | } |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* Like vsprintf but provides a pointer to malloc'd storage, which must |
2 | 2 | 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. | |
4 | 4 | |
5 | 5 | This file is part of the libiberty library. |
6 | 6 | Libiberty is free software; you can redistribute it and/or |
@@ -165,10 +165,10 @@ static void ATTRIBUTE_PRINTF_1 | ||
165 | 165 | checkit (const char *format, ...) |
166 | 166 | { |
167 | 167 | char *result; |
168 | - VA_OPEN (args, format); | |
169 | - VA_FIXEDARG (args, const char *, format); | |
168 | + va_list args; | |
169 | + va_start (args, format); | |
170 | 170 | vasprintf (&result, format, args); |
171 | - VA_CLOSE (args); | |
171 | + va_end (args); | |
172 | 172 | |
173 | 173 | if (strlen (result) < (size_t) global_total_width) |
174 | 174 | printf ("PASS: "); |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* 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. | |
3 | 3 | Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. |
4 | 4 | |
5 | 5 | This file is part of the libiberty library. This library is free |
@@ -95,12 +95,10 @@ static int ATTRIBUTE_PRINTF_3 | ||
95 | 95 | checkit (char *s, size_t n, const char *format, ...) |
96 | 96 | { |
97 | 97 | 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); | |
102 | 100 | result = vsnprintf (s, n, format, ap); |
103 | - VA_CLOSE (ap); | |
101 | + va_end (ap); | |
104 | 102 | return result; |
105 | 103 | } |
106 | 104 |