Gentoo Archives: gentoo-commits

From: "Justin Lecher (jlec)" <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in media-libs/ming/files: ming-0.4.4-vasprintf.patch
Date: Tue, 05 Jun 2012 16:28:25
Message-Id: 20120605162813.637FD2004C@flycatcher.gentoo.org
1 jlec 12/06/05 16:28:13
2
3 Added: ming-0.4.4-vasprintf.patch
4 Log:
5 media-libs/ming: Version Bump, moved to EAPI=4 and autotools-utils.eclass, add fix for gcc-4.7, #417499
6
7 (Portage version: 2.2.0_alpha110/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 media-libs/ming/files/ming-0.4.4-vasprintf.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/ming/files/ming-0.4.4-vasprintf.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/ming/files/ming-0.4.4-vasprintf.patch?rev=1.1&content-type=text/plain
14
15 Index: ming-0.4.4-vasprintf.patch
16 ===================================================================
17 From 815f18295602dfabfad53b754fbcaad91e2198bc Mon Sep 17 00:00:00 2001
18 Message-Id: <815f18295602dfabfad53b754fbcaad91e2198bc.1338912967.git.jlec@g.o>
19 From: Sandro Santilli <strk@××××××.net>
20 Date: Sat, 29 Oct 2011 08:41:17 +0200
21 Subject: [PATCH] Put vasprintf own implementation in its own file
22
23 ---
24 test/actionscript/ActionScriptTest.c | 1 +
25 test/actionscript/Makefile.am | 2 +-
26 util/Makefile.am | 6 +++-
27 util/decompile.c | 44 +++------------------------------
28 util/makeswf.c | 39 ------------------------------
29 util/makeswf_utils.c | 1 +
30 util/vasprintf.c | 43 +++++++++++++++++++++++++++++++++
31 util/vasprintf.h | 7 +++++
32 8 files changed, 61 insertions(+), 82 deletions(-)
33
34 diff --git a/test/actionscript/ActionScriptTest.c b/test/actionscript/ActionScriptTest.c
35 index b351711..5af64c4 100644
36 --- a/test/actionscript/ActionScriptTest.c
37 +++ b/test/actionscript/ActionScriptTest.c
38 @@ -40,6 +40,7 @@
39 #include <sys/stat.h>
40 #include <limits.h>
41 #include <makeswf.h>
42 +#include <vasprintf.h>
43
44 static SWFMovie
45 compile(const char* filename, const char* ppfile, int version)
46 diff --git a/test/actionscript/Makefile.am b/test/actionscript/Makefile.am
47 index ae415ab..40e64e2 100644
48 --- a/test/actionscript/Makefile.am
49 +++ b/test/actionscript/Makefile.am
50 @@ -83,7 +83,7 @@ CLEANFILES = *.pp *.swf
51 check_PROGRAMS = \
52 ActionScriptTest
53
54 -ActionScriptTest_SOURCES = ActionScriptTest.c ../run_test.c ../../util/makeswf_utils.c
55 +ActionScriptTest_SOURCES = ActionScriptTest.c ../run_test.c ../../util/makeswf_utils.c ../../util/vasprintf.c
56 ActionScriptTest_LDADD = $(top_builddir)/src/libming.la
57 ActionScriptTest_CFLAGS = -DTOP_BUILDDIR='"$(top_builddir)"' -DTOP_SOURCEDIR='"$(srcdir)"' -I$(top_srcdir)/util/ -DAS_TESTS='"$(AS_TESTS)"'
58
59 diff --git a/util/Makefile.am b/util/Makefile.am
60 index 0668f4f..3a7c9c4 100644
61 --- a/util/Makefile.am
62 +++ b/util/Makefile.am
63 @@ -45,7 +45,8 @@ libutil_la_SOURCES = \
64 blocktypes.c \
65 decompile.c \
66 parser.c \
67 - read.c
68 + read.c \
69 + vasprintf.c
70
71 libutil_la_LIBADD = $(MATHLIB) $(ZLIB)
72
73 @@ -60,7 +61,8 @@ noinst_HEADERS = \
74 parser.h \
75 read.h \
76 swfoutput.h \
77 - swftypes.h
78 + swftypes.h \
79 + vasprintf.c
80
81 listswf_SOURCES = outputtxt.c main.c
82 listswf_LDADD = libutil.la $(top_builddir)/src/libming.la
83 diff --git a/util/decompile.c b/util/decompile.c
84 index 1af7a9f..c844fa4 100644
85 --- a/util/decompile.c
86 +++ b/util/decompile.c
87 @@ -18,7 +18,7 @@
88 *
89 ****************************************************************************/
90
91 -#define _GNU_SOURCE
92 +#define _GNU_SOURCE 1
93
94 #define DEBUGSTACK
95 #define DECOMP_SWITCH
96 @@ -42,45 +42,8 @@
97 #include "action.h"
98 #include "swftypes.h"
99 #include "../src/blocks/error.h"
100 +#include "vasprintf.h"
101
102 -#ifndef HAVE_VASPRINTF
103 -/* Workaround for the lack of vasprintf()
104 - * As found on: http://unixpapa.com/incnote/stdio.html
105 - * Seems to be Public Domain
106 - */
107 -int
108 -vasprintf(char **ret, const char *format, va_list ap)
109 -{
110 - va_list ap2;
111 - int len = 100; /* First guess at the size */
112 - if ((*ret = (char *) malloc(len)) == NULL)
113 - {
114 - return -1;
115 - }
116 - while (1)
117 - {
118 - int nchar;
119 - va_copy(ap2, ap);
120 - nchar= vsnprintf(*ret, len, format, ap2);
121 - if (nchar > -1 && nchar < len)
122 - {
123 - return nchar;
124 - }
125 - if (nchar > len)
126 - {
127 - len= nchar+1;
128 - } else
129 - {
130 - len*= 2;
131 - }
132 - if ((*ret = (char *) realloc(*ret, len)) == NULL)
133 - {
134 - free(*ret);
135 - return -1;
136 - }
137 - }
138 -}
139 -#endif
140
141 static char **pool;
142 struct SWF_ACTIONPUSHPARAM *regs[256];
143 @@ -247,10 +210,11 @@ static void
144 println(const char* fmt, ...)
145 {
146 char *tmp;
147 + int written;
148
149 va_list ap;
150 va_start (ap, fmt);
151 - vasprintf (&tmp, fmt, ap);
152 + written = vasprintf (&tmp, fmt, ap);
153
154 dcprintf("%s%s", tmp, newlinestring);
155
156 diff --git a/util/makeswf.c b/util/makeswf.c
157 index 0b80728..4fdc826 100644
158 --- a/util/makeswf.c
159 +++ b/util/makeswf.c
160 @@ -76,45 +76,6 @@
161 #include <getopt.h>
162 #endif
163
164 -#ifndef HAVE_VASPRINTF
165 -/* Workaround for the lack of vasprintf()
166 - * As found on: http://unixpapa.com/incnote/stdio.html
167 - * Seems to be Public Domain
168 - */
169 -int
170 -vasprintf(char **ret, const char *format, va_list ap)
171 -{
172 - va_list ap2;
173 - int len = 100; /* First guess at the size */
174 - if ((*ret = (char *) malloc(len)) == NULL)
175 - {
176 - return -1;
177 - }
178 - while (1)
179 - {
180 - int nchar;
181 - va_copy(ap2, ap);
182 - nchar= vsnprintf(*ret, len, format, ap2);
183 - if (nchar > -1 && nchar < len)
184 - {
185 - return nchar;
186 - }
187 - if (nchar > len)
188 - {
189 - len= nchar+1;
190 - } else
191 - {
192 - len*= 2;
193 - }
194 - if ((*ret = (char *) realloc(*ret, len)) == NULL)
195 - {
196 - free(*ret);
197 - return -1;
198 - }
199 - }
200 -}
201 -#endif
202 -
203 #define DEFSWFVERSION 6
204 #define DEFSWFCOMPRESSION 9
205
206 diff --git a/util/makeswf_utils.c b/util/makeswf_utils.c
207 index f9f53bd..6a65d87 100644
208 --- a/util/makeswf_utils.c
209 +++ b/util/makeswf_utils.c
210 @@ -41,6 +41,7 @@
211 #ifdef HAVE_GETOPT_H
212 #include <getopt.h>
213 #endif
214 +#include "vasprintf.h"
215
216 // Cheating, but it works (not sure why the above ifdef for getopt isn't)
217 #ifdef _WIN32
218 diff --git a/util/vasprintf.c b/util/vasprintf.c
219 new file mode 100644
220 index 0000000..1127664
221 --- /dev/null
222 +++ b/util/vasprintf.c
223 @@ -0,0 +1,43 @@
224 +#include <stdio.h>
225 +#include <stdlib.h>
226 +#include <stdarg.h>
227 +
228 +#ifndef HAVE_VASPRINTF
229 +/* Workaround for the lack of vasprintf()
230 + * As found on: http://unixpapa.com/incnote/stdio.html
231 + * Seems to be Public Domain
232 + */
233 +int
234 +vasprintf(char **ret, const char *format, va_list ap)
235 +{
236 + va_list ap2;
237 + int len = 100; /* First guess at the size */
238 + if ((*ret = (char *) malloc(len)) == NULL)
239 + {
240 + return -1;
241 + }
242 + while (1)
243 + {
244 + int nchar;
245 + va_copy(ap2, ap);
246 + nchar= vsnprintf(*ret, len, format, ap2);
247 + if (nchar > -1 && nchar < len)
248 + {
249 + return nchar;
250 + }
251 + if (nchar > len)
252 + {
253 + len= nchar+1;
254 + } else
255 + {
256 + len*= 2;
257 + }
258 + if ((*ret = (char *) realloc(*ret, len)) == NULL)
259 + {
260 + free(*ret);
261 + return -1;
262 + }
263 + }
264 +}
265 +#endif
266 +
267 diff --git a/util/vasprintf.h b/util/vasprintf.h
268 new file mode 100644
269 index 0000000..9391c23
270 --- /dev/null
271 +++ b/util/vasprintf.h
272 @@ -0,0 +1,7 @@
273 +#include <stdio.h>
274 +#include "ming_config.h"
275 +
276 +#ifndef HAVE_VASPRINTF
277 +int vasprintf(char **ret, const char *format, va_list ap);
278 +#endif
279 +
280 --
281 1.7.8.6