1 |
tetromino 11/10/28 20:41:32 |
2 |
|
3 |
Added: rply-1.01-lc_numeric.patch rply-1.01-stdint.h.patch |
4 |
rply_CMakeLists.txt |
5 |
Log: |
6 |
New ebuild, moved from gnome overlay. |
7 |
|
8 |
(Portage version: 2.2.0_alpha71/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 media-libs/rply/files/rply-1.01-lc_numeric.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply-1.01-lc_numeric.patch?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply-1.01-lc_numeric.patch?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: rply-1.01-lc_numeric.patch |
17 |
=================================================================== |
18 |
From 8a7a76b7dcc94e8e71725e26a146330c73377ebd Mon Sep 17 00:00:00 2001 |
19 |
From: Alexandre Rostovtsev <tetromino@×××××.com> |
20 |
Date: Mon, 26 Sep 2011 04:46:44 -0400 |
21 |
Subject: [PATCH 2/2] Switch LC_NUMERIC locale to "C" for decimal point |
22 |
separator safety |
23 |
|
24 |
Make sure to switch the LC_NUMERIC locale to "C" when using strtod() and |
25 |
fpritnf("%g",...) to ensure that '.' is used as the decimal point |
26 |
separator when reading and writing .ply files. |
27 |
--- |
28 |
rply.c | 31 +++++++++++++++++++++++++++---- |
29 |
1 files changed, 27 insertions(+), 4 deletions(-) |
30 |
|
31 |
diff --git a/rply.c b/rply.c |
32 |
index 9eaa77f..789c002 100644 |
33 |
--- a/rply.c |
34 |
+++ b/rply.c |
35 |
@@ -12,6 +12,7 @@ |
36 |
#include <string.h> |
37 |
#include <limits.h> |
38 |
#include <float.h> |
39 |
+#include <locale.h> |
40 |
#include <stdarg.h> |
41 |
#include <stdlib.h> |
42 |
#include <stddef.h> |
43 |
@@ -1229,13 +1230,27 @@ static int oascii_uint32(p_ply ply, double value) { |
44 |
} |
45 |
|
46 |
static int oascii_float32(p_ply ply, double value) { |
47 |
+ char *curr_locale; |
48 |
+ int ret; |
49 |
if (value < -FLT_MAX || value > FLT_MAX) return 0; |
50 |
- return fprintf(ply->fp, "%g ", (float) value) > 0; |
51 |
+ /* Switch locale to C to use '.' as the decimal point separator */ |
52 |
+ curr_locale = setlocale(LC_NUMERIC, NULL); |
53 |
+ setlocale(LC_NUMERIC, "C"); |
54 |
+ ret = fprintf(ply->fp, "%g ", (float) value); |
55 |
+ setlocale(LC_NUMERIC, curr_locale); |
56 |
+ return ret > 0; |
57 |
} |
58 |
|
59 |
static int oascii_float64(p_ply ply, double value) { |
60 |
+ char *curr_locale; |
61 |
+ int ret; |
62 |
if (value < -DBL_MAX || value > DBL_MAX) return 0; |
63 |
- return fprintf(ply->fp, "%g ", value) > 0; |
64 |
+ /* Switch locale to C to use '.' as the decimal point separator */ |
65 |
+ curr_locale = setlocale(LC_NUMERIC, NULL); |
66 |
+ setlocale(LC_NUMERIC, "C"); |
67 |
+ ret = fprintf(ply->fp, "%g ", value); |
68 |
+ setlocale(LC_NUMERIC, curr_locale); |
69 |
+ return ret > 0; |
70 |
} |
71 |
|
72 |
static int obinary_int8(p_ply ply, double value) { |
73 |
@@ -1336,17 +1351,25 @@ static int iascii_uint32(p_ply ply, double *value) { |
74 |
} |
75 |
|
76 |
static int iascii_float32(p_ply ply, double *value) { |
77 |
- char *end; |
78 |
+ char *end, *curr_locale; |
79 |
if (!ply_read_word(ply)) return 0; |
80 |
+ /* Switch locale to C to use '.' as the decimal point separator */ |
81 |
+ curr_locale = setlocale(LC_NUMERIC, NULL); |
82 |
+ setlocale(LC_NUMERIC, "C"); |
83 |
*value = strtod(BWORD(ply), &end); |
84 |
+ setlocale(LC_NUMERIC, curr_locale); |
85 |
if (*end || *value < -FLT_MAX || *value > FLT_MAX) return 0; |
86 |
return 1; |
87 |
} |
88 |
|
89 |
static int iascii_float64(p_ply ply, double *value) { |
90 |
- char *end; |
91 |
+ char *end, *curr_locale; |
92 |
if (!ply_read_word(ply)) return 0; |
93 |
+ /* Switch locale to C to use '.' as the decimal point separator */ |
94 |
+ curr_locale = setlocale(LC_NUMERIC, NULL); |
95 |
+ setlocale(LC_NUMERIC, "C"); |
96 |
*value = strtod(BWORD(ply), &end); |
97 |
+ setlocale(LC_NUMERIC, curr_locale); |
98 |
if (*end || *value < -DBL_MAX || *value > DBL_MAX) return 0; |
99 |
return 1; |
100 |
} |
101 |
-- |
102 |
1.7.6.1 |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
1.1 media-libs/rply/files/rply-1.01-stdint.h.patch |
108 |
|
109 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply-1.01-stdint.h.patch?rev=1.1&view=markup |
110 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply-1.01-stdint.h.patch?rev=1.1&content-type=text/plain |
111 |
|
112 |
Index: rply-1.01-stdint.h.patch |
113 |
=================================================================== |
114 |
From eeb09032068baed6d81cff01cdfcccd6d55a8152 Mon Sep 17 00:00:00 2001 |
115 |
From: Alexandre Rostovtsev <tetromino@×××××.com> |
116 |
Date: Mon, 26 Sep 2011 04:45:49 -0400 |
117 |
Subject: [PATCH 1/2] Use stdint.h types |
118 |
|
119 |
Use stdint.h types (int16_t and int32_t) instead of assuming that short |
120 |
and long must always a specific number of bytes. Also, use strtoul for |
121 |
reading uint32_t values. |
122 |
--- |
123 |
rply.c | 61 ++++++++++++++++++++++++++++--------------------------------- |
124 |
1 files changed, 28 insertions(+), 33 deletions(-) |
125 |
|
126 |
diff --git a/rply.c b/rply.c |
127 |
index 042244f..9eaa77f 100644 |
128 |
--- a/rply.c |
129 |
+++ b/rply.c |
130 |
@@ -15,6 +15,7 @@ |
131 |
#include <stdarg.h> |
132 |
#include <stdlib.h> |
133 |
#include <stddef.h> |
134 |
+#include <stdint.h> |
135 |
|
136 |
#include "rply.h" |
137 |
|
138 |
@@ -1183,18 +1184,12 @@ static e_ply_storage_mode ply_arch_endian(void) { |
139 |
static int ply_type_check(void) { |
140 |
assert(sizeof(char) == 1); |
141 |
assert(sizeof(unsigned char) == 1); |
142 |
- assert(sizeof(short) == 2); |
143 |
- assert(sizeof(unsigned short) == 2); |
144 |
- assert(sizeof(long) == 4); |
145 |
- assert(sizeof(unsigned long) == 4); |
146 |
+ assert(sizeof(long) >= 4); |
147 |
assert(sizeof(float) == 4); |
148 |
assert(sizeof(double) == 8); |
149 |
if (sizeof(char) != 1) return 0; |
150 |
if (sizeof(unsigned char) != 1) return 0; |
151 |
- if (sizeof(short) != 2) return 0; |
152 |
- if (sizeof(unsigned short) != 2) return 0; |
153 |
- if (sizeof(long) != 4) return 0; |
154 |
- if (sizeof(unsigned long) != 4) return 0; |
155 |
+ if (sizeof(long) < 4) return 0; |
156 |
if (sizeof(float) != 4) return 0; |
157 |
if (sizeof(double) != 8) return 0; |
158 |
return 1; |
159 |
@@ -1214,23 +1209,23 @@ static int oascii_uint8(p_ply ply, double value) { |
160 |
} |
161 |
|
162 |
static int oascii_int16(p_ply ply, double value) { |
163 |
- if (value > SHRT_MAX || value < SHRT_MIN) return 0; |
164 |
- return fprintf(ply->fp, "%d ", (short) value) > 0; |
165 |
+ if (value > INT16_MAX || value < INT16_MIN) return 0; |
166 |
+ return fprintf(ply->fp, "%d ", (int16_t) value) > 0; |
167 |
} |
168 |
|
169 |
static int oascii_uint16(p_ply ply, double value) { |
170 |
- if (value > USHRT_MAX || value < 0) return 0; |
171 |
- return fprintf(ply->fp, "%d ", (unsigned short) value) > 0; |
172 |
+ if (value > UINT16_MAX || value < 0) return 0; |
173 |
+ return fprintf(ply->fp, "%d ", (uint16_t) value) > 0; |
174 |
} |
175 |
|
176 |
static int oascii_int32(p_ply ply, double value) { |
177 |
- if (value > LONG_MAX || value < LONG_MIN) return 0; |
178 |
- return fprintf(ply->fp, "%d ", (int) value) > 0; |
179 |
+ if (value > INT32_MAX || value < INT32_MIN) return 0; |
180 |
+ return fprintf(ply->fp, "%d ", (int32_t) value) > 0; |
181 |
} |
182 |
|
183 |
static int oascii_uint32(p_ply ply, double value) { |
184 |
- if (value > ULONG_MAX || value < 0) return 0; |
185 |
- return fprintf(ply->fp, "%d ", (unsigned int) value) > 0; |
186 |
+ if (value > UINT32_MAX || value < 0) return 0; |
187 |
+ return fprintf(ply->fp, "%d ", (uint32_t) value) > 0; |
188 |
} |
189 |
|
190 |
static int oascii_float32(p_ply ply, double value) { |
191 |
@@ -1256,26 +1251,26 @@ static int obinary_uint8(p_ply ply, double value) { |
192 |
} |
193 |
|
194 |
static int obinary_int16(p_ply ply, double value) { |
195 |
- short int16 = (short) value; |
196 |
- if (value > SHRT_MAX || value < SHRT_MIN) return 0; |
197 |
+ int16_t int16 = value; |
198 |
+ if (value > INT16_MAX || value < INT16_MIN) return 0; |
199 |
return ply->odriver->ochunk(ply, &int16, sizeof(int16)); |
200 |
} |
201 |
|
202 |
static int obinary_uint16(p_ply ply, double value) { |
203 |
- unsigned short uint16 = (unsigned short) value; |
204 |
- if (value > USHRT_MAX || value < 0) return 0; |
205 |
+ uint16_t uint16 = value; |
206 |
+ if (value > UINT16_MAX || value < 0) return 0; |
207 |
return ply->odriver->ochunk(ply, &uint16, sizeof(uint16)); |
208 |
} |
209 |
|
210 |
static int obinary_int32(p_ply ply, double value) { |
211 |
- long int32 = (long) value; |
212 |
- if (value > LONG_MAX || value < LONG_MIN) return 0; |
213 |
+ int32_t int32 = value; |
214 |
+ if (value > INT32_MAX || value < INT32_MIN) return 0; |
215 |
return ply->odriver->ochunk(ply, &int32, sizeof(int32)); |
216 |
} |
217 |
|
218 |
static int obinary_uint32(p_ply ply, double value) { |
219 |
- unsigned long uint32 = (unsigned long) value; |
220 |
- if (value > ULONG_MAX || value < 0) return 0; |
221 |
+ uint32_t uint32 = value; |
222 |
+ if (value > UINT32_MAX || value < 0) return 0; |
223 |
return ply->odriver->ochunk(ply, &uint32, sizeof(uint32)); |
224 |
} |
225 |
|
226 |
@@ -1312,7 +1307,7 @@ static int iascii_int16(p_ply ply, double *value) { |
227 |
char *end; |
228 |
if (!ply_read_word(ply)) return 0; |
229 |
*value = strtol(BWORD(ply), &end, 10); |
230 |
- if (*end || *value > SHRT_MAX || *value < SHRT_MIN) return 0; |
231 |
+ if (*end || *value > INT16_MAX || *value < INT16_MIN) return 0; |
232 |
return 1; |
233 |
} |
234 |
|
235 |
@@ -1320,7 +1315,7 @@ static int iascii_uint16(p_ply ply, double *value) { |
236 |
char *end; |
237 |
if (!ply_read_word(ply)) return 0; |
238 |
*value = strtol(BWORD(ply), &end, 10); |
239 |
- if (*end || *value > USHRT_MAX || *value < 0) return 0; |
240 |
+ if (*end || *value > UINT16_MAX || *value < 0) return 0; |
241 |
return 1; |
242 |
} |
243 |
|
244 |
@@ -1328,15 +1323,15 @@ static int iascii_int32(p_ply ply, double *value) { |
245 |
char *end; |
246 |
if (!ply_read_word(ply)) return 0; |
247 |
*value = strtol(BWORD(ply), &end, 10); |
248 |
- if (*end || *value > LONG_MAX || *value < LONG_MIN) return 0; |
249 |
+ if (*end || *value > INT32_MAX || *value < INT32_MIN) return 0; |
250 |
return 1; |
251 |
} |
252 |
|
253 |
static int iascii_uint32(p_ply ply, double *value) { |
254 |
char *end; |
255 |
if (!ply_read_word(ply)) return 0; |
256 |
- *value = strtol(BWORD(ply), &end, 10); |
257 |
- if (*end || *value < 0) return 0; |
258 |
+ *value = strtoul(BWORD(ply), &end, 10); |
259 |
+ if (*end || *value > UINT32_MAX || *value < 0) return 0; |
260 |
return 1; |
261 |
} |
262 |
|
263 |
@@ -1371,28 +1366,28 @@ static int ibinary_uint8(p_ply ply, double *value) { |
264 |
} |
265 |
|
266 |
static int ibinary_int16(p_ply ply, double *value) { |
267 |
- short int16; |
268 |
+ int16_t int16; |
269 |
if (!ply->idriver->ichunk(ply, &int16, sizeof(int16))) return 0; |
270 |
*value = int16; |
271 |
return 1; |
272 |
} |
273 |
|
274 |
static int ibinary_uint16(p_ply ply, double *value) { |
275 |
- unsigned short uint16; |
276 |
+ uint16_t uint16; |
277 |
if (!ply->idriver->ichunk(ply, &uint16, sizeof(uint16))) return 0; |
278 |
*value = uint16; |
279 |
return 1; |
280 |
} |
281 |
|
282 |
static int ibinary_int32(p_ply ply, double *value) { |
283 |
- long int32; |
284 |
+ int32_t int32; |
285 |
if (!ply->idriver->ichunk(ply, &int32, sizeof(int32))) return 0; |
286 |
*value = int32; |
287 |
return 1; |
288 |
} |
289 |
|
290 |
static int ibinary_uint32(p_ply ply, double *value) { |
291 |
- unsigned long uint32; |
292 |
+ uint32_t uint32; |
293 |
if (!ply->idriver->ichunk(ply, &uint32, sizeof(uint32))) return 0; |
294 |
*value = uint32; |
295 |
return 1; |
296 |
-- |
297 |
1.7.6.1 |
298 |
|
299 |
|
300 |
|
301 |
|
302 |
1.1 media-libs/rply/files/rply_CMakeLists.txt |
303 |
|
304 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply_CMakeLists.txt?rev=1.1&view=markup |
305 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-libs/rply/files/rply_CMakeLists.txt?rev=1.1&content-type=text/plain |
306 |
|
307 |
Index: rply_CMakeLists.txt |
308 |
=================================================================== |
309 |
# Fedora's cmake file for rply |
310 |
# http://pkgs.fedoraproject.org/gitweb/?p=rply.git;a=blob;f=rply_CMakeLists.txt |
311 |
PROJECT(rply) |
312 |
cmake_minimum_required(VERSION 2.6) |
313 |
|
314 |
SET(RPLY_LIB_MAJOR_VERSION 1) |
315 |
SET(RPLY_LIB_MINOR_VERSION 01) |
316 |
|
317 |
SET(RPLY_CMAKE_DIR ${CMAKE_SOURCE_DIR}/CMake/ ) |
318 |
SET(RPLY_LIBRARY librply.so ) |
319 |
|
320 |
add_library(rply SHARED rply.c ) |
321 |
set_target_properties( rply PROPERTIES |
322 |
VERSION ${RPLY_LIB_MAJOR_VERSION}.${RPLY_LIB_MINOR_VERSION} |
323 |
SOVERSION ${RPLY_LIB_MAJOR_VERSION} |
324 |
) |
325 |
|
326 |
include_directories( ${CMAKE_SOURCE_DIR} ) |
327 |
add_executable(rply_convert etc/convert.c ) |
328 |
add_executable(rply_dump etc/dump.c ) |
329 |
add_executable(rply_sconvert etc/sconvert.c ) |
330 |
target_link_libraries (rply_convert rply) |
331 |
target_link_libraries (rply_dump rply) |
332 |
target_link_libraries (rply_sconvert rply) |
333 |
|
334 |
# Installs the header files |
335 |
install(FILES rply.h DESTINATION include/rply) |
336 |
|
337 |
# Installs the target file |
338 |
install(TARGETS rply LIBRARY DESTINATION lib${LIB_SUFFIX}) |
339 |
install(TARGETS rply_convert RUNTIME DESTINATION bin) |
340 |
install(TARGETS rply_dump RUNTIME DESTINATION bin) |
341 |
install(TARGETS rply_sconvert RUNTIME DESTINATION bin) |
342 |
|
343 |
#This should be the last line of the project |
344 |
SUBDIRS( CMake/export ) |