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