Debian Codegraph @

src/main/sequence.c

raw symbols SCIP
1 /*
2 *
3 * Sequence data type. This type is designed to be derived from by
4 * the curve and dither matrix types.
5 *
6 * Copyright 2002-2003 Robert Krawitz ([email protected])
7 * Copyright 2003 Roger Leigh ([email protected])
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
24 #include <config.h>cxx . . $ `<file>/config.h`/
25 #endif
26 #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/
27 #include <gutenprint/sequence.h>cxx . . $ `<file>/include/gutenprint/sequence.h`/
28 #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/
29 #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/
30 #include <math.h>
31 #ifdef sun
32 #include <ieeefp.h>
33 #endif
34 #include <string.h>
35 #include <stdlib.h>
36 #include <limits.h>
37 #include <errno.h>
38 #include <ctype.h>
39
40 struct stp_sequencecxx . . $ stp_sequence#
41 {
42 int recompute_rangecxx . . $ stp_sequence#recompute_range.; /* Do we need to recompute the min and max? */
43 double blocxx . . $ stp_sequence#blo.; /* Lower bound */
44 double bhicxx . . $ stp_sequence#bhi.; /* Upper bound */
45 double rlocxx . . $ stp_sequence#rlo.; /* Lower range limit */
46 double rhicxx . . $ stp_sequence#rhi.; /* Upper range limit */
47 size_t sizecxx . . $ stp_sequence#size.; /* Number of points */
48 double *datacxx . . $ stp_sequence#data.; /* Array of doubles */
49 float *float_datacxx . . $ stp_sequence#float_data.; /* Data converted to other form */
50 long *long_datacxx . . $ stp_sequence#long_data.;
51 unsigned long *ulong_datacxx . . $ stp_sequence#ulong_data.;
52 int *int_datacxx . . $ stp_sequence#int_data.;
53 unsigned *uint_datacxx . . $ stp_sequence#uint_data.;
54 short *short_datacxx . . $ stp_sequence#short_data.;
55 unsigned short *ushort_datacxx . . $ stp_sequence#ushort_data.;
56 };
57
58 /*
59 * We could do more sanity checks here if we want.
60 */
61
62 #define CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence) STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(sequence, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
63
64 static void
65 sequence_ctorcxx . . $ sequence_ctor(58667e1f04cce976).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
66 {
67 sequence->rlocxx . . $ stp_sequence#rlo. = sequence->blocxx . . $ stp_sequence#blo. = 0.0;
68 sequence->rhicxx . . $ stp_sequence#rhi. = sequence->bhicxx . . $ stp_sequence#bhi. = 1.0;
69 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1;
70 sequence->sizecxx . . $ stp_sequence#size. = 0;
71 sequence->datacxx . . $ stp_sequence#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
72 }
73
74 stp_sequence_tcxx . . $ stp_sequence_t# *
75 stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).(void)
76 {
77 stp_sequence_tcxx . . $ stp_sequence_t# *ret;
78 ret = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(stp_sequence_tcxx . . $ stp_sequence_t#));
79 sequence_ctorcxx . . $ sequence_ctor(58667e1f04cce976).(ret);
80 return ret;
81 }
82
83 static void
84 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
85 {
86 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->float_data);
87 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->long_data);
88 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->ulong_data);
89 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->int_data);
90 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->uint_data);
91 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->short_data);
92 STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(sequence->ushort_data);
93 }
94
95 static void
96 sequence_dtorcxx . . $ sequence_dtor(58667e1f04cce976).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
97 {
98 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(sequence);
99 if (sequence->datacxx . . $ stp_sequence#data.)
100 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sequence->datacxx . . $ stp_sequence#data.);
101 memsetcxx . . $ memset(d1de1e4fb215f1c6).(sequence, 0, sizeof(stp_sequence_tcxx . . $ stp_sequence_t#));
102 }
103
104 void
105 stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
106 {
107 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
108 sequence_dtorcxx . . $ sequence_dtor(58667e1f04cce976).(sequence);
109 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sequence);
110 }
111
112 void
113 stp_sequence_copycxx . . $ stp_sequence_copy(d2364ad210b53cd1).(stp_sequence_tcxx . . $ stp_sequence_t# *dest, const stp_sequence_tcxx . . $ stp_sequence_t# *source)
114 {
115 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(dest);
116 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(source);
117
118 dest->recompute_rangecxx . . $ stp_sequence#recompute_range. = source->recompute_rangecxx . . $ stp_sequence#recompute_range.;
119 dest->blocxx . . $ stp_sequence#blo. = source->blocxx . . $ stp_sequence#blo.;
120 dest->bhicxx . . $ stp_sequence#bhi. = source->bhicxx . . $ stp_sequence#bhi.;
121 dest->rlocxx . . $ stp_sequence#rlo. = source->rlocxx . . $ stp_sequence#rlo.;
122 dest->rhicxx . . $ stp_sequence#rhi. = source->rhicxx . . $ stp_sequence#rhi.;
123 dest->sizecxx . . $ stp_sequence#size. = source->sizecxx . . $ stp_sequence#size.;
124 dest->datacxx . . $ stp_sequence#data. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(double) * source->sizecxx . . $ stp_sequence#size.);
125 memcpycxx . . $ memcpy(cc817cb175f282d).(dest->datacxx . . $ stp_sequence#data., source->datacxx . . $ stp_sequence#data., (sizeof(double) * source->sizecxx . . $ stp_sequence#size.));
126 }
127
128 void
129 stp_sequence_reversecxx . . $ stp_sequence_reverse(d2364ad210b53cd1).(stp_sequence_tcxx . . $ stp_sequence_t# *dest, const stp_sequence_tcxx . . $ stp_sequence_t# *source)
130 {
131 unsigned int i;
132 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(dest);
133 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(source);
134
135 dest->recompute_rangecxx . . $ stp_sequence#recompute_range. = source->recompute_rangecxx . . $ stp_sequence#recompute_range.;
136 dest->blocxx . . $ stp_sequence#blo. = source->blocxx . . $ stp_sequence#blo.;
137 dest->bhicxx . . $ stp_sequence#bhi. = source->bhicxx . . $ stp_sequence#bhi.;
138 dest->rlocxx . . $ stp_sequence#rlo. = source->rlocxx . . $ stp_sequence#rlo.;
139 dest->rhicxx . . $ stp_sequence#rhi. = source->rhicxx . . $ stp_sequence#rhi.;
140 dest->sizecxx . . $ stp_sequence#size. = source->sizecxx . . $ stp_sequence#size.;
141 dest->datacxx . . $ stp_sequence#data. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(double) * source->sizecxx . . $ stp_sequence#size.);
142 for (i = 0; i < source->sizecxx . . $ stp_sequence#size.; i++)
143 dest->datacxx . . $ stp_sequence#data.[i] = source->datacxx . . $ stp_sequence#data.[source->sizecxx . . $ stp_sequence#size. - i - 1];
144 }
145
146 stp_sequence_tcxx . . $ stp_sequence_t# *
147 stp_sequence_create_copycxx . . $ stp_sequence_create_copy(e5907136df4f5f97).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
148 {
149 stp_sequence_tcxx . . $ stp_sequence_t# *ret;
150 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
151 ret = stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).();
152 stp_sequence_copycxx . . $ stp_sequence_copy(d2364ad210b53cd1).(ret, sequence);
153 return ret;
154 }
155
156 stp_sequence_tcxx . . $ stp_sequence_t# *
157 stp_sequence_create_reversecxx . . $ stp_sequence_create_reverse(e5907136df4f5f97).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
158 {
159 stp_sequence_tcxx . . $ stp_sequence_t# *ret;
160 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
161 ret = stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).();
162 stp_sequence_reversecxx . . $ stp_sequence_reverse(d2364ad210b53cd1).(ret, sequence);
163 return ret;
164 }
165
166 int
167 stp_sequence_set_boundscxx . . $ stp_sequence_set_bounds(d74b306f919ecc73).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence, double low, double high)
168 {
169 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
170 if (low > high)
171 return 0;
172 sequence->rlocxx . . $ stp_sequence#rlo. = sequence->blocxx . . $ stp_sequence#blo. = low;
173 sequence->rhicxx . . $ stp_sequence#rhi. = sequence->bhicxx . . $ stp_sequence#bhi. = high;
174 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1;
175 return 1;
176 }
177
178 void
179 stp_sequence_get_boundscxx . . $ stp_sequence_get_bounds(f1c777fa1c0d001).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence,
180 double *low, double *high)
181 {
182 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
183 *low = sequence->blocxx . . $ stp_sequence#blo.;
184 *high = sequence->bhicxx . . $ stp_sequence#bhi.;
185 }
186
187
188 /*
189 * Find the minimum and maximum points on the curve.
190 */
191 static void
192 scan_sequence_rangecxx . . $ scan_sequence_range(58667e1f04cce976).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
193 {
194 unsigned int i;
195 sequence->rlocxx . . $ stp_sequence#rlo. = sequence->bhicxx . . $ stp_sequence#bhi.;
196 sequence->rhicxx . . $ stp_sequence#rhi. = sequence->blocxx . . $ stp_sequence#blo.;
197 if (sequence->sizecxx . . $ stp_sequence#size.)
198 for (i = 0; i < sequence->sizecxx . . $ stp_sequence#size.; i++)
199 {
200 if (sequence->datacxx . . $ stp_sequence#data.[i] < sequence->rlocxx . . $ stp_sequence#rlo.)
201 sequence->rlocxx . . $ stp_sequence#rlo. = sequence->datacxx . . $ stp_sequence#data.[i];
202 if (sequence->datacxx . . $ stp_sequence#data.[i] > sequence->rhicxx . . $ stp_sequence#rhi.)
203 sequence->rhicxx . . $ stp_sequence#rhi. = sequence->datacxx . . $ stp_sequence#data.[i];
204 }
205 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 0; /* Don't recompute unless the data changes */
206 }
207
208 void
209 stp_sequence_get_rangecxx . . $ stp_sequence_get_range(f1c777fa1c0d001).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence,
210 double *low, double *high)
211 {
212 if (sequence->recompute_rangecxx . . $ stp_sequence#recompute_range.) /* Don't recompute the range if we don't
213 need to. */
214 scan_sequence_rangecxx . . $ scan_sequence_range(58667e1f04cce976).((stp_sequence_tcxx . . $ stp_sequence_t# *) stpi_cast_safecxx . . $ stpi_cast_safe(3343d82129b43479).(sequence));
215 *low = sequence->rlocxx . . $ stp_sequence#rlo.;
216 *high = sequence->rhicxx . . $ stp_sequence#rhi.;
217 }
218
219
220 int
221 stp_sequence_set_sizecxx . . $ stp_sequence_set_size(cb447bd5d582db64).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence, size_t size)
222 {
223 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
224 if (sequence->datacxx . . $ stp_sequence#data.) /* Free old data */
225 {
226 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sequence->datacxx . . $ stp_sequence#data.);
227 sequence->datacxx . . $ stp_sequence#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
228 }
229 sequence->sizecxx . . $ stp_sequence#size. = size;
230 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1; /* Always recompute on change */
231 if (size == 0)
232 return 1;
233 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(sequence);
234 sequence->datacxx . . $ stp_sequence#data. = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(double) * size);
235 return 1;
236 }
237
238
239 size_t
240 stp_sequence_get_sizecxx . . $ stp_sequence_get_size(57c44cb7f90fb5bc).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence)
241 {
242 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
243 return sequence->sizecxx . . $ stp_sequence#size.;
244 }
245
246
247
248 int
249 stp_sequence_set_datacxx . . $ stp_sequence_set_data(eaf6acc80580ab39).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence,
250 size_t size, const double *data)
251 {
252 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
253 sequence->sizecxx . . $ stp_sequence#size. = size;
254 if (sequence->datacxx . . $ stp_sequence#data.)
255 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sequence->datacxx . . $ stp_sequence#data.);
256 sequence->datacxx . . $ stp_sequence#data. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(double) * size);
257 memcpycxx . . $ memcpy(cc817cb175f282d).(sequence->datacxx . . $ stp_sequence#data., data, (sizeof(double) * size));
258 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(sequence);
259 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1;
260 return 1;
261 }
262
263 int
264 stp_sequence_set_subrangecxx . . $ stp_sequence_set_subrange(3a82d5ae3a6d1032).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence, size_t where,
265 size_t size, const double *data)
266 {
267 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
268 if (where + size > sequence->sizecxx . . $ stp_sequence#size.) /* Exceeds data size */
269 return 0;
270 memcpycxx . . $ memcpy(cc817cb175f282d).(sequence->datacxx . . $ stp_sequence#data.+where, data, (sizeof(double) * size));
271 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(sequence);
272 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1;
273 return 1;
274 }
275
276
277 void
278 stp_sequence_get_datacxx . . $ stp_sequence_get_data(5acce6d1b35abc9a).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence, size_t *size,
279 const double **data)
280 {
281 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
282 *size = sequence->sizecxx . . $ stp_sequence#size.;
283 *data = sequence->datacxx . . $ stp_sequence#data.;
284 }
285
286
287 int
288 stp_sequence_set_pointcxx . . $ stp_sequence_set_point(e632f4aa9a6329ba).(stp_sequence_tcxx . . $ stp_sequence_t# *sequence, size_t where,
289 double data)
290 {
291 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
292
293 if (where >= sequence->sizecxx . . $ stp_sequence#size. || ! isfinitecxx . . $ `<external>/11263917310783833665/math.h:963:11`!(data) ||
294 data < sequence->blocxx . . $ stp_sequence#blo. || data > sequence->bhicxx . . $ stp_sequence#bhi.)
295 return 0;
296
297 if (sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. == 0 && (data < sequence->rlocxx . . $ stp_sequence#rlo. ||
298 data > sequence->rhicxx . . $ stp_sequence#rhi. ||
299 sequence->datacxx . . $ stp_sequence#data.[where] == sequence->rhicxx . . $ stp_sequence#rhi. ||
300 sequence->datacxx . . $ stp_sequence#data.[where] == sequence->rlocxx . . $ stp_sequence#rlo.))
301 sequence->recompute_rangecxx . . $ stp_sequence#recompute_range. = 1;
302
303 sequence->datacxx . . $ stp_sequence#data.[where] = data;
304 invalidate_auxilliary_datacxx . . $ invalidate_auxilliary_data(58667e1f04cce976).(sequence);
305 return 1;
306 }
307
308 int
309 stp_sequence_get_pointcxx . . $ stp_sequence_get_point(dd05bfc28554384c).(const stp_sequence_tcxx . . $ stp_sequence_t# *sequence, size_t where,
310 double *data)
311 {
312 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence);
313
314 if (where >= sequence->sizecxx . . $ stp_sequence#size.)
315 return 0;
316 *data = sequence->datacxx . . $ stp_sequence#data.[where];
317 return 1;
318 }
319
320 stp_sequence_tcxx . . $ stp_sequence_t# *
321 stp_sequence_create_from_xmltreecxx . . $ stp_sequence_create_from_xmltree(46d170727e408206).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *da)
322 {
323 const char *stmp;
324 stp_sequence_tcxx . . $ stp_sequence_t# *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
325 size_t point_count;
326 double low, high;
327 unsigned int i;
328
329 ret = stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).();
330
331 /* Get curve point count */
332 stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(da, "count");
333 if (stmp)
334 {
335 point_count = (size_t) stp_xmlstrtoulcxx . . $ stp_xmlstrtoul(751346f8406fd082).(stmp);
336 if ((stp_xmlstrtolcxx . . $ stp_xmlstrtol(3c95bd14d5d5d286).(stmp)) < 0)
337 {
338 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: \"count\" is less than zero\n");
339 goto error;
340 }
341 }
342 else
343 {
344 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: \"count\" missing\n");
345 goto error;
346 }
347 /* Get lower bound */
348 stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(da, "lower-bound");
349 if (stmp)
350 {
351 low = stp_xmlstrtodcxx . . $ stp_xmlstrtod(9a18bdb0e56c1bc2).(stmp);
352 }
353 else
354 {
355 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: \"lower-bound\" missing\n");
356 goto error;
357 }
358 /* Get upper bound */
359 stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(da, "upper-bound");
360 if (stmp)
361 {
362 high = stp_xmlstrtodcxx . . $ stp_xmlstrtod(9a18bdb0e56c1bc2).(stmp);
363 }
364 else
365 {
366 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: \"upper-bound\" missing\n");
367 goto error;
368 }
369
370 stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!,
371 "stp_sequence_create_from_xmltree: stp_sequence_set_size: %ld\n",
372 (long)point_count);
373 stp_sequence_set_sizecxx . . $ stp_sequence_set_size(cb447bd5d582db64).(ret, point_count);
374 stp_sequence_set_boundscxx . . $ stp_sequence_set_bounds(d74b306f919ecc73).(ret, low, high);
375
376 /* Now read in the data points */
377 if (point_count)
378 {
379 stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child = da->childcxx . . $ stp_mxml_node_s#child.;
380 i = 0;
381 while (child && i < point_count)
382 {
383 if (child->typecxx . . $ stp_mxml_node_s#type. == STP_MXML_TEXTcxx . . $ STP_MXML_TEXT.)
384 {
385 char *endptr;
386 /*
387 * Explicitly documented that callers to strtod should clear
388 * errno before calling it if they want to check the return
389 * status.
390 */
391 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
392 double tmpval = strtodcxx . . $ strtod(3dfe5620a0d3160e).(child->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..stringcxx . . $ stp_mxml_text_s#string., &endptr);
393 if (endptr == child->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..stringcxx . . $ stp_mxml_text_s#string.)
394 {
395 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).
396 ("stp_sequence_create_from_xmltree: bad data %s\n",
397 child->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..stringcxx . . $ stp_mxml_text_s#string.);
398 goto error;
399 }
400 if (! isfinitecxx . . $ `<external>/11263917310783833665/math.h:963:11`!(tmpval)
401 || ( tmpval == 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`! )
402 || tmpval < low
403 || tmpval > high)
404 {
405 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: "
406 "read aborted: datum out of bounds: "
407 "%g %d %s (require %g <= x <= %g), n = %d\n",
408 tmpval, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, child->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..stringcxx . . $ stp_mxml_text_s#string.,
409 low, high, i);
410 goto error;
411 }
412 /* Datum was valid, so now add to the sequence */
413 stp_sequence_set_pointcxx . . $ stp_sequence_set_point(e632f4aa9a6329ba).(ret, i, tmpval);
414 i++;
415 }
416 child = child->nextcxx . . $ stp_mxml_node_s#next.;
417 }
418 if (i < point_count)
419 {
420 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: "
421 "read aborted: too little data "
422 "(n=%d, needed %ld)\n", i, (long)point_count);
423 goto error;
424 }
425 }
426
427 return ret;
428
429 error:
430 stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_sequence_create_from_xmltree: error during sequence read\n");
431 if (ret)
432 stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(ret);
433 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
434 }
435
436 stp_mxml_node_tcxx . . $ stp_mxml_node_t# *
437 stp_xmltree_create_from_sequencecxx . . $ stp_xmltree_create_from_sequence(5a8928e2ae29fea3).(const stp_sequence_tcxx . . $ stp_sequence_t# *seq) /* The sequence */
438 {
439 size_t pointcount;
440 double low;
441 double high;
442
443 char *count;
444 char *lower_bound;
445 char *upper_bound;
446
447 stp_mxml_node_tcxx . . $ stp_mxml_node_t# *seqnode;
448
449 unsigned int i; /* loop counter */
450
451 pointcount = stp_sequence_get_sizecxx . . $ stp_sequence_get_size(57c44cb7f90fb5bc).(seq);
452 stp_sequence_get_boundscxx . . $ stp_sequence_get_bounds(f1c777fa1c0d001).(seq, &low, &high);
453
454 /* should count be of greater precision? */
455 stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&count, "%lu", (unsigned long) pointcount);
456 stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&lower_bound, "%g", low);
457 stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&upper_bound, "%g", high);
458
459 seqnode = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sequence");
460 (void) stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(seqnode, "count", count);
461 (void) stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(seqnode, "lower-bound", lower_bound);
462 (void) stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(seqnode, "upper-bound", upper_bound);
463
464 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(count);
465 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(lower_bound);
466 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(upper_bound);
467
468 /* Write the curve points into the node content */
469 if (pointcount) /* Is there any data to write? */
470 {
471 for (i = 0; i < pointcount; i++)
472 {
473 double dval;
474 char *sval;
475
476 if ((stp_sequence_get_pointcxx . . $ stp_sequence_get_point(dd05bfc28554384c).(seq, i, &dval)) != 1)
477 goto error;
478
479 stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&sval, "%g", dval);
480 stp_mxmlNewTextcxx . . $ stp_mxmlNewText(a1e8609c1a01b87b).(seqnode, 1, sval);
481 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(sval);
482 }
483 }
484 return seqnode;
485
486 error:
487 if (seqnode)
488 stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(seqnode);
489 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
490 }
491
492
493 #define isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!(x) (1)
494
495 /* "Overloaded" functions */
496
497 #define DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(t, name, checkfinite) \
498 int \
499 stp_sequence_set_##name##_data(stp_sequence_t *sequence, \
500 size_t count, const t *data) \
501 { \
502 unsigned int i; \
503 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence); \
504 if (count < 2) \
505 return 0; \
506 \
507 /* Validate the data before we commit to it. */ \
508 for (i = 0; i < count; i++) \
509 if ((! checkfinite(data[i])) || \
510 data[i] < sequence->blo || \
511 data[i] > sequence->bhi) \
512 return 0; \
513 stp_sequence_set_size(sequence, count); \
514 for (i = 0; i < count; i++) \
515 stp_sequence_set_point(sequence, i, (double) data[i]); \
516 return 1; \
517 }
518
519 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(float, float, isfinitecxx . . $ `<external>/11263917310783833665/math.h:963:11`!)
520 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(long, long, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
521 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(unsigned long, ulong, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
522 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(int, int, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
523 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(unsigned int, uint, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
524 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(short, short, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
525 DEFINE_DATA_SETTERcxx . . $ `src/main/sequence.c:497:9`!(unsigned short, ushort, isfinite_nullcxx . . $ `src/main/sequence.c:493:9`!)
526
527 #define DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(t, lb, ub, name) \
528 const t * \
529 stp_sequence_get_##name##_data(const stp_sequence_t *sequence, size_t *count) \
530 { \
531 unsigned int i; \
532 CHECK_SEQUENCEcxx . . $ `src/main/sequence.c:62:9`!(sequence); \
533 if (sequence->blo < (double) lb || sequence->bhi > (double) ub) \
534 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; \
535 if (!sequence->name##_data) \
536 { \
537 stp_sequence_t *seq = (stp_sequence_t *) stpi_cast_safe(sequence); \
538 seq->name##_data = stp_zalloc(sizeof(t) * sequence->size); \
539 for (i = 0; i < sequence->size; i++) \
540 seq->name##_data[i] = (t) sequence->data[i]; \
541 } \
542 *count = sequence->size; \
543 return sequence->name##_data; \
544 }
545
546 #ifndef HUGE_VALFcxx . . $ `<external>/11263917310783833665/math.h:59:11`! /* ISO constant, from <math.h> */
547 #define HUGE_VALF 3.402823466E+38F
548 #endif
549
550 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(float, -HUGE_VALFcxx . . $ `<external>/11263917310783833665/math.h:59:11`!, HUGE_VALFcxx . . $ `<external>/11263917310783833665/math.h:59:11`!, float)
551 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(long, LONG_MINcxx . . $ `<external>/67164224788392828/limits.h:129:9`!, LONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:131:9`!, long)
552 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(unsigned long, 0, ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`!, ulong)
553 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(int, INT_MINcxx . . $ `<external>/67164224788392828/limits.h:118:9`!, INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!, int)
554 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(unsigned int, 0, UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!, uint)
555 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(short, SHRT_MINcxx . . $ `<external>/67164224788392828/limits.h:104:9`!, SHRT_MAXcxx . . $ `<external>/67164224788392828/limits.h:106:9`!, short)
556 DEFINE_DATA_ACCESSORcxx . . $ `src/main/sequence.c:527:9`!(unsigned short, 0, USHRT_MAXcxx . . $ `<external>/67164224788392828/limits.h:113:10`!, ushort)