150 #if defined(LIBC_SCCS) && !defined(lint)
151 static char *sccsid =
"from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";
167 #define VFPRINTF vfiprintf
168 #define _VFPRINTF_R _vfiprintf_r
170 #define VFPRINTF vfprintf
171 #define _VFPRINTF_R _vfprintf_r
172 #ifndef NO_FLOATING_POINT
173 #define FLOATING_POINT
178 #if defined WANT_PRINTF_LONG_LONG && defined __GNUC__
183 #if defined WANT_IO_POS_ARGS
195 #include <sys/lock.h>
203 #ifndef _SMALL_PRINTF
210 #include "vfieeefp.h"
216 #if defined WANT_IO_LONG_DBL && (LDBL_MANT_DIG > DBL_MANT_DIG)
221 #ifndef _SMALL_PRINTF
229 register struct __suio *uio;
233 if (uio->uio_resid == 0) {
237 err = __sfvwrite(fp, uio);
249 __sbprintf(fp, fmt, ap)
256 unsigned char buf[BUFSIZ];
259 fake._flags = fp->_flags & ~__SNBF;
260 fake._file = fp->_file;
261 fake._cookie = fp->_cookie;
262 fake._write = fp->_write;
265 fake._bf._base = fake._p = buf;
266 fake._bf._size = fake._w =
sizeof(buf);
268 #ifndef __SINGLE_THREAD__
269 __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock);
273 ret = VFPRINTF(&fake, fmt, ap);
274 if (ret >= 0 && fflush(&fake))
276 if (fake._flags & __SERR)
277 fp->_flags |= __SERR;
279 #ifndef __SINGLE_THREAD__
280 __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock);
288 #ifdef FLOATING_POINT
293 #if ((MAXEXP+MAXFRACT+1) > MB_LEN_MAX)
294 # define BUF (MAXEXP+MAXFRACT+1)
296 # define BUF MB_LEN_MAX
302 static char *cvt _PARAMS((
struct _reent *,
double,
int,
int,
char *,
int *,
int,
int *));
304 static char *cvt _PARAMS((
struct _reent *, _LONG_DOUBLE,
int,
int,
char *,
int *,
int,
int *));
305 extern int _ldcheck _PARAMS((_LONG_DOUBLE *));
308 static int exponent _PARAMS((
char *,
int,
int));
317 #define quad_t long long
318 #define u_quad_t unsigned long long
321 #define u_quad_t unsigned long
324 typedef quad_t * quad_ptr_t;
325 typedef void * void_ptr_t;
326 typedef char * char_ptr_t;
327 typedef long * long_ptr_t;
328 typedef int * int_ptr_t;
329 typedef short * short_ptr_t;
332 #define MAX_POS_ARGS 32
342 _LONG_DOUBLE val__LONG_DOUBLE;
343 int_ptr_t val_int_ptr_t;
344 short_ptr_t val_short_ptr_t;
345 long_ptr_t val_long_ptr_t;
346 char_ptr_t val_char_ptr_t;
347 quad_ptr_t val_quad_ptr_t;
348 void_ptr_t val_void_ptr_t;
350 u_quad_t val_u_quad_t;
354 static union arg_val *get_arg (
struct _reent *data,
int n,
char *fmt,
355 va_list *ap,
int *numargs,
union arg_val *args,
356 int *arg_type,
char **last_fmt);
362 #define to_digit(c) ((c) - '0')
363 #define is_digit(c) ((unsigned)to_digit(c) <= 9)
364 #define to_char(n) ((n) + '0')
370 #define HEXPREFIX 0x002
371 #define LADJUST 0x004
372 #define LONGDBL 0x008
373 #define LONGINT 0x010
375 #define QUADINT 0x020
379 #define QUADINT LONGINT
381 #define SHORTINT 0x040
382 #define ZEROPAD 0x080
386 int _EXFUN (_VFPRINTF_R, (
struct _reent *, FILE *, _CONST
char *, va_list));
389 _DEFUN (VFPRINTF, (fp, fmt0, ap),
391 _CONST
char *fmt0 _AND
396 #ifndef _SMALL_PRINTF
399 result = _VFPRINTF_R (_REENT, fp, fmt0, ap);
407 _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
408 struct _reent *data _AND
410 _CONST
char *fmt0 _AND
417 register struct __siov *iovp;
425 union arg_val args[MAX_POS_ARGS];
426 int arg_type[MAX_POS_ARGS];
434 #ifdef FLOATING_POINT
436 char *decimal_point =
".";
438 char *decimal_point = localeconv()->decimal_point;
442 union {
int i;
double d; } _double_ = {0};
443 #define _fpvalue (_double_.d)
445 union {
int i; _LONG_DOUBLE ld; } _long_double_ = {0};
446 #define _fpvalue (_long_double_.ld)
455 enum { OCT, DEC, HEX } base;
460 #ifndef _SMALL_PRINTF
463 struct __siov iov[NIOV];
464 char *malloc_buf =
NULL;
466 char malloc_buf [MAXBUFLOC];
483 static _CONST
char blanks[PADSIZE] =
484 {
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' '};
485 static _CONST
char zeroes[PADSIZE] =
486 {
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0'};
489 memset (&state,
'\0',
sizeof (state));
492 #ifndef _SMALL_PRINTF
496 #define PRINT(ptr, len,f) { \
497 iovp->iov_base = (ptr); \
498 iovp->iov_len = (len); \
499 uio.uio_resid += (len); \
501 if (++uio.uio_iovcnt >= NIOV) { \
502 if (__sprint(fp, &uio)) \
507 #define PAD(howmany, with,f) { \
508 if ((n = (howmany)) > 0) { \
509 while (n > PADSIZE) { \
510 PRINT(with, PADSIZE,f); \
517 if (uio.uio_resid && __sprint(fp, &uio)) \
519 uio.uio_iovcnt = 0; \
524 void _SMALL_PRINTF_puts(
const char *ptr,
int len, FILE *f);
525 #define PRINT(ptr, len, f) {_SMALL_PRINTF_puts(ptr,len,f);}
526 #define PAD(howmany, with, f) { \
527 if ((n = (howmany)) > 0) { \
528 while (n > PADSIZE) { \
529 PRINT(with, PADSIZE,f); \
535 #define FLUSH() { ; }
541 #define GET_ARG(n, ap, type) \
544 ? args[n].val_##type \
545 : get_arg (data, n, fmt_anchor, &ap, &numargs, args, arg_type, &saved_fmt)->val_##type \
546 : arg_index++ < numargs \
547 ? args[n].val_##type \
548 : numargs < MAX_POS_ARGS \
549 ? args[numargs++].val_##type = va_arg(ap, type) \
553 #define GET_ARG(n, ap, type) (va_arg(ap, type))
562 (flags&QUADINT ? GET_ARG(N, ap, quad_t) : \
563 flags&LONGINT ? GET_ARG(N, ap, long) : \
564 flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \
565 (long)GET_ARG(N, ap, int))
567 (flags&QUADINT ? GET_ARG(N, ap, u_quad_t) : \
568 flags&LONGINT ? GET_ARG(N, ap, u_long) : \
569 flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \
570 (u_long)GET_ARG(N, ap, u_int))
573 (flags&LONGINT ? GET_ARG(N, ap, long) : \
574 flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \
575 (long)GET_ARG(N, ap, int))
577 (flags&LONGINT ? GET_ARG(N, ap, u_long) : \
578 flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \
579 (u_long)GET_ARG(N, ap, u_int))
582 #ifndef _SMALL_PRINTF
588 if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
590 return (__sbprintf(fp, fmt0, ap));
592 uio.uio_iov = iovp = iov;
614 while ((n = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
620 while (*fmt !=
'\0' && *fmt !=
'%')
623 if ((m = fmt - cp) != 0) {
648 reswitch:
switch (ch) {
665 old_is_pos_arg = is_pos_arg;
667 if (is_digit(*fmt)) {
673 n = 10 * n + to_digit(ch);
675 }
while (is_digit(ch));
678 if (n <= MAX_POS_ARGS) {
698 width = GET_ARG(n, ap,
int);
700 is_pos_arg = old_is_pos_arg;
713 if ((ch = *fmt++) ==
'*') {
717 old_is_pos_arg = is_pos_arg;
719 if (is_digit(*fmt)) {
725 n = 10 * n + to_digit(ch);
727 }
while (is_digit(ch));
730 if (n <= MAX_POS_ARGS) {
743 prec = GET_ARG(n, ap,
int);
745 is_pos_arg = old_is_pos_arg;
752 while (is_digit(ch)) {
753 n = 10 * n + to_digit(ch);
756 prec = n < 0 ? -1 : n;
766 case '1':
case '2':
case '3':
case '4':
767 case '5':
case '6':
case '7':
case '8':
case '9':
770 n = 10 * n + to_digit(ch);
772 }
while (is_digit(ch));
775 if (n <= MAX_POS_ARGS) {
786 #ifdef FLOATING_POINT
808 if (ch ==
'C' || (flags & LONGINT)) {
811 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
812 if ((size = (
int)_wcrtomb_r(data, cp,
813 (
wchar_t)GET_ARG(N, ap, wint_t),
818 *cp = GET_ARG(N, ap,
int);
830 if ((quad_t)_uquad < 0)
832 if ((
long) _uquad < 0)
841 #ifdef FLOATING_POINT
849 }
else if ((ch ==
'g' || ch ==
'G') && prec == 0) {
854 if (flags & LONGDBL) {
855 _fpvalue = (double) GET_ARG(N, ap, _LONG_DOUBLE);
857 _fpvalue = GET_ARG(N, ap,
double);
861 if (isinf(_fpvalue)) {
868 if (isnan(_fpvalue)) {
876 if (flags & LONGDBL) {
877 _fpvalue = GET_ARG(N, ap, _LONG_DOUBLE);
879 _fpvalue = (_LONG_DOUBLE)GET_ARG(N, ap,
double);
883 tmp = _ldcheck (&_fpvalue);
900 cp = cvt(data, _fpvalue, prec, flags, &softsign,
903 if (ch ==
'g' || ch ==
'G') {
904 if (expt <= -4 || expt > prec)
905 ch = (ch ==
'g') ?
'e' :
'E';
911 expsize = exponent(expstr, expt, ch);
912 size = expsize + ndig;
913 if (ndig > 1 || flags & ALT)
915 }
else if (ch ==
'f') {
918 if (prec || flags & ALT)
921 size = (prec || flags & ALT)
924 }
else if (expt >= ndig) {
929 size = ndig + (expt > 0 ?
939 *GET_ARG(N, ap, quad_ptr_t) = ret;
943 *GET_ARG(N, ap, long_ptr_t) = ret;
944 else if (flags & SHORTINT)
945 *GET_ARG(N, ap, short_ptr_t) = ret;
947 *GET_ARG(N, ap, int_ptr_t) = ret;
965 _uquad = (u_long)(
unsigned _POINTER_INT)GET_ARG(N, ap, void_ptr_t);
967 xdigs =
"0123456789abcdef";
974 if ((cp = GET_ARG(N, ap, char_ptr_t)) ==
NULL) {
978 else if (ch ==
'S' || (flags & LONGINT)) {
982 wcp = (_CONST
wchar_t *)cp;
984 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
993 if ((n = (
int)_wcrtomb_r(data,
994 buf, wcp[m], &ps)) == -1)
1005 if ((size = (
int)_wcsrtombs_r(data,
1006 NULL, &wcp, 0, &ps)) == -1)
1008 wcp = (_CONST
wchar_t *)cp;
1014 #ifndef _SMALL_PRINTF
1016 (
char *)_malloc_r(data, size + 1)) ==
NULL)
1021 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
1022 if (_wcsrtombs_r(data, malloc_buf, &wcp, size, &ps) != size)
1027 else if (prec >= 0) {
1033 char *p = memchr(cp, 0, prec);
1053 xdigs =
"0123456789ABCDEF";
1056 xdigs =
"0123456789abcdef";
1057 hex: _uquad = UARG();
1060 if (flags & ALT && _uquad != 0)
1064 nosign: sign =
'\0';
1070 number:
if ((dprec = prec) >= 0)
1079 if (_uquad != 0 || prec != 0) {
1088 *--cp = to_char(_uquad & 7);
1092 if (flags & ALT && *cp !=
'0')
1098 while (_uquad >= 10) {
1099 *--cp = to_char(_uquad % 10);
1102 *--cp = to_char(_uquad);
1107 *--cp = xdigs[_uquad & 15];
1113 cp =
"bug in vfprintf: bad base";
1127 else if (base == OCT && (flags & ALT))
1130 size = buf + BUF - cp;
1158 realsz = dprec > size ? dprec : size;
1161 else if (flags & HEXPREFIX)
1165 if ((flags & (LADJUST|ZEROPAD)) == 0)
1166 PAD(width - realsz, blanks, fp);
1170 PRINT(&sign, 1, fp);
1171 }
else if (flags & HEXPREFIX) {
1178 if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
1179 PAD(width - realsz, zeroes, fp);
1182 PAD(dprec - size, zeroes, fp);
1185 #ifdef FLOATING_POINT
1186 if ((flags & FPT) == 0) {
1187 PRINT(cp, size, fp);
1190 if (_fpvalue == 0) {
1193 if (expt < ndig || (flags & ALT) != 0) {
1194 PRINT(decimal_point, 1, fp);
1195 PAD(ndig - 1, zeroes, fp);
1197 }
else if (expt <= 0) {
1200 PRINT(decimal_point, 1, fp);
1201 PAD(-expt, zeroes, fp);
1202 PRINT(cp, ndig, fp);
1204 }
else if (expt >= ndig) {
1205 PRINT(cp, ndig, fp);
1206 PAD(expt - ndig, zeroes, fp);
1210 PRINT(cp, expt, fp);
1213 PRINT(cp, ndig-expt, fp);
1216 if (ndig > 1 || flags & ALT) {
1221 PRINT(cp, ndig-1, fp);
1224 PAD(ndig - 1, zeroes, fp);
1227 PRINT(expstr, expsize, fp);
1231 PRINT(cp, size, fp);
1234 if (flags & LADJUST)
1235 PAD(width - realsz, blanks, fp);
1238 ret += width > realsz ? width : realsz;
1242 #ifndef _SMALL_PRINTF
1243 if (malloc_buf !=
NULL) {
1253 #ifndef _SMALL_PRINTF
1254 if (malloc_buf !=
NULL)
1256 return (__sferror(fp) ? EOF : ret);
1263 #ifdef FLOATING_POINT
1266 extern char *_dtoa_r _PARAMS((
struct _reent *,
double,
int,
1267 int,
int *,
int *,
char **));
1269 extern char *_ldtoa_r _PARAMS((
struct _reent *, _LONG_DOUBLE,
int,
1270 int,
int *,
int *,
char **));
1272 #define word0(x) ldword0(x)
1276 cvt(data, value, ndigits, flags, sign, decpt, ch, length)
1277 struct _reent *data;
1283 int ndigits,
flags, *decpt, ch, *length;
1287 char *digits, *bp, *rve;
1289 union double_union tmp;
1291 struct ldieee *ldptr;
1301 if (ch ==
'e' || ch ==
'E') {
1310 if (word0(tmp) & Sign_bit) {
1316 digits = _dtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve);
1318 ldptr = (
struct ldieee *)&value;
1325 digits = _ldtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve);
1328 if ((ch !=
'g' && ch !=
'G') || flags & ALT) {
1329 bp = digits + ndigits;
1331 if (*digits ==
'0' && value)
1332 *decpt = -ndigits + 1;
1340 *length = rve - digits;
1345 exponent(p0, exp, fmtch)
1349 register char *p, *t;
1363 *--t = to_char(exp % 10);
1364 }
while ((exp /= 10) > 9);
1365 *--t = to_char(exp);
1366 for (; t < expbuf + 40; *p++ = *t++);
1370 *p++ = to_char(exp);
1377 #ifndef _NO_POS_ARGS
1451 const static CH_CLASS chclass[256] = {
1452 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1453 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1454 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1455 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1456 FLAG, OTHER, OTHER, FLAG, DOLLAR, OTHER, OTHER, OTHER,
1457 OTHER, OTHER, STAR, FLAG, OTHER, FLAG, DOT, OTHER,
1458 ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT,
1459 DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1460 OTHER, OTHER, OTHER, SPEC, SPEC, SPEC, OTHER, SPEC,
1461 OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
1462 OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, SPEC,
1463 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1464 OTHER, OTHER, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC,
1465 MODFR, SPEC, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
1466 SPEC, MODFR, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER,
1467 SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1468 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1469 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1470 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1471 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1472 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1473 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1474 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1475 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1476 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1477 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1478 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1479 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1480 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1481 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1482 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1483 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1486 const static STATE state_table[MAX_STATE][MAX_CH_CLASS] = {
1488 { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
1489 { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
1490 { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE },
1491 { DONE, DONE, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE },
1492 { DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE },
1493 { SDOT, PREC, DONE, SMOD, DONE, DONE, VARP, DONE, DONE },
1494 { DONE, VWDIG, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE },
1495 { DONE, VPDIG, DONE, SMOD, DONE, DONE, DONE, DONE, DONE },
1496 { DONE, DONE, DONE, SMOD, DONE, DONE, DONE, DONE, DONE },
1497 { DONE, DONE, WIDTH, DONE, DONE, DONE, DONE, DONE, DONE },
1498 { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE },
1501 const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = {
1503 { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1504 { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1505 { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1506 { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1507 { NOOP, NOOP, NOOP, NOOP, GETARG, NOOP, NOOP, NOOP, NOOP },
1508 { NOOP, SKIPNUM, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1509 { NOOP, NUMBER, NOOP, GETPW, GETPWB, GETPW, NOOP, NOOP, NOOP },
1510 { NOOP, NUMBER, NOOP, GETPW, GETPWB, NOOP, NOOP, NOOP, NOOP },
1511 { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1512 { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP },
1513 { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP },
1517 static union arg_val *
1518 get_arg (
struct _reent *data,
int n,
char *fmt, va_list *ap,
1519 int *numargs_p,
union arg_val *args,
1520 int *arg_type,
char **last_fmt)
1525 int numargs = *numargs_p;
1527 STATE state, next_state;
1530 int max_pos_arg = n;
1531 enum types { INT, LONG_INT, SHORT_INT, QUAD_INT, CHAR, CHAR_PTR, DOUBLE, LONG_DOUBLE, WIDE_CHAR };
1539 if (*last_fmt !=
NULL)
1543 memset (&wc_state,
'\0',
sizeof (wc_state));
1548 while (*fmt && n >= numargs)
1551 while ((nbytes = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
1561 while (*fmt !=
'\0' && *fmt !=
'%')
1576 while (state != DONE)
1579 chtype = chclass[ch];
1580 next_state = state_table[state][chtype];
1581 action = action_table[state][chtype];
1612 numargs &= (MAX_POS_ARGS - 1);
1622 if (flags & LONGINT)
1623 spec_type = LONG_INT;
1624 else if (flags & SHORTINT)
1625 spec_type = SHORT_INT;
1626 #ifndef _NO_LONGLONG
1627 else if (flags & QUADINT)
1628 spec_type = QUAD_INT;
1636 spec_type = LONG_INT;
1644 if (flags & LONGDBL)
1645 spec_type = LONG_DOUBLE;
1653 spec_type = CHAR_PTR;
1659 spec_type = WIDE_CHAR;
1666 arg_type[pos] = spec_type;
1672 args[numargs++].val_long = va_arg(*ap,
long);
1675 args[numargs++].val_quad_t = va_arg(*ap, quad_t);
1678 args[numargs++].val_wint_t = va_arg(*ap, wint_t);
1683 args[numargs++].val_int = va_arg(*ap,
int);
1686 args[numargs++].val_char_ptr_t = va_arg(*ap,
char *);
1689 args[numargs++].val_double = va_arg(*ap,
double);
1692 args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE);
1699 if (arg_type[0] == -1)
1700 memset (arg_type, 0,
sizeof(
int) * MAX_POS_ARGS);
1702 max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos);
1705 if (arg_type[0] == -1)
1706 memset (arg_type, 0,
sizeof(
int) * MAX_POS_ARGS);
1708 arg_type[number] = INT;
1709 max_pos_arg = (max_pos_arg > number ? max_pos_arg : number);
1715 args[numargs++].val_int = va_arg(*ap,
int);
1718 number = (ch -
'0');
1719 while ((ch = *fmt) !=
'\0' && is_digit(ch))
1721 number = number * 10 + (ch -
'0');
1726 while ((ch = *fmt) !=
'\0' && is_digit(ch))
1739 last_arg = max_pos_arg;
1743 while (numargs <= last_arg)
1745 switch (arg_type[numargs])
1748 args[numargs++].val_long = va_arg(*ap,
long);
1751 args[numargs++].val_quad_t = va_arg(*ap, quad_t);
1754 args[numargs++].val_char_ptr_t = va_arg(*ap,
char *);
1757 args[numargs++].val_double = va_arg(*ap,
double);
1760 args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE);
1763 args[numargs++].val_wint_t = va_arg(*ap, wint_t);
1769 args[numargs++].val_int = va_arg(*ap,
int);
1776 *numargs_p = numargs;