150 #if defined(LIBC_SCCS) && !defined(lint)
151 static char *sccsid =
"from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";
161 #define VFPRINTF vfiprintf
162 #define _VFPRINTF_R _vfiprintf_r
164 #define VFPRINTF vfprintf
165 #define _VFPRINTF_R _vfprintf_r
166 #ifndef NO_FLOATING_POINT
167 #define FLOATING_POINT
172 #if defined WANT_PRINTF_LONG_LONG && defined __GNUC__
177 #if defined WANT_IO_POS_ARGS
189 #include <sys/lock.h>
197 #ifndef _SMALL_PRINTF
204 #include "vfieeefp.h"
210 #if defined WANT_IO_LONG_DBL && (LDBL_MANT_DIG > DBL_MANT_DIG)
215 #ifndef _SMALL_PRINTF
223 register struct __suio *uio;
227 if (uio->uio_resid == 0) {
231 err = __sfvwrite(fp, uio);
243 __sbprintf(fp, fmt, ap)
250 unsigned char buf[BUFSIZ];
253 fake._flags = fp->_flags & ~__SNBF;
254 fake._file = fp->_file;
255 fake._cookie = fp->_cookie;
256 fake._write = fp->_write;
259 fake._bf._base = fake._p = buf;
260 fake._bf._size = fake._w =
sizeof(buf);
262 #ifndef __SINGLE_THREAD__
263 __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock);
267 ret = VFPRINTF(&fake, fmt, ap);
268 if (ret >= 0 && fflush(&fake))
270 if (fake._flags & __SERR)
271 fp->_flags |= __SERR;
273 #ifndef __SINGLE_THREAD__
274 __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock);
282 #ifdef FLOATING_POINT
287 #if ((MAXEXP+MAXFRACT+1) > MB_LEN_MAX)
288 # define BUF (MAXEXP+MAXFRACT+1)
290 # define BUF MB_LEN_MAX
296 static char *cvt _PARAMS((
struct _reent *,
double,
int,
int,
char *,
int *,
int,
int *));
298 static char *cvt _PARAMS((
struct _reent *, _LONG_DOUBLE,
int,
int,
char *,
int *,
int,
int *));
299 extern int _ldcheck _PARAMS((_LONG_DOUBLE *));
302 static int exponent _PARAMS((
char *,
int,
int));
311 #define quad_t long long
312 #define u_quad_t unsigned long long
315 #define u_quad_t unsigned long
318 typedef quad_t * quad_ptr_t;
319 typedef void * void_ptr_t;
320 typedef char * char_ptr_t;
321 typedef long * long_ptr_t;
322 typedef int * int_ptr_t;
323 typedef short * short_ptr_t;
326 #define MAX_POS_ARGS 32
336 _LONG_DOUBLE val__LONG_DOUBLE;
337 int_ptr_t val_int_ptr_t;
338 short_ptr_t val_short_ptr_t;
339 long_ptr_t val_long_ptr_t;
340 char_ptr_t val_char_ptr_t;
341 quad_ptr_t val_quad_ptr_t;
342 void_ptr_t val_void_ptr_t;
344 u_quad_t val_u_quad_t;
348 static union arg_val *get_arg (
struct _reent *data,
int n,
char *fmt,
349 va_list *ap,
int *numargs,
union arg_val *args,
350 int *arg_type,
char **last_fmt);
356 #define to_digit(c) ((c) - '0')
357 #define is_digit(c) ((unsigned)to_digit(c) <= 9)
358 #define to_char(n) ((n) + '0')
364 #define HEXPREFIX 0x002
365 #define LADJUST 0x004
366 #define LONGDBL 0x008
367 #define LONGINT 0x010
369 #define QUADINT 0x020
373 #define QUADINT LONGINT
375 #define SHORTINT 0x040
376 #define ZEROPAD 0x080
380 int _EXFUN (_VFPRINTF_R, (
struct _reent *, FILE *, _CONST
char *, va_list));
383 _DEFUN (VFPRINTF, (fp, fmt0, ap),
385 _CONST
char *fmt0 _AND
390 #ifndef _SMALL_PRINTF
393 result = _VFPRINTF_R (_REENT, fp, fmt0, ap);
401 _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
402 struct _reent *data _AND
404 _CONST
char *fmt0 _AND
411 register struct __siov *iovp;
419 union arg_val args[MAX_POS_ARGS];
420 int arg_type[MAX_POS_ARGS];
428 #ifdef FLOATING_POINT
430 char *decimal_point =
".";
432 char *decimal_point = localeconv()->decimal_point;
436 union {
int i;
double d; } _double_ = {0};
437 #define _fpvalue (_double_.d)
439 union {
int i; _LONG_DOUBLE ld; } _long_double_ = {0};
440 #define _fpvalue (_long_double_.ld)
449 enum { OCT, DEC, HEX } base;
454 #ifndef _SMALL_PRINTF
457 struct __siov iov[NIOV];
458 char *malloc_buf =
NULL;
460 char malloc_buf [MAXBUFLOC];
477 static _CONST
char blanks[PADSIZE] =
478 {
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' '};
479 static _CONST
char zeroes[PADSIZE] =
480 {
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0'};
483 memset (&state,
'\0',
sizeof (state));
486 #ifndef _SMALL_PRINTF
490 #define PRINT(ptr, len,f) { \
491 iovp->iov_base = (ptr); \
492 iovp->iov_len = (len); \
493 uio.uio_resid += (len); \
495 if (++uio.uio_iovcnt >= NIOV) { \
496 if (__sprint(fp, &uio)) \
501 #define PAD(howmany, with,f) { \
502 if ((n = (howmany)) > 0) { \
503 while (n > PADSIZE) { \
504 PRINT(with, PADSIZE,f); \
511 if (uio.uio_resid && __sprint(fp, &uio)) \
513 uio.uio_iovcnt = 0; \
518 void _SMALL_PRINTF_puts(
const char *ptr,
int len, FILE *f);
519 #define PRINT(ptr, len, f) {_SMALL_PRINTF_puts(ptr,len,f);}
520 #define PAD(howmany, with, f) { \
521 if ((n = (howmany)) > 0) { \
522 while (n > PADSIZE) { \
523 PRINT(with, PADSIZE,f); \
529 #define FLUSH() { ; }
535 #define GET_ARG(n, ap, type) \
538 ? args[n].val_##type \
539 : get_arg (data, n, fmt_anchor, &ap, &numargs, args, arg_type, &saved_fmt)->val_##type \
540 : arg_index++ < numargs \
541 ? args[n].val_##type \
542 : numargs < MAX_POS_ARGS \
543 ? args[numargs++].val_##type = va_arg(ap, type) \
547 #define GET_ARG(n, ap, type) (va_arg(ap, type))
556 (flags&QUADINT ? GET_ARG(N, ap, quad_t) : \
557 flags&LONGINT ? GET_ARG(N, ap, long) : \
558 flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \
559 (long)GET_ARG(N, ap, int))
561 (flags&QUADINT ? GET_ARG(N, ap, u_quad_t) : \
562 flags&LONGINT ? GET_ARG(N, ap, u_long) : \
563 flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \
564 (u_long)GET_ARG(N, ap, u_int))
567 (flags&LONGINT ? GET_ARG(N, ap, long) : \
568 flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \
569 (long)GET_ARG(N, ap, int))
571 (flags&LONGINT ? GET_ARG(N, ap, u_long) : \
572 flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \
573 (u_long)GET_ARG(N, ap, u_int))
576 #ifndef _SMALL_PRINTF
582 if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
584 return (__sbprintf(fp, fmt0, ap));
586 uio.uio_iov = iovp = iov;
608 while ((n = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
614 while (*fmt !=
'\0' && *fmt !=
'%')
617 if ((m = fmt - cp) != 0) {
642 reswitch:
switch (ch) {
659 old_is_pos_arg = is_pos_arg;
661 if (is_digit(*fmt)) {
667 n = 10 * n + to_digit(ch);
669 }
while (is_digit(ch));
672 if (n <= MAX_POS_ARGS) {
692 width = GET_ARG(n, ap,
int);
694 is_pos_arg = old_is_pos_arg;
707 if ((ch = *fmt++) ==
'*') {
711 old_is_pos_arg = is_pos_arg;
713 if (is_digit(*fmt)) {
719 n = 10 * n + to_digit(ch);
721 }
while (is_digit(ch));
724 if (n <= MAX_POS_ARGS) {
737 prec = GET_ARG(n, ap,
int);
739 is_pos_arg = old_is_pos_arg;
746 while (is_digit(ch)) {
747 n = 10 * n + to_digit(ch);
750 prec = n < 0 ? -1 : n;
760 case '1':
case '2':
case '3':
case '4':
761 case '5':
case '6':
case '7':
case '8':
case '9':
764 n = 10 * n + to_digit(ch);
766 }
while (is_digit(ch));
769 if (n <= MAX_POS_ARGS) {
780 #ifdef FLOATING_POINT
802 if (ch ==
'C' || (flags & LONGINT)) {
805 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
806 if ((size = (
int)_wcrtomb_r(data, cp,
807 (
wchar_t)GET_ARG(N, ap, wint_t),
812 *cp = GET_ARG(N, ap,
int);
824 if ((quad_t)_uquad < 0)
826 if ((
long) _uquad < 0)
835 #ifdef FLOATING_POINT
843 }
else if ((ch ==
'g' || ch ==
'G') && prec == 0) {
848 if (flags & LONGDBL) {
849 _fpvalue = (double) GET_ARG(N, ap, _LONG_DOUBLE);
851 _fpvalue = GET_ARG(N, ap,
double);
855 if (isinf(_fpvalue)) {
862 if (isnan(_fpvalue)) {
870 if (flags & LONGDBL) {
871 _fpvalue = GET_ARG(N, ap, _LONG_DOUBLE);
873 _fpvalue = (_LONG_DOUBLE)GET_ARG(N, ap,
double);
877 tmp = _ldcheck (&_fpvalue);
894 cp = cvt(data, _fpvalue, prec, flags, &softsign,
897 if (ch ==
'g' || ch ==
'G') {
898 if (expt <= -4 || expt > prec)
899 ch = (ch ==
'g') ?
'e' :
'E';
905 expsize = exponent(expstr, expt, ch);
906 size = expsize + ndig;
907 if (ndig > 1 || flags & ALT)
909 }
else if (ch ==
'f') {
912 if (prec || flags & ALT)
915 size = (prec || flags & ALT)
918 }
else if (expt >= ndig) {
923 size = ndig + (expt > 0 ?
933 *GET_ARG(N, ap, quad_ptr_t) = ret;
937 *GET_ARG(N, ap, long_ptr_t) = ret;
938 else if (flags & SHORTINT)
939 *GET_ARG(N, ap, short_ptr_t) = ret;
941 *GET_ARG(N, ap, int_ptr_t) = ret;
959 _uquad = (u_long)(
unsigned _POINTER_INT)GET_ARG(N, ap, void_ptr_t);
961 xdigs =
"0123456789abcdef";
968 if ((cp = GET_ARG(N, ap, char_ptr_t)) ==
NULL) {
972 else if (ch ==
'S' || (flags & LONGINT)) {
976 wcp = (_CONST
wchar_t *)cp;
978 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
987 if ((n = (
int)_wcrtomb_r(data,
988 buf, wcp[m], &ps)) == -1)
999 if ((size = (
int)_wcsrtombs_r(data,
1000 NULL, &wcp, 0, &ps)) == -1)
1002 wcp = (_CONST
wchar_t *)cp;
1008 #ifndef _SMALL_PRINTF
1010 (
char *)_malloc_r(data, size + 1)) ==
NULL)
1015 memset((
void *)&ps,
'\0',
sizeof(mbstate_t));
1016 if (_wcsrtombs_r(data, malloc_buf, &wcp, size, &ps) != size)
1021 else if (prec >= 0) {
1027 char *p = memchr(cp, 0, prec);
1047 xdigs =
"0123456789ABCDEF";
1050 xdigs =
"0123456789abcdef";
1051 hex: _uquad = UARG();
1054 if (flags & ALT && _uquad != 0)
1058 nosign: sign =
'\0';
1064 number:
if ((dprec = prec) >= 0)
1073 if (_uquad != 0 || prec != 0) {
1082 *--cp = to_char(_uquad & 7);
1086 if (flags & ALT && *cp !=
'0')
1092 while (_uquad >= 10) {
1093 *--cp = to_char(_uquad % 10);
1096 *--cp = to_char(_uquad);
1101 *--cp = xdigs[_uquad & 15];
1107 cp =
"bug in vfprintf: bad base";
1121 else if (base == OCT && (flags & ALT))
1124 size = buf + BUF - cp;
1152 realsz = dprec > size ? dprec : size;
1155 else if (flags & HEXPREFIX)
1159 if ((flags & (LADJUST|ZEROPAD)) == 0)
1160 PAD(width - realsz, blanks, fp);
1164 PRINT(&sign, 1, fp);
1165 }
else if (flags & HEXPREFIX) {
1172 if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
1173 PAD(width - realsz, zeroes, fp);
1176 PAD(dprec - size, zeroes, fp);
1179 #ifdef FLOATING_POINT
1180 if ((flags & FPT) == 0) {
1181 PRINT(cp, size, fp);
1184 if (_fpvalue == 0) {
1187 if (expt < ndig || (flags & ALT) != 0) {
1188 PRINT(decimal_point, 1, fp);
1189 PAD(ndig - 1, zeroes, fp);
1191 }
else if (expt <= 0) {
1194 PRINT(decimal_point, 1, fp);
1195 PAD(-expt, zeroes, fp);
1196 PRINT(cp, ndig, fp);
1198 }
else if (expt >= ndig) {
1199 PRINT(cp, ndig, fp);
1200 PAD(expt - ndig, zeroes, fp);
1204 PRINT(cp, expt, fp);
1207 PRINT(cp, ndig-expt, fp);
1210 if (ndig > 1 || flags & ALT) {
1215 PRINT(cp, ndig-1, fp);
1218 PAD(ndig - 1, zeroes, fp);
1221 PRINT(expstr, expsize, fp);
1225 PRINT(cp, size, fp);
1228 if (flags & LADJUST)
1229 PAD(width - realsz, blanks, fp);
1232 ret += width > realsz ? width : realsz;
1236 #ifndef _SMALL_PRINTF
1237 if (malloc_buf !=
NULL) {
1247 #ifndef _SMALL_PRINTF
1248 if (malloc_buf !=
NULL)
1250 return (__sferror(fp) ? EOF : ret);
1257 #ifdef FLOATING_POINT
1260 extern char *_dtoa_r _PARAMS((
struct _reent *,
double,
int,
1261 int,
int *,
int *,
char **));
1263 extern char *_ldtoa_r _PARAMS((
struct _reent *, _LONG_DOUBLE,
int,
1264 int,
int *,
int *,
char **));
1266 #define word0(x) ldword0(x)
1270 cvt(data, value, ndigits, flags, sign, decpt, ch, length)
1271 struct _reent *data;
1277 int ndigits,
flags, *decpt, ch, *length;
1281 char *digits, *bp, *rve;
1283 union double_union tmp;
1285 struct ldieee *ldptr;
1295 if (ch ==
'e' || ch ==
'E') {
1304 if (word0(tmp) & Sign_bit) {
1310 digits = _dtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve);
1312 ldptr = (
struct ldieee *)&value;
1319 digits = _ldtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve);
1322 if ((ch !=
'g' && ch !=
'G') || flags & ALT) {
1323 bp = digits + ndigits;
1325 if (*digits ==
'0' && value)
1326 *decpt = -ndigits + 1;
1334 *length = rve - digits;
1339 exponent(p0, exp, fmtch)
1343 register char *p, *t;
1357 *--t = to_char(exp % 10);
1358 }
while ((exp /= 10) > 9);
1359 *--t = to_char(exp);
1360 for (; t < expbuf + 40; *p++ = *t++);
1364 *p++ = to_char(exp);
1371 #ifndef _NO_POS_ARGS
1445 const static CH_CLASS chclass[256] = {
1446 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1447 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1448 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1449 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1450 FLAG, OTHER, OTHER, FLAG, DOLLAR, OTHER, OTHER, OTHER,
1451 OTHER, OTHER, STAR, FLAG, OTHER, FLAG, DOT, OTHER,
1452 ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT,
1453 DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1454 OTHER, OTHER, OTHER, SPEC, SPEC, SPEC, OTHER, SPEC,
1455 OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
1456 OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, SPEC,
1457 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1458 OTHER, OTHER, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC,
1459 MODFR, SPEC, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
1460 SPEC, MODFR, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER,
1461 SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1462 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1463 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1464 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1465 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1466 OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
1467 OTHER, 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,
1480 const static STATE state_table[MAX_STATE][MAX_CH_CLASS] = {
1482 { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
1483 { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
1484 { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE },
1485 { DONE, DONE, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE },
1486 { DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE },
1487 { SDOT, PREC, DONE, SMOD, DONE, DONE, VARP, DONE, DONE },
1488 { DONE, VWDIG, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE },
1489 { DONE, VPDIG, DONE, SMOD, DONE, DONE, DONE, DONE, DONE },
1490 { DONE, DONE, DONE, SMOD, DONE, DONE, DONE, DONE, DONE },
1491 { DONE, DONE, WIDTH, DONE, DONE, DONE, DONE, DONE, DONE },
1492 { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE },
1495 const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = {
1497 { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1498 { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1499 { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1500 { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1501 { NOOP, NOOP, NOOP, NOOP, GETARG, NOOP, NOOP, NOOP, NOOP },
1502 { NOOP, SKIPNUM, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1503 { NOOP, NUMBER, NOOP, GETPW, GETPWB, GETPW, NOOP, NOOP, NOOP },
1504 { NOOP, NUMBER, NOOP, GETPW, GETPWB, NOOP, NOOP, NOOP, NOOP },
1505 { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
1506 { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP },
1507 { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP },
1511 static union arg_val *
1512 get_arg (
struct _reent *data,
int n,
char *fmt, va_list *ap,
1513 int *numargs_p,
union arg_val *args,
1514 int *arg_type,
char **last_fmt)
1519 int numargs = *numargs_p;
1521 STATE state, next_state;
1524 int max_pos_arg = n;
1525 enum types { INT, LONG_INT, SHORT_INT, QUAD_INT, CHAR, CHAR_PTR, DOUBLE, LONG_DOUBLE, WIDE_CHAR };
1533 if (*last_fmt !=
NULL)
1537 memset (&wc_state,
'\0',
sizeof (wc_state));
1542 while (*fmt && n >= numargs)
1545 while ((nbytes = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
1555 while (*fmt !=
'\0' && *fmt !=
'%')
1570 while (state != DONE)
1573 chtype = chclass[ch];
1574 next_state = state_table[state][chtype];
1575 action = action_table[state][chtype];
1606 numargs &= (MAX_POS_ARGS - 1);
1616 if (flags & LONGINT)
1617 spec_type = LONG_INT;
1618 else if (flags & SHORTINT)
1619 spec_type = SHORT_INT;
1620 #ifndef _NO_LONGLONG
1621 else if (flags & QUADINT)
1622 spec_type = QUAD_INT;
1630 spec_type = LONG_INT;
1638 if (flags & LONGDBL)
1639 spec_type = LONG_DOUBLE;
1647 spec_type = CHAR_PTR;
1653 spec_type = WIDE_CHAR;
1660 arg_type[pos] = spec_type;
1666 args[numargs++].val_long = va_arg(*ap,
long);
1669 args[numargs++].val_quad_t = va_arg(*ap, quad_t);
1672 args[numargs++].val_wint_t = va_arg(*ap, wint_t);
1677 args[numargs++].val_int = va_arg(*ap,
int);
1680 args[numargs++].val_char_ptr_t = va_arg(*ap,
char *);
1683 args[numargs++].val_double = va_arg(*ap,
double);
1686 args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE);
1693 if (arg_type[0] == -1)
1694 memset (arg_type, 0,
sizeof(
int) * MAX_POS_ARGS);
1696 max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos);
1699 if (arg_type[0] == -1)
1700 memset (arg_type, 0,
sizeof(
int) * MAX_POS_ARGS);
1702 arg_type[number] = INT;
1703 max_pos_arg = (max_pos_arg > number ? max_pos_arg : number);
1709 args[numargs++].val_int = va_arg(*ap,
int);
1712 number = (ch -
'0');
1713 while ((ch = *fmt) !=
'\0' && is_digit(ch))
1715 number = number * 10 + (ch -
'0');
1720 while ((ch = *fmt) !=
'\0' && is_digit(ch))
1733 last_arg = max_pos_arg;
1737 while (numargs <= last_arg)
1739 switch (arg_type[numargs])
1742 args[numargs++].val_long = va_arg(*ap,
long);
1745 args[numargs++].val_quad_t = va_arg(*ap, quad_t);
1748 args[numargs++].val_char_ptr_t = va_arg(*ap,
char *);
1751 args[numargs++].val_double = va_arg(*ap,
double);
1754 args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE);
1757 args[numargs++].val_wint_t = va_arg(*ap, wint_t);
1763 args[numargs++].val_int = va_arg(*ap,
int);
1770 *numargs_p = numargs;