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