Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Printf. */
2 : : /* M2Printf.mod provides a simple printf capability.
3 : :
4 : : Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : # if !defined (TRUE)
33 : : # define TRUE (1==1)
34 : : # endif
35 : :
36 : : # if !defined (FALSE)
37 : : # define FALSE (1==0)
38 : : # endif
39 : :
40 : : #if defined(__cplusplus)
41 : : # undef NULL
42 : : # define NULL 0
43 : : #endif
44 : : #define _M2Printf_C
45 : :
46 : : #include "GM2Printf.h"
47 : : # include "GSFIO.h"
48 : : # include "GFIO.h"
49 : : # include "GDynamicStrings.h"
50 : : # include "GStrLib.h"
51 : : # include "GFormatStrings.h"
52 : : # include "GNameKey.h"
53 : : # include "GM2RTS.h"
54 : :
55 : :
56 : : /*
57 : : printf0 - writes out an array to, StdOut, after the escape
58 : : sequences have been translated.
59 : : */
60 : :
61 : : extern "C" void M2Printf_printf0 (const char *a_, unsigned int _a_high);
62 : :
63 : : /*
64 : : printf0 - writes out an array to, StdOut, after the escape
65 : : sequences have been translated.
66 : : */
67 : :
68 : : extern "C" void M2Printf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
69 : :
70 : : /*
71 : : printf0 - writes out an array to, StdOut, after the escape
72 : : sequences have been translated.
73 : : */
74 : :
75 : : extern "C" void M2Printf_printf2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
76 : :
77 : : /*
78 : : printf0 - writes out an array to, StdOut, after the escape
79 : : sequences have been translated.
80 : : */
81 : :
82 : : extern "C" void M2Printf_printf3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
83 : :
84 : : /*
85 : : printf0 - writes out an array to, StdOut, after the escape
86 : : sequences have been translated.
87 : : */
88 : :
89 : : extern "C" void M2Printf_printf4 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
90 : :
91 : : /*
92 : : fprintf0 - writes out an array to, file, after the escape sequences
93 : : have been translated.
94 : : */
95 : :
96 : : extern "C" void M2Printf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high);
97 : :
98 : : /*
99 : : fprintf0 - writes out an array to, file, after the escape sequences
100 : : have been translated.
101 : : */
102 : :
103 : : extern "C" void M2Printf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
104 : :
105 : : /*
106 : : fprintf0 - writes out an array to, file, after the escape sequences
107 : : have been translated.
108 : : */
109 : :
110 : : extern "C" void M2Printf_fprintf2 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
111 : :
112 : : /*
113 : : fprintf0 - writes out an array to, file, after the escape sequences
114 : : have been translated.
115 : : */
116 : :
117 : : extern "C" void M2Printf_fprintf3 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
118 : :
119 : : /*
120 : : fprintf0 - writes out an array to, file, after the escape sequences
121 : : have been translated.
122 : : */
123 : :
124 : : extern "C" void M2Printf_fprintf4 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
125 : :
126 : : /*
127 : : Cast - casts a := b
128 : : */
129 : :
130 : : static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b_, unsigned int _b_high);
131 : :
132 : : /*
133 : : TranslateNameToCharStar - takes a format specification string, a, and
134 : : if it contains %a then this is translated
135 : : into a String and %a is replaced by %s.
136 : : */
137 : :
138 : : static bool TranslateNameToCharStar (char *a, unsigned int _a_high, unsigned int n);
139 : :
140 : :
141 : : /*
142 : : Cast - casts a := b
143 : : */
144 : :
145 : 572 : static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b_, unsigned int _b_high)
146 : : {
147 : 572 : unsigned int i;
148 : 572 : unsigned char b[_b_high+1];
149 : :
150 : : /* make a local copy of each unbounded array. */
151 : 572 : memcpy (b, b_, _b_high+1);
152 : :
153 : 572 : if (_a_high == _b_high)
154 : : {
155 : 2860 : for (i=0; i<=_a_high; i++)
156 : : {
157 : 2288 : const_cast<unsigned char *>(a)[i] = b[i];
158 : : }
159 : : }
160 : : else
161 : : {
162 : 0 : M2RTS_HALT (-1);
163 : : __builtin_unreachable ();
164 : : }
165 : 572 : }
166 : :
167 : :
168 : : /*
169 : : TranslateNameToCharStar - takes a format specification string, a, and
170 : : if it contains %a then this is translated
171 : : into a String and %a is replaced by %s.
172 : : */
173 : :
174 : 573 : static bool TranslateNameToCharStar (char *a, unsigned int _a_high, unsigned int n)
175 : : {
176 : 573 : unsigned int argno;
177 : 573 : unsigned int i;
178 : 573 : unsigned int h;
179 : :
180 : 573 : argno = 1;
181 : 573 : i = 0;
182 : 573 : h = StrLib_StrLen ((const char *) a, _a_high);
183 : 17177 : while (i < h)
184 : : {
185 : 16604 : if ((a[i] == '%') && ((i+1) < h))
186 : : {
187 : 573 : if ((a[i+1] == 'a') && (argno == n))
188 : : {
189 : 572 : const_cast<char *>(a)[i+1] = 's';
190 : 572 : return true;
191 : : }
192 : 1 : argno += 1;
193 : 1 : if (argno > n)
194 : : {
195 : : /* all done */
196 : : return false;
197 : : }
198 : : }
199 : 16031 : i += 1;
200 : : }
201 : : return false;
202 : : /* static analysis guarentees a RETURN statement will be used before here. */
203 : : __builtin_unreachable ();
204 : : }
205 : :
206 : :
207 : : /*
208 : : printf0 - writes out an array to, StdOut, after the escape
209 : : sequences have been translated.
210 : : */
211 : :
212 : 0 : extern "C" void M2Printf_printf0 (const char *a_, unsigned int _a_high)
213 : : {
214 : 0 : char a[_a_high+1];
215 : :
216 : : /* make a local copy of each unbounded array. */
217 : 0 : memcpy (a, a_, _a_high+1);
218 : :
219 : 0 : M2Printf_fprintf0 (FIO_StdOut, (const char *) a, _a_high);
220 : 0 : }
221 : :
222 : :
223 : : /*
224 : : printf0 - writes out an array to, StdOut, after the escape
225 : : sequences have been translated.
226 : : */
227 : :
228 : 572 : extern "C" void M2Printf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
229 : : {
230 : 572 : char a[_a_high+1];
231 : 572 : unsigned char w[_w_high+1];
232 : :
233 : : /* make a local copy of each unbounded array. */
234 : 572 : memcpy (a, a_, _a_high+1);
235 : 572 : memcpy (w, w_, _w_high+1);
236 : :
237 : 572 : M2Printf_fprintf1 (FIO_StdOut, (const char *) a, _a_high, (const unsigned char *) w, _w_high);
238 : 572 : }
239 : :
240 : :
241 : : /*
242 : : printf0 - writes out an array to, StdOut, after the escape
243 : : sequences have been translated.
244 : : */
245 : :
246 : 0 : extern "C" void M2Printf_printf2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high)
247 : : {
248 : 0 : char a[_a_high+1];
249 : 0 : unsigned char w1[_w1_high+1];
250 : 0 : unsigned char w2[_w2_high+1];
251 : :
252 : : /* make a local copy of each unbounded array. */
253 : 0 : memcpy (a, a_, _a_high+1);
254 : 0 : memcpy (w1, w1_, _w1_high+1);
255 : 0 : memcpy (w2, w2_, _w2_high+1);
256 : :
257 : 0 : M2Printf_fprintf2 (FIO_StdOut, (const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high);
258 : 0 : }
259 : :
260 : :
261 : : /*
262 : : printf0 - writes out an array to, StdOut, after the escape
263 : : sequences have been translated.
264 : : */
265 : :
266 : 0 : extern "C" void M2Printf_printf3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high)
267 : : {
268 : 0 : char a[_a_high+1];
269 : 0 : unsigned char w1[_w1_high+1];
270 : 0 : unsigned char w2[_w2_high+1];
271 : 0 : unsigned char w3[_w3_high+1];
272 : :
273 : : /* make a local copy of each unbounded array. */
274 : 0 : memcpy (a, a_, _a_high+1);
275 : 0 : memcpy (w1, w1_, _w1_high+1);
276 : 0 : memcpy (w2, w2_, _w2_high+1);
277 : 0 : memcpy (w3, w3_, _w3_high+1);
278 : :
279 : 0 : M2Printf_fprintf3 (FIO_StdOut, (const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
280 : 0 : }
281 : :
282 : :
283 : : /*
284 : : printf0 - writes out an array to, StdOut, after the escape
285 : : sequences have been translated.
286 : : */
287 : :
288 : 0 : extern "C" void M2Printf_printf4 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high)
289 : : {
290 : 0 : char a[_a_high+1];
291 : 0 : unsigned char w1[_w1_high+1];
292 : 0 : unsigned char w2[_w2_high+1];
293 : 0 : unsigned char w3[_w3_high+1];
294 : 0 : unsigned char w4[_w4_high+1];
295 : :
296 : : /* make a local copy of each unbounded array. */
297 : 0 : memcpy (a, a_, _a_high+1);
298 : 0 : memcpy (w1, w1_, _w1_high+1);
299 : 0 : memcpy (w2, w2_, _w2_high+1);
300 : 0 : memcpy (w3, w3_, _w3_high+1);
301 : 0 : memcpy (w4, w4_, _w4_high+1);
302 : :
303 : 0 : M2Printf_fprintf4 (FIO_StdOut, (const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high, (const unsigned char *) w4, _w4_high);
304 : 0 : }
305 : :
306 : :
307 : : /*
308 : : fprintf0 - writes out an array to, file, after the escape sequences
309 : : have been translated.
310 : : */
311 : :
312 : 0 : extern "C" void M2Printf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high)
313 : : {
314 : 0 : char a[_a_high+1];
315 : :
316 : : /* make a local copy of each unbounded array. */
317 : 0 : memcpy (a, a_, _a_high+1);
318 : :
319 : 0 : if ((DynamicStrings_KillString (SFIO_WriteS (file, FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) a, _a_high))))) == NULL)
320 : : {} /* empty. */
321 : 0 : }
322 : :
323 : :
324 : : /*
325 : : fprintf0 - writes out an array to, file, after the escape sequences
326 : : have been translated.
327 : : */
328 : :
329 : 573 : extern "C" void M2Printf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
330 : : {
331 : 573 : DynamicStrings_String s;
332 : 573 : DynamicStrings_String t;
333 : 573 : NameKey_Name n;
334 : 573 : char a[_a_high+1];
335 : 573 : unsigned char w[_w_high+1];
336 : :
337 : : /* make a local copy of each unbounded array. */
338 : 573 : memcpy (a, a_, _a_high+1);
339 : 573 : memcpy (w, w_, _w_high+1);
340 : :
341 : 573 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
342 : : {
343 : 572 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w, _w_high);
344 : 572 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
345 : 572 : t = DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high));
346 : 572 : s = FormatStrings_Sprintf1 (t, (const unsigned char *) &s, (sizeof (s)-1));
347 : : }
348 : : else
349 : : {
350 : 1 : t = DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high));
351 : 1 : s = FormatStrings_Sprintf1 (t, (const unsigned char *) w, _w_high);
352 : : }
353 : 573 : if ((DynamicStrings_KillString (SFIO_WriteS (file, s))) == NULL)
354 : : {} /* empty. */
355 : 573 : }
356 : :
357 : :
358 : : /*
359 : : fprintf0 - writes out an array to, file, after the escape sequences
360 : : have been translated.
361 : : */
362 : :
363 : 0 : extern "C" void M2Printf_fprintf2 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high)
364 : : {
365 : 0 : NameKey_Name n;
366 : 0 : DynamicStrings_String s;
367 : 0 : DynamicStrings_String s1;
368 : 0 : DynamicStrings_String s2;
369 : 0 : unsigned int b;
370 : 0 : char a[_a_high+1];
371 : 0 : unsigned char w1[_w1_high+1];
372 : 0 : unsigned char w2[_w2_high+1];
373 : :
374 : : /* make a local copy of each unbounded array. */
375 : 0 : memcpy (a, a_, _a_high+1);
376 : 0 : memcpy (w1, w1_, _w1_high+1);
377 : 0 : memcpy (w2, w2_, _w2_high+1);
378 : :
379 : 0 : b = (unsigned int) 0;
380 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
381 : : {
382 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w1, _w1_high);
383 : 0 : s1 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
384 : 0 : b |= (1 << (1 ));
385 : : }
386 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 2))
387 : : {
388 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w2, _w2_high);
389 : 0 : s2 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
390 : 0 : b |= (1 << (2 ));
391 : : }
392 : 0 : switch (b)
393 : : {
394 : 0 : case (unsigned int) 0:
395 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high);
396 : 0 : break;
397 : :
398 : 0 : case (unsigned int) ((1 << (1))):
399 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high);
400 : 0 : break;
401 : :
402 : 0 : case (unsigned int) ((1 << (2))):
403 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1));
404 : 0 : break;
405 : :
406 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2))):
407 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1));
408 : 0 : break;
409 : :
410 : :
411 : 0 : default:
412 : 0 : M2RTS_HALT (-1);
413 : : __builtin_unreachable ();
414 : 0 : break;
415 : : }
416 : 0 : if ((DynamicStrings_KillString (SFIO_WriteS (file, s))) == NULL)
417 : : {} /* empty. */
418 : 0 : }
419 : :
420 : :
421 : : /*
422 : : fprintf0 - writes out an array to, file, after the escape sequences
423 : : have been translated.
424 : : */
425 : :
426 : 0 : extern "C" void M2Printf_fprintf3 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high)
427 : : {
428 : 0 : NameKey_Name n;
429 : 0 : DynamicStrings_String s;
430 : 0 : DynamicStrings_String s1;
431 : 0 : DynamicStrings_String s2;
432 : 0 : DynamicStrings_String s3;
433 : 0 : unsigned int b;
434 : 0 : char a[_a_high+1];
435 : 0 : unsigned char w1[_w1_high+1];
436 : 0 : unsigned char w2[_w2_high+1];
437 : 0 : unsigned char w3[_w3_high+1];
438 : :
439 : : /* make a local copy of each unbounded array. */
440 : 0 : memcpy (a, a_, _a_high+1);
441 : 0 : memcpy (w1, w1_, _w1_high+1);
442 : 0 : memcpy (w2, w2_, _w2_high+1);
443 : 0 : memcpy (w3, w3_, _w3_high+1);
444 : :
445 : 0 : b = (unsigned int) 0;
446 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
447 : : {
448 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w1, _w1_high);
449 : 0 : s1 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
450 : 0 : b |= (1 << (1 ));
451 : : }
452 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 2))
453 : : {
454 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w2, _w2_high);
455 : 0 : s2 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
456 : 0 : b |= (1 << (2 ));
457 : : }
458 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 3))
459 : : {
460 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w3, _w3_high);
461 : 0 : s3 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
462 : 0 : b |= (1 << (3 ));
463 : : }
464 : 0 : switch (b)
465 : : {
466 : 0 : case (unsigned int) 0:
467 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
468 : 0 : break;
469 : :
470 : 0 : case (unsigned int) ((1 << (1))):
471 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
472 : 0 : break;
473 : :
474 : 0 : case (unsigned int) ((1 << (2))):
475 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high);
476 : 0 : break;
477 : :
478 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2))):
479 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high);
480 : 0 : break;
481 : :
482 : 0 : case (unsigned int) ((1 << (3))):
483 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1));
484 : 0 : break;
485 : :
486 : 0 : case (unsigned int) ((1 << (1)) | (1 << (3))):
487 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1));
488 : 0 : break;
489 : :
490 : 0 : case (unsigned int) ((1 << (2)) | (1 << (3))):
491 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1));
492 : 0 : break;
493 : :
494 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2)) | (1 << (3))):
495 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1));
496 : 0 : break;
497 : :
498 : :
499 : 0 : default:
500 : 0 : M2RTS_HALT (-1);
501 : : __builtin_unreachable ();
502 : 0 : break;
503 : : }
504 : 0 : if ((DynamicStrings_KillString (SFIO_WriteS (file, s))) == NULL)
505 : : {} /* empty. */
506 : 0 : }
507 : :
508 : :
509 : : /*
510 : : fprintf0 - writes out an array to, file, after the escape sequences
511 : : have been translated.
512 : : */
513 : :
514 : 0 : extern "C" void M2Printf_fprintf4 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high)
515 : : {
516 : 0 : NameKey_Name n;
517 : 0 : DynamicStrings_String s;
518 : 0 : DynamicStrings_String s1;
519 : 0 : DynamicStrings_String s2;
520 : 0 : DynamicStrings_String s3;
521 : 0 : DynamicStrings_String s4;
522 : 0 : unsigned int b;
523 : 0 : char a[_a_high+1];
524 : 0 : unsigned char w1[_w1_high+1];
525 : 0 : unsigned char w2[_w2_high+1];
526 : 0 : unsigned char w3[_w3_high+1];
527 : 0 : unsigned char w4[_w4_high+1];
528 : :
529 : : /* make a local copy of each unbounded array. */
530 : 0 : memcpy (a, a_, _a_high+1);
531 : 0 : memcpy (w1, w1_, _w1_high+1);
532 : 0 : memcpy (w2, w2_, _w2_high+1);
533 : 0 : memcpy (w3, w3_, _w3_high+1);
534 : 0 : memcpy (w4, w4_, _w4_high+1);
535 : :
536 : 0 : b = (unsigned int) 0;
537 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
538 : : {
539 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w1, _w1_high);
540 : 0 : s1 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
541 : 0 : b |= (1 << (1 ));
542 : : }
543 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 2))
544 : : {
545 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w2, _w2_high);
546 : 0 : s2 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
547 : 0 : b |= (1 << (2 ));
548 : : }
549 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 3))
550 : : {
551 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w3, _w3_high);
552 : 0 : s3 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
553 : 0 : b |= (1 << (3 ));
554 : : }
555 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 4))
556 : : {
557 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w4, _w4_high);
558 : 0 : s4 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
559 : 0 : b |= (1 << (4 ));
560 : : }
561 : 0 : switch (b)
562 : : {
563 : 0 : case (unsigned int) 0:
564 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high, (const unsigned char *) w4, _w4_high);
565 : 0 : break;
566 : :
567 : 0 : case (unsigned int) ((1 << (1))):
568 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high, (const unsigned char *) w4, _w4_high);
569 : 0 : break;
570 : :
571 : 0 : case (unsigned int) ((1 << (2))):
572 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high, (const unsigned char *) w4, _w4_high);
573 : 0 : break;
574 : :
575 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2))):
576 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high, (const unsigned char *) w4, _w4_high);
577 : 0 : break;
578 : :
579 : 0 : case (unsigned int) ((1 << (3))):
580 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) w4, _w4_high);
581 : 0 : break;
582 : :
583 : 0 : case (unsigned int) ((1 << (1)) | (1 << (3))):
584 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) w4, _w4_high);
585 : 0 : break;
586 : :
587 : 0 : case (unsigned int) ((1 << (2)) | (1 << (3))):
588 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) w4, _w4_high);
589 : 0 : break;
590 : :
591 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2)) | (1 << (3))):
592 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) w4, _w4_high);
593 : 0 : break;
594 : :
595 : 0 : case (unsigned int) ((1 << (4))):
596 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high, (const unsigned char *) &s4, (sizeof (s4)-1));
597 : 0 : break;
598 : :
599 : 0 : case (unsigned int) ((1 << (1)) | (1 << (4))):
600 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high, (const unsigned char *) &s4, (sizeof (s4)-1));
601 : 0 : break;
602 : :
603 : 0 : case (unsigned int) ((1 << (2)) | (1 << (4))):
604 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high, (const unsigned char *) &s4, (sizeof (s4)-1));
605 : 0 : break;
606 : :
607 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2)) | (1 << (4))):
608 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high, (const unsigned char *) &s4, (sizeof (s4)-1));
609 : 0 : break;
610 : :
611 : 0 : case (unsigned int) ((1 << (3)) | (1 << (4))):
612 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) &s4, (sizeof (s4)-1));
613 : 0 : break;
614 : :
615 : 0 : case (unsigned int) ((1 << (1)) | (1 << (3)) | (1 << (4))):
616 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) &s4, (sizeof (s4)-1));
617 : 0 : break;
618 : :
619 : 0 : case (unsigned int) ((1 << (2)) | (1 << (3)) | (1 << (4))):
620 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) &s4, (sizeof (s4)-1));
621 : 0 : break;
622 : :
623 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2)) | (1 << (3)) | (1 << (4))):
624 : 0 : s = FormatStrings_Sprintf4 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1), (const unsigned char *) &s4, (sizeof (s4)-1));
625 : 0 : break;
626 : :
627 : :
628 : 0 : default:
629 : 0 : M2RTS_HALT (-1);
630 : : __builtin_unreachable ();
631 : 0 : break;
632 : : }
633 : 0 : if ((DynamicStrings_KillString (SFIO_WriteS (file, s))) == NULL)
634 : : {} /* empty. */
635 : 0 : }
636 : :
637 : 0 : extern "C" void _M2_M2Printf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
638 : : {
639 : 0 : }
640 : :
641 : 0 : extern "C" void _M2_M2Printf_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
642 : : {
643 : 0 : }
|