Ruby  2.4.2p198(2017-09-14revision59899)
vsnprintf.c
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 1990, 1993
3  * The Regents of the University of California. All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Chris Torek.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 /*
34  * IMPORTANT NOTE:
35  * --------------
36  * From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
37  * paragraph 3 above is now null and void.
38  */
39 
40 /* SNPRINTF.C
41  * fjc 7-31-97 Modified by Mib Software to be a standalone snprintf.c module.
42  * http://www.mibsoftware.com
43  * Mib Software does not warrant this software any differently than the
44  * University of California, Berkeley as described above. All warranties
45  * are disclaimed. Use this software at your own risk.
46  *
47  * All code referencing FILE * functions was eliminated, since it could
48  * never be called. All header files and necessary files are collapsed
49  * into one file, internal functions are declared static. This should
50  * allow inclusion into libraries with less chance of namespace collisions.
51  *
52  * snprintf should be the only externally visible item.
53  *
54  * As of 7-31-97 FLOATING_POINT is NOT provided. The code is somewhat
55  * non-portable, so it is disabled.
56  */
57 
58 /* Define FLOATING_POINT to get floating point. */
59 /*
60 #define FLOATING_POINT
61 */
62 
63 #include <sys/types.h>
64 #define u_long unsigned long
65 #define u_short unsigned short
66 #define u_int unsigned int
67 
68 #if !defined(HAVE_STDARG_PROTOTYPES)
69 #if defined(__STDC__)
70 #define HAVE_STDARG_PROTOTYPES 1
71 #endif
72 #endif
73 
74 #undef __P
75 #if defined(HAVE_STDARG_PROTOTYPES)
76 # include <stdarg.h>
77 # if !defined(__P)
78 # define __P(x) x
79 # endif
80 #else
81 # define __P(x) ()
82 # if !defined(const)
83 # define const
84 # endif
85 # include <varargs.h>
86 #endif
87 #ifndef _BSD_VA_LIST_
88 #define _BSD_VA_LIST_ va_list
89 #endif
90 
91 #ifdef __STDC__
92 # include <limits.h>
93 #else
94 # ifndef LONG_MAX
95 # ifdef HAVE_LIMITS_H
96 # include <limits.h>
97 # else
98  /* assuming 32bit(2's complement) long */
99 # define LONG_MAX 2147483647
100 # endif
101 # endif
102 #endif
103 
104 #if defined(__hpux) && !defined(__GNUC__) && !defined(__STDC__)
105 #define const
106 #endif
107 
108 #if defined(sgi)
109 #undef __const
110 #define __const
111 #endif /* People who don't like const sys_error */
112 
113 #include <stddef.h>
114 #if defined(__hpux) && !defined(__GNUC__) || defined(__DECC)
115 #include <string.h>
116 #endif
117 
118 #if !defined(__CYGWIN32__) && defined(__hpux) && !defined(__GNUC__)
119 #include <stdlib.h>
120 #endif
121 
122 #ifndef NULL
123 #define NULL 0
124 #endif
125 
126 #if SIZEOF_LONG > SIZEOF_INT
127 # include <errno.h>
128 #endif
129 
130 /*
131  * NB: to fit things in six character monocase externals, the stdio
132  * code uses the prefix `__s' for stdio objects, typically followed
133  * by a three-character attempt at a mnemonic.
134  */
135 
136 /* stdio buffers */
137 struct __sbuf {
138  unsigned char *_base;
139  size_t _size;
140 };
141 
142 
143 /*
144  * stdio state variables.
145  *
146  * The following always hold:
147  *
148  * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
149  * _lbfsize is -_bf._size, else _lbfsize is 0
150  * if _flags&__SRD, _w is 0
151  * if _flags&__SWR, _r is 0
152  *
153  * This ensures that the getc and putc macros (or inline functions) never
154  * try to write or read from a file that is in `read' or `write' mode.
155  * (Moreover, they can, and do, automatically switch from read mode to
156  * write mode, and back, on "r+" and "w+" files.)
157  *
158  * _lbfsize is used only to make the inline line-buffered output stream
159  * code as compact as possible.
160  *
161  * _ub, _up, and _ur are used when ungetc() pushes back more characters
162  * than fit in the current _bf, or when ungetc() pushes back a character
163  * that does not match the previous one in _bf. When this happens,
164  * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
165  * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
166  *
167  * NB: see WARNING above before changing the layout of this structure!
168  */
169 typedef struct __sFILE {
170  unsigned char *_p; /* current position in (some) buffer */
171 #if 0
172  size_t _r; /* read space left for getc() */
173 #endif
174  size_t _w; /* write space left for putc() */
175  short _flags; /* flags, below; this FILE is free if 0 */
176  short _file; /* fileno, if Unix descriptor, else -1 */
177  struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
178  size_t _lbfsize; /* 0 or -_bf._size, for inline putc */
179  int (*vwrite)(/* struct __sFILE*, struct __suio * */);
180  const char *(*vextra)(/* struct __sFILE*, size_t, void*, long*, int */);
181 } FILE;
182 
183 
184 #define __SLBF 0x0001 /* line buffered */
185 #define __SNBF 0x0002 /* unbuffered */
186 #define __SRD 0x0004 /* OK to read */
187 #define __SWR 0x0008 /* OK to write */
188  /* RD and WR are never simultaneously asserted */
189 #define __SRW 0x0010 /* open for reading & writing */
190 #define __SEOF 0x0020 /* found EOF */
191 #define __SERR 0x0040 /* found error */
192 #define __SMBF 0x0080 /* _buf is from malloc */
193 #define __SAPP 0x0100 /* fdopen()ed in append mode */
194 #define __SSTR 0x0200 /* this is an sprintf/snprintf string */
195 #define __SOPT 0x0400 /* do fseek() optimisation */
196 #define __SNPT 0x0800 /* do not do fseek() optimisation */
197 #define __SOFF 0x1000 /* set iff _offset is in fact correct */
198 #define __SMOD 0x2000 /* true => fgetln modified _p text */
199 
200 
201 #define EOF (-1)
202 
203 
204 #define BSD__sfeof(p) (((p)->_flags & __SEOF) != 0)
205 #define BSD__sferror(p) (((p)->_flags & __SERR) != 0)
206 #define BSD__sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
207 #define BSD__sfileno(p) ((p)->_file)
208 
209 #undef feof
210 #undef ferror
211 #undef clearerr
212 #define feof(p) BSD__sfeof(p)
213 #define ferror(p) BSD__sferror(p)
214 #define clearerr(p) BSD__sclearerr(p)
215 
216 #ifndef _ANSI_SOURCE
217 #define fileno(p) BSD__sfileno(p)
218 #endif
219 
220 
221 /*
222  * I/O descriptors for __sfvwrite().
223  */
224 struct __siov {
225  const void *iov_base;
226  size_t iov_len;
227 };
228 struct __suio {
229  struct __siov *uio_iov;
231  size_t uio_resid;
232 };
233 
234 /*
235  * Write some memory regions. Return zero on success, EOF on error.
236  *
237  * This routine is large and unsightly, but most of the ugliness due
238  * to the three different kinds of output buffering is handled here.
239  */
240 static int
241 BSD__sfvwrite(register FILE *fp, register struct __suio *uio)
242 {
243  register size_t len;
244  register const char *p;
245  register struct __siov *iov;
246  register size_t w;
247 
248  if ((len = uio->uio_resid) == 0)
249  return (0);
250 #ifndef __hpux
251 #define MIN(a, b) ((a) < (b) ? (a) : (b))
252 #endif
253 #define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
254 
255  iov = uio->uio_iov;
256  p = iov->iov_base;
257  len = iov->iov_len;
258  iov++;
259 #define GETIOV(extra_work) \
260  while (len == 0) { \
261  extra_work; \
262  p = iov->iov_base; \
263  len = iov->iov_len; \
264  iov++; \
265  }
266  if (fp->_flags & __SNBF) {
267  /* fjc 7-31-97 Will never happen. We are working with
268  strings only
269  */
270  } else if ((fp->_flags & __SLBF) == 0) {
271  /*
272  * Fully buffered: fill partially full buffer, if any,
273  * and then flush. If there is no partial buffer, write
274  * one _bf._size byte chunk directly (without copying).
275  *
276  * String output is a special case: write as many bytes
277  * as fit, but pretend we wrote everything. This makes
278  * snprintf() return the number of bytes needed, rather
279  * than the number used, and avoids its write function
280  * (so that the write function can be invalid).
281  */
282  do {
283  GETIOV(;);
284  w = fp->_w;
285  if (fp->_flags & __SSTR) {
286  if (len < w)
287  w = len;
288  COPY(w); /* copy MIN(fp->_w,len), */
289  fp->_w -= w;
290  fp->_p += w;
291  w = len; /* but pretend copied all */
292  } else {
293  /* fjc 7-31-97 Will never happen. We are working with
294  strings only
295  */
296  }
297  p += w;
298  len -= w;
299  } while ((uio->uio_resid -= w) != 0);
300  } else {
301  /* fjc 7-31-97 Will never happen. We are working with
302  strings only
303  */
304  }
305  return (0);
306 }
307 
308 /*
309  * Actual printf innards.
310  *
311  * This code is large and complicated...
312  */
313 
314 /*
315  * Flush out all the vectors defined by the given uio,
316  * then reset it so that it can be reused.
317  */
318 static int
319 BSD__sprint(FILE *fp, register struct __suio *uio)
320 {
321  register int err;
322 
323  if (uio->uio_resid == 0) {
324  uio->uio_iovcnt = 0;
325  return (0);
326  }
327  err = (*fp->vwrite)(fp, uio);
328  uio->uio_resid = 0;
329  uio->uio_iovcnt = 0;
330  return (err);
331 }
332 
333 
334 /*
335  * Helper function for `fprintf to unbuffered unix file': creates a
336  * temporary buffer. We only work on write-only files; this avoids
337  * worries about ungetc buffers and so forth.
338  */
339 static int
340 BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
341 {
342 /* We don't support files. */
343  return 0;
344 }
345 
346 
347 /*
348  * Macros for converting digits to letters and vice versa
349  */
350 #define to_digit(c) ((c) - '0')
351 #define is_digit(c) ((unsigned)to_digit(c) <= 9)
352 #define to_char(n) (char)((n) + '0')
353 
354 #ifdef _HAVE_SANE_QUAD_
355 /*
356  * Convert an unsigned long long to ASCII for printf purposes, returning
357  * a pointer to the first character of the string representation.
358  * Octal numbers can be forced to have a leading zero; hex numbers
359  * use the given digits.
360  */
361 static char *
362 BSD__uqtoa(register u_quad_t val, char *endp, int base, int octzero, const char *xdigs)
363 {
364  register char *cp = endp;
365  register quad_t sval;
366 
367  /*
368  * Handle the three cases separately, in the hope of getting
369  * better/faster code.
370  */
371  switch (base) {
372  case 10:
373  if (val < 10) { /* many numbers are 1 digit */
374  *--cp = to_char(val);
375  return (cp);
376  }
377  /*
378  * On many machines, unsigned arithmetic is harder than
379  * signed arithmetic, so we do at most one unsigned mod and
380  * divide; this is sufficient to reduce the range of
381  * the incoming value to where signed arithmetic works.
382  */
383  if (val > LLONG_MAX) {
384  *--cp = to_char(val % 10);
385  sval = val / 10;
386  } else
387  sval = val;
388  do {
389  *--cp = to_char(sval % 10);
390  sval /= 10;
391  } while (sval != 0);
392  break;
393 
394  case 8:
395  do {
396  *--cp = to_char(val & 7);
397  val >>= 3;
398  } while (val);
399  if (octzero && *cp != '0')
400  *--cp = '0';
401  break;
402 
403  case 16:
404  do {
405  *--cp = xdigs[val & 15];
406  val >>= 4;
407  } while (val);
408  break;
409 
410  default: /* oops */
411  /*
412  abort();
413  */
414  break; /* fjc 7-31-97. Don't reference abort() here */
415  }
416  return (cp);
417 }
418 #endif /* _HAVE_SANE_QUAD_ */
419 
420 /*
421  * Convert an unsigned long to ASCII for printf purposes, returning
422  * a pointer to the first character of the string representation.
423  * Octal numbers can be forced to have a leading zero; hex numbers
424  * use the given digits.
425  */
426 static char *
427 BSD__ultoa(register u_long val, char *endp, int base, int octzero, const char *xdigs)
428 {
429  register char *cp = endp;
430  register long sval;
431 
432  /*
433  * Handle the three cases separately, in the hope of getting
434  * better/faster code.
435  */
436  switch (base) {
437  case 10:
438  if (val < 10) { /* many numbers are 1 digit */
439  *--cp = to_char(val);
440  return (cp);
441  }
442  /*
443  * On many machines, unsigned arithmetic is harder than
444  * signed arithmetic, so we do at most one unsigned mod and
445  * divide; this is sufficient to reduce the range of
446  * the incoming value to where signed arithmetic works.
447  */
448  if (val > LONG_MAX) {
449  *--cp = to_char(val % 10);
450  sval = val / 10;
451  } else
452  sval = val;
453  do {
454  *--cp = to_char(sval % 10);
455  sval /= 10;
456  } while (sval != 0);
457  break;
458 
459  case 8:
460  do {
461  *--cp = to_char(val & 7);
462  val >>= 3;
463  } while (val);
464  if (octzero && *cp != '0')
465  *--cp = '0';
466  break;
467 
468  case 16:
469  do {
470  *--cp = xdigs[val & 15];
471  val >>= 4;
472  } while (val);
473  break;
474 
475  default: /* oops */
476  /*
477  abort();
478  */
479  break; /* fjc 7-31-97. Don't reference abort() here */
480  }
481  return (cp);
482 }
483 
484 #ifdef FLOATING_POINT
485 #include <math.h>
486 #include <float.h>
487 /* #include "floatio.h" */
488 
489 #ifndef MAXEXP
490 # if DBL_MAX_10_EXP > -DBL_MIN_10_EXP
491 # define MAXEXP (DBL_MAX_10_EXP)
492 # else
493 # define MAXEXP (-DBL_MIN_10_EXP)
494 # endif
495 #endif
496 
497 #ifndef MAXFRACT
498 # define MAXFRACT (MAXEXP*10/3)
499 #endif
500 
501 #define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
502 #define DEFPREC 6
503 
504 static char *cvt(double, int, int, char *, int *, int, int *, char *);
505 static int exponent(char *, int, int);
506 
507 #else /* no FLOATING_POINT */
508 
509 #define BUF 68
510 
511 #endif /* FLOATING_POINT */
512 
513 #ifndef lower_hexdigits
514 # define lower_hexdigits "0123456789abcdef"
515 #endif
516 #ifndef upper_hexdigits
517 # define upper_hexdigits "0123456789ABCDEF"
518 #endif
519 
520 /*
521  * Flags used during conversion.
522  */
523 #define ALT 0x001 /* alternate form */
524 #define HEXPREFIX 0x002 /* add 0x or 0X prefix */
525 #define LADJUST 0x004 /* left adjustment */
526 #define LONGDBL 0x008 /* long double; unimplemented */
527 #define LONGINT 0x010 /* long integer */
528 
529 #ifdef _HAVE_SANE_QUAD_
530 #define QUADINT 0x020 /* quad integer */
531 #endif /* _HAVE_SANE_QUAD_ */
532 
533 #define SHORTINT 0x040 /* short integer */
534 #define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
535 #define FPT 0x100 /* Floating point number */
536 static ssize_t
537 BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
538 {
539 #ifdef PRI_EXTRA_MARK
541 #endif
542  register const char *fmt; /* format string */
543  register int ch; /* character from fmt */
544  register int n; /* handy integer (short term usage) */
545  register const char *cp;/* handy char pointer (short term usage) */
546  register struct __siov *iovp;/* for PRINT macro */
547  register int flags; /* flags as above */
548  ssize_t ret; /* return value accumulator */
549  int width; /* width from format (%8d), or 0 */
550  int prec; /* precision from format (%.3d), or -1 */
551  char sign; /* sign prefix (' ', '+', '-', or \0) */
552 #ifdef FLOATING_POINT
553  char softsign; /* temporary negative sign for floats */
554  double _double = 0; /* double precision arguments %[eEfgG] */
555  int expt; /* integer value of exponent */
556  int expsize = 0; /* character count for expstr */
557  int ndig = 0; /* actual number of digits returned by cvt */
558  int fprec = 0; /* floating point precision */
559  char expstr[7]; /* buffer for exponent string */
560 #endif
561  u_long MAYBE_UNUSED(ulval); /* integer arguments %[diouxX] */
562 #ifdef _HAVE_SANE_QUAD_
563  u_quad_t MAYBE_UNUSED(uqval); /* %q integers */
564 #endif /* _HAVE_SANE_QUAD_ */
565  int base; /* base for [diouxX] conversion */
566  int dprec; /* a copy of prec if [diouxX], 0 otherwise */
567  long fieldsz; /* field size expanded by sign, etc */
568  long realsz; /* field size expanded by dprec */
569  int size; /* size of converted field or string */
570  const char *xdigs = 0; /* digits for [xX] conversion */
571 #define NIOV 8
572  struct __suio uio; /* output information: summary */
573  struct __siov iov[NIOV];/* ... and individual io vectors */
574  char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
575  char ox[4]; /* space for 0x hex-prefix, hexadecimal's 1. */
576  char *const ebuf = buf + sizeof(buf);
577 #if SIZEOF_LONG > SIZEOF_INT
578  long ln;
579 #endif
580 
581  /*
582  * Choose PADSIZE to trade efficiency vs. size. If larger printf
583  * fields occur frequently, increase PADSIZE and make the initializers
584  * below longer.
585  */
586 #define PADSIZE 16 /* pad chunk size */
587  static const char blanks[PADSIZE] =
588  {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
589  static const char zeroes[PADSIZE] =
590  {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
591 
592  /*
593  * BEWARE, these `goto error' on error, and PAD uses `n'.
594  */
595 #define PRINT(ptr, len) { \
596  iovp->iov_base = (ptr); \
597  iovp->iov_len = (len); \
598  uio.uio_resid += (len); \
599  iovp++; \
600  if (++uio.uio_iovcnt >= NIOV) { \
601  if (BSD__sprint(fp, &uio)) \
602  goto error; \
603  iovp = iov; \
604  } \
605 }
606 #define PAD(howmany, with) { \
607  if ((n = (howmany)) > 0) { \
608  while (n > PADSIZE) { \
609  PRINT((with), PADSIZE); \
610  n -= PADSIZE; \
611  } \
612  PRINT((with), n); \
613  } \
614 }
615 #if SIZEOF_LONG > SIZEOF_INT
616  /* abandon if too larger padding */
617 #define PAD_L(howmany, with) { \
618  ln = (howmany); \
619  if ((long)((int)ln) != ln) { \
620  errno = ENOMEM; \
621  goto error; \
622  } \
623  if (ln > 0) PAD((int)ln, (with)); \
624 }
625 #else
626 #define PAD_L(howmany, with) PAD((howmany), (with))
627 #endif
628 #define FLUSH() { \
629  if (uio.uio_resid && BSD__sprint(fp, &uio)) \
630  goto error; \
631  uio.uio_iovcnt = 0; \
632  iovp = iov; \
633 }
634 
635  /*
636  * To extend shorts properly, we need both signed and unsigned
637  * argument extraction methods.
638  */
639 #define SARG() \
640  (flags&LONGINT ? va_arg(ap, long) : \
641  flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
642  (long)va_arg(ap, int))
643 #define UARG() \
644  (flags&LONGINT ? va_arg(ap, u_long) : \
645  flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \
646  (u_long)va_arg(ap, u_int))
647 
648  /* optimize fprintf(stderr) (and other unbuffered Unix files) */
649  if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
650  fp->_file >= 0)
651  return (BSD__sbprintf(fp, fmt0, ap));
652 
653  fmt = fmt0;
654  uio.uio_iov = iovp = iov;
655  uio.uio_resid = 0;
656  uio.uio_iovcnt = 0;
657  ret = 0;
658  xdigs = 0;
659 
660  /*
661  * Scan the format for conversions (`%' character).
662  */
663  for (;;) {
664  size_t nc;
665  for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
666  /* void */;
667  if ((nc = fmt - cp) != 0) {
668  PRINT(cp, nc);
669  ret += nc;
670  }
671  if (ch == '\0')
672  goto done;
673  fmt++; /* skip over '%' */
674 
675  flags = 0;
676  dprec = 0;
677  width = 0;
678  prec = -1;
679  sign = '\0';
680 
681 rflag: ch = *fmt++;
682 reswitch: switch (ch) {
683  case ' ':
684  /*
685  * ``If the space and + flags both appear, the space
686  * flag will be ignored.''
687  * -- ANSI X3J11
688  */
689  if (!sign)
690  sign = ' ';
691  goto rflag;
692  case '#':
693  flags |= ALT;
694  goto rflag;
695  case '*':
696  /*
697  * ``A negative field width argument is taken as a
698  * - flag followed by a positive field width.''
699  * -- ANSI X3J11
700  * They don't exclude field widths read from args.
701  */
702  if ((width = va_arg(ap, int)) >= 0)
703  goto rflag;
704  width = -width;
705  /* FALLTHROUGH */
706  case '-':
707  flags |= LADJUST;
708  goto rflag;
709  case '+':
710  sign = '+';
711  goto rflag;
712  case '.':
713  if ((ch = *fmt++) == '*') {
714  n = va_arg(ap, int);
715  prec = n < 0 ? -1 : n;
716  goto rflag;
717  }
718  n = 0;
719  while (is_digit(ch)) {
720  n = 10 * n + to_digit(ch);
721  ch = *fmt++;
722  }
723  prec = n < 0 ? -1 : n;
724  goto reswitch;
725  case '0':
726  /*
727  * ``Note that 0 is taken as a flag, not as the
728  * beginning of a field width.''
729  * -- ANSI X3J11
730  */
731  flags |= ZEROPAD;
732  goto rflag;
733  case '1': case '2': case '3': case '4':
734  case '5': case '6': case '7': case '8': case '9':
735  n = 0;
736  do {
737  n = 10 * n + to_digit(ch);
738  ch = *fmt++;
739  } while (is_digit(ch));
740  width = n;
741  goto reswitch;
742 #ifdef FLOATING_POINT
743  case 'L':
744  flags |= LONGDBL;
745  goto rflag;
746 #endif
747  case 'h':
748  flags |= SHORTINT;
749  goto rflag;
750 #if SIZEOF_PTRDIFF_T == SIZEOF_LONG
751  case 't':
752 #endif
753 #if SIZEOF_SIZE_T == SIZEOF_LONG
754  case 'z':
755 #endif
756  case 'l':
757 #ifdef _HAVE_SANE_QUAD_
758  if (*fmt == 'l') {
759  fmt++;
760  flags |= QUADINT;
761  } else {
762  flags |= LONGINT;
763  }
764 #else
765  flags |= LONGINT;
766 #endif
767  goto rflag;
768 #ifdef _HAVE_SANE_QUAD_
769 #if SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
770  case 't':
771 #endif
772 #if SIZEOF_SIZE_T == SIZEOF_LONG_LONG
773  case 'z':
774 #endif
775  case 'q':
776  flags |= QUADINT;
777  goto rflag;
778 #endif /* _HAVE_SANE_QUAD_ */
779 #ifdef _WIN32
780  case 'I':
781  if (*fmt == '3' && *(fmt + 1) == '2') {
782  fmt += 2;
783  flags |= LONGINT;
784  }
785 #ifdef _HAVE_SANE_QUAD_
786  else if (*fmt == '6' && *(fmt + 1) == '4') {
787  fmt += 2;
788  flags |= QUADINT;
789  }
790 #endif
791  else
792 #if defined(_HAVE_SANE_QUAD_) && SIZEOF_SIZE_T == SIZEOF_LONG_LONG
793  flags |= QUADINT;
794 #else
795  flags |= LONGINT;
796 #endif
797  goto rflag;
798 #endif
799  case 'c':
800  cp = buf;
801  *buf = (char)va_arg(ap, int);
802  size = 1;
803  sign = '\0';
804  break;
805  case 'i':
806 #ifdef _HAVE_SANE_QUAD_
807 # define INTPTR_MASK (QUADINT|LONGINT|SHORTINT)
808 #else
809 # define INTPTR_MASK (LONGINT|SHORTINT)
810 #endif
811 #if defined _HAVE_SANE_QUAD_ && SIZEOF_VOIDP == SIZEOF_LONG_LONG
812 # define INTPTR_FLAG QUADINT
813 #elif SIZEOF_VOIDP == SIZEOF_LONG
814 # define INTPTR_FLAG LONGINT
815 #else
816 # define INTPTR_FLAG 0
817 #endif
818 #ifdef PRI_EXTRA_MARK
819 # define IS_PRI_EXTRA_MARK(s) \
820  (PRI_EXTRA_MARK_LEN < 1 || \
821  (*(s) == PRI_EXTRA_MARK[0] && \
822  (PRI_EXTRA_MARK_LEN == 1 || \
823  strncmp((s)+1, PRI_EXTRA_MARK+1, \
824  PRI_EXTRA_MARK_LEN-1) == 0)))
825 #else
826 # define PRI_EXTRA_MARK_LEN 0
827 # define IS_PRI_EXTRA_MARK(s) 1
828 #endif
829  if (fp->vextra && (flags & INTPTR_MASK) == INTPTR_FLAG &&
830  IS_PRI_EXTRA_MARK(fmt)) {
831  fmt += PRI_EXTRA_MARK_LEN;
832  FLUSH();
833 #if defined _HAVE_SANE_QUAD_ && SIZEOF_VOIDP == SIZEOF_LONG_LONG
834  uqval = va_arg(ap, u_quad_t);
835  cp = (*fp->vextra)(fp, sizeof(uqval), &uqval, &fieldsz, sign);
836 #else
837  ulval = va_arg(ap, u_long);
838  cp = (*fp->vextra)(fp, sizeof(ulval), &ulval, &fieldsz, sign);
839 #endif
840  sign = '\0';
841  if (!cp) goto error;
842  if (prec < 0) goto long_len;
843  size = fieldsz < prec ? (int)fieldsz : prec;
844  break;
845  }
846  goto decimal;
847  case 'D':
848  flags |= LONGINT;
849  /*FALLTHROUGH*/
850  case 'd':
851  decimal:
852 #ifdef _HAVE_SANE_QUAD_
853  if (flags & QUADINT) {
854  uqval = va_arg(ap, quad_t);
855  if ((quad_t)uqval < 0) {
856  uqval = -(quad_t)uqval;
857  sign = '-';
858  }
859  } else
860 #endif /* _HAVE_SANE_QUAD_ */
861  {
862  ulval = SARG();
863  if ((long)ulval < 0) {
864  ulval = (u_long)(-(long)ulval);
865  sign = '-';
866  }
867  }
868  base = 10;
869  goto number;
870 #ifdef FLOATING_POINT
871  case 'a':
872  case 'A':
873  if (prec > 0) {
874  flags |= ALT;
875  prec++;
876  fprec = prec;
877  }
878  goto fp_begin;
879  case 'e': /* anomalous precision */
880  case 'E':
881  if (prec != 0)
882  flags |= ALT;
883  prec = (prec == -1) ?
884  DEFPREC + 1 : (fprec = prec + 1);
885  /* FALLTHROUGH */
886  goto fp_begin;
887  case 'f': /* always print trailing zeroes */
888  if (prec != 0)
889  flags |= ALT;
890  case 'g':
891  case 'G':
892  if (prec == -1)
893  prec = DEFPREC;
894  else
895  fprec = prec;
896 fp_begin: _double = va_arg(ap, double);
897  /* do this before tricky precision changes */
898  if (isinf(_double)) {
899  if (_double < 0)
900  sign = '-';
901  cp = "Inf";
902  size = 3;
903  break;
904  }
905  if (isnan(_double)) {
906  cp = "NaN";
907  size = 3;
908  break;
909  }
910  flags |= FPT;
911  cp = cvt(_double, (prec < MAXFRACT ? prec : MAXFRACT), flags, &softsign,
912  &expt, ch, &ndig, buf);
913  if (ch == 'g' || ch == 'G') {
914  if (expt <= -4 || (expt > prec && expt > 1))
915  ch = (ch == 'g') ? 'e' : 'E';
916  else
917  ch = 'g';
918  }
919  if (ch == 'a' || ch == 'A') {
920  flags |= HEXPREFIX;
921  --expt;
922  expsize = exponent(expstr, expt, ch + 'p' - 'a');
923  ch += 'x' - 'a';
924  size = expsize + ndig;
925  if (ndig > 1 || flags & ALT)
926  ++size; /* floating point */
927  }
928  else if (ch <= 'e') { /* 'e' or 'E' fmt */
929  --expt;
930  expsize = exponent(expstr, expt, ch);
931  size = expsize + ndig;
932  if (ndig > 1 || flags & ALT)
933  ++fprec, ++size;
934  } else if (ch == 'f') { /* f fmt */
935  if (expt > 0) {
936  size = expt;
937  if (prec || flags & ALT)
938  size += prec + 1;
939  } else if (!prec) { /* "0" */
940  size = 1;
941  if (flags & ALT)
942  size += 1;
943  } else /* "0.X" */
944  size = prec + 2;
945  } else if (expt >= ndig) { /* fixed g fmt */
946  size = expt;
947  if (flags & ALT)
948  ++size;
949  } else
950  size = ndig + (expt > 0 ?
951  1 : 2 - expt);
952 
953  if (softsign)
954  sign = '-';
955  break;
956 #endif /* FLOATING_POINT */
957  case 'n':
958 #ifdef _HAVE_SANE_QUAD_
959  if (flags & QUADINT)
960  *va_arg(ap, quad_t *) = ret;
961  else if (flags & LONGINT)
962 #else /* _HAVE_SANE_QUAD_ */
963  if (flags & LONGINT)
964 #endif /* _HAVE_SANE_QUAD_ */
965  *va_arg(ap, long *) = ret;
966  else if (flags & SHORTINT)
967  *va_arg(ap, short *) = (short)ret;
968  else
969  *va_arg(ap, int *) = (int)ret;
970  continue; /* no output */
971  case 'O':
972  flags |= LONGINT;
973  /*FALLTHROUGH*/
974  case 'o':
975 #ifdef _HAVE_SANE_QUAD_
976  if (flags & QUADINT)
977  uqval = va_arg(ap, u_quad_t);
978  else
979 #endif /* _HAVE_SANE_QUAD_ */
980  ulval = UARG();
981  base = 8;
982  goto nosign;
983  case 'p':
984  /*
985  * ``The argument shall be a pointer to void. The
986  * value of the pointer is converted to a sequence
987  * of printable characters, in an implementation-
988  * defined manner.''
989  * -- ANSI X3J11
990  */
991  prec = (int)(sizeof(void*)*CHAR_BIT/4);
992 #ifdef _HAVE_LLP64_
993  uqval = (u_quad_t)va_arg(ap, void *);
994  flags = (flags) | QUADINT | HEXPREFIX;
995 #else
996  ulval = (u_long)va_arg(ap, void *);
997 #ifdef _HAVE_SANE_QUAD_
998  flags = (flags & ~QUADINT) | HEXPREFIX;
999 #else /* _HAVE_SANE_QUAD_ */
1000  flags = (flags) | HEXPREFIX;
1001 #endif /* _HAVE_SANE_QUAD_ */
1002 #endif
1003  base = 16;
1004  xdigs = lower_hexdigits;
1005  ch = 'x';
1006  goto nosign;
1007  case 's':
1008  if ((cp = va_arg(ap, char *)) == NULL)
1009  cp = "(null)";
1010  if (prec >= 0) {
1011  /*
1012  * can't use strlen; can only look for the
1013  * NUL in the first `prec' characters, and
1014  * strlen() will go further.
1015  */
1016  const char *p = (char *)memchr(cp, 0, prec);
1017 
1018  if (p != NULL && (p - cp) < prec)
1019  size = (int)(p - cp);
1020  else
1021  size = prec;
1022  }
1023  else {
1024  fieldsz = strlen(cp);
1025  goto long_len;
1026  }
1027  sign = '\0';
1028  break;
1029  case 'U':
1030  flags |= LONGINT;
1031  /*FALLTHROUGH*/
1032  case 'u':
1033 #ifdef _HAVE_SANE_QUAD_
1034  if (flags & QUADINT)
1035  uqval = va_arg(ap, u_quad_t);
1036  else
1037 #endif /* _HAVE_SANE_QUAD_ */
1038  ulval = UARG();
1039  base = 10;
1040  goto nosign;
1041  case 'X':
1042  xdigs = upper_hexdigits;
1043  goto hex;
1044  case 'x':
1045  xdigs = lower_hexdigits;
1046 hex:
1047 #ifdef _HAVE_SANE_QUAD_
1048  if (flags & QUADINT)
1049  uqval = va_arg(ap, u_quad_t);
1050  else
1051 #endif /* _HAVE_SANE_QUAD_ */
1052  ulval = UARG();
1053  base = 16;
1054  /* leading 0x/X only if non-zero */
1055  if (flags & ALT &&
1056 #ifdef _HAVE_SANE_QUAD_
1057  (flags & QUADINT ? uqval != 0 : ulval != 0)
1058 #else /* _HAVE_SANE_QUAD_ */
1059  ulval != 0
1060 #endif /* _HAVE_SANE_QUAD_ */
1061  )
1062  flags |= HEXPREFIX;
1063 
1064  /* unsigned conversions */
1065 nosign: sign = '\0';
1066  /*
1067  * ``... diouXx conversions ... if a precision is
1068  * specified, the 0 flag will be ignored.''
1069  * -- ANSI X3J11
1070  */
1071 number: if ((dprec = prec) >= 0)
1072  flags &= ~ZEROPAD;
1073 
1074  /*
1075  * ``The result of converting a zero value with an
1076  * explicit precision of zero is no characters.''
1077  * -- ANSI X3J11
1078  */
1079  cp = ebuf;
1080 #ifdef _HAVE_SANE_QUAD_
1081  if (flags & QUADINT) {
1082  if (uqval != 0 || prec != 0)
1083  cp = BSD__uqtoa(uqval, ebuf, base,
1084  flags & ALT, xdigs);
1085  } else
1086 #else /* _HAVE_SANE_QUAD_ */
1087 #endif /* _HAVE_SANE_QUAD_ */
1088  {
1089  if (ulval != 0 || prec != 0)
1090  cp = BSD__ultoa(ulval, ebuf, base,
1091  flags & ALT, xdigs);
1092  }
1093  size = (int)(ebuf - cp);
1094  break;
1095  default: /* "%?" prints ?, unless ? is NUL */
1096  if (ch == '\0')
1097  goto done;
1098  /* pretend it was %c with argument ch */
1099  cp = buf;
1100  *buf = ch;
1101  size = 1;
1102  sign = '\0';
1103  break;
1104  }
1105 
1106  /*
1107  * All reasonable formats wind up here. At this point, `cp'
1108  * points to a string which (if not flags&LADJUST) should be
1109  * padded out to `width' places. If flags&ZEROPAD, it should
1110  * first be prefixed by any sign or other prefix; otherwise,
1111  * it should be blank padded before the prefix is emitted.
1112  * After any left-hand padding and prefixing, emit zeroes
1113  * required by a decimal [diouxX] precision, then print the
1114  * string proper, then emit zeroes required by any leftover
1115  * floating precision; finally, if LADJUST, pad with blanks.
1116  *
1117  * Compute actual size, so we know how much to pad.
1118  * fieldsz excludes decimal prec; realsz includes it.
1119  */
1120  fieldsz = size;
1121 long_len:
1122  realsz = dprec > fieldsz ? dprec : fieldsz;
1123  if (sign)
1124  realsz++;
1125  if (flags & HEXPREFIX)
1126  realsz += 2;
1127 
1128  /* right-adjusting blank padding */
1129  if ((flags & (LADJUST|ZEROPAD)) == 0)
1130  PAD_L(width - realsz, blanks);
1131 
1132  /* prefix */
1133  if (sign) {
1134  PRINT(&sign, 1);
1135  }
1136  if (flags & HEXPREFIX) {
1137  ox[0] = '0';
1138  ox[1] = ch;
1139  PRINT(ox, 2);
1140  }
1141 
1142  /* right-adjusting zero padding */
1143  if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
1144  PAD_L(width - realsz, zeroes);
1145 
1146  /* leading zeroes from decimal precision */
1147  PAD_L(dprec - fieldsz, zeroes);
1148 
1149  /* the string or number proper */
1150 #ifdef FLOATING_POINT
1151  if ((flags & FPT) == 0) {
1152  PRINT(cp, fieldsz);
1153  } else { /* glue together f_p fragments */
1154  if (flags & HEXPREFIX) {
1155  if (ndig > 1 || flags & ALT) {
1156  ox[2] = *cp++;
1157  ox[3] = '.';
1158  PRINT(ox+2, 2);
1159  if (ndig > 0) PRINT(cp, ndig-1);
1160  } else /* XpYYY */
1161  PRINT(cp, 1);
1162  PAD(fprec-ndig, zeroes);
1163  PRINT(expstr, expsize);
1164  }
1165  else if (ch >= 'f') { /* 'f' or 'g' */
1166  if (_double == 0) {
1167  /* kludge for __dtoa irregularity */
1168  if (ndig <= 1 &&
1169  (flags & ALT) == 0) {
1170  PRINT("0", 1);
1171  } else {
1172  PRINT("0.", 2);
1173  PAD((ndig >= fprec ? ndig - 1 : fprec - (ch != 'f')),
1174  zeroes);
1175  }
1176  } else if (expt == 0 && ndig == 0 && (flags & ALT) == 0) {
1177  PRINT("0", 1);
1178  } else if (expt <= 0) {
1179  PRINT("0.", 2);
1180  PAD(-expt, zeroes);
1181  PRINT(cp, ndig);
1182  if (flags & ALT)
1183  PAD(fprec - ndig + (ch == 'f' ? expt : 0), zeroes);
1184  } else if (expt >= ndig) {
1185  PRINT(cp, ndig);
1186  PAD(expt - ndig, zeroes);
1187  if (flags & ALT)
1188  PRINT(".", 1);
1189  } else {
1190  PRINT(cp, expt);
1191  cp += expt;
1192  PRINT(".", 1);
1193  PRINT(cp, ndig-expt);
1194  if (flags & ALT)
1195  PAD(fprec - ndig + (ch == 'f' ? expt : 0), zeroes);
1196  }
1197  } else { /* 'e' or 'E' */
1198  if (ndig > 1 || flags & ALT) {
1199  ox[0] = *cp++;
1200  ox[1] = '.';
1201  PRINT(ox, 2);
1202  if (_double /*|| flags & ALT == 0*/) {
1203  PRINT(cp, ndig-1);
1204  } else /* 0.[0..] */
1205  /* __dtoa irregularity */
1206  PAD(ndig - 1, zeroes);
1207  if (flags & ALT) PAD(fprec - ndig - 1, zeroes);
1208  } else /* XeYYY */
1209  PRINT(cp, 1);
1210  PRINT(expstr, expsize);
1211  }
1212  }
1213 #else
1214  PRINT(cp, fieldsz);
1215 #endif
1216  /* left-adjusting padding (always blank) */
1217  if (flags & LADJUST)
1218  PAD_L(width - realsz, blanks);
1219 
1220  /* finally, adjust ret */
1221  ret += width > realsz ? width : realsz;
1222 
1223  FLUSH(); /* copy out the I/O vectors */
1224  }
1225 done:
1226  FLUSH();
1227 error:
1228  return (BSD__sferror(fp) ? EOF : ret);
1229  /* NOTREACHED */
1230 }
1231 
1232 #ifdef FLOATING_POINT
1233 
1234 extern char *BSD__dtoa(double, int, int, int *, int *, char **);
1235 extern char *BSD__hdtoa(double, const char *, int, int *, int *, char **);
1236 
1237 static char *
1238 cvt(double value, int ndigits, int flags, char *sign, int *decpt, int ch, int *length, char *buf)
1239 {
1240  int mode, dsgn;
1241  char *digits, *bp, *rve;
1242 
1243  if (ch == 'f')
1244  mode = 3;
1245  else {
1246  mode = 2;
1247  }
1248  if (value < 0) {
1249  value = -value;
1250  *sign = '-';
1251  } else if (value == 0.0 && 1.0/value < 0) {
1252  *sign = '-';
1253  } else {
1254  *sign = '\000';
1255  }
1256  if (ch == 'a' || ch =='A') {
1257  digits = BSD__hdtoa(value,
1258  ch == 'a' ? lower_hexdigits : upper_hexdigits,
1259  ndigits, decpt, &dsgn, &rve);
1260  }
1261  else {
1262  digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
1263  }
1264  buf[0] = 0; /* rve - digits may be 0 */
1265  memcpy(buf, digits, rve - digits);
1266  xfree(digits);
1267  rve = buf + (rve - digits);
1268  digits = buf;
1269  if (flags & ALT) { /* Print trailing zeros */
1270  bp = digits + ndigits;
1271  if (ch == 'f') {
1272  if (*digits == '0' && value)
1273  *decpt = -ndigits + 1;
1274  bp += *decpt;
1275  }
1276  while (rve < bp)
1277  *rve++ = '0';
1278  }
1279  *length = (int)(rve - digits);
1280  return (digits);
1281 }
1282 
1283 static int
1284 exponent(char *p0, int exp, int fmtch)
1285 {
1286  register char *p, *t;
1287  char expbuf[2 + (MAXEXP < 1000 ? 3 : MAXEXP < 10000 ? 4 : 5)]; /* >= 2 + ceil(log10(MAXEXP)) */
1288 
1289  p = p0;
1290  *p++ = fmtch;
1291  if (exp < 0) {
1292  exp = -exp;
1293  *p++ = '-';
1294  }
1295  else
1296  *p++ = '+';
1297  t = expbuf + sizeof(expbuf);
1298  if (exp > 9) {
1299  do {
1300  *--t = to_char(exp % 10);
1301  } while ((exp /= 10) > 9);
1302  *--t = to_char(exp);
1303  for (; t < expbuf + sizeof(expbuf); *p++ = *t++);
1304  }
1305  else {
1306  if (fmtch & 15) *p++ = '0'; /* other than p or P */
1307  *p++ = to_char(exp);
1308  }
1309  return (int)(p - p0);
1310 }
1311 #endif /* FLOATING_POINT */
size_t strlen(const char *)
unsigned char * _base
Definition: vsnprintf.c:138
size_t _lbfsize
Definition: vsnprintf.c:178
#define __SSTR
Definition: vsnprintf.c:194
#define to_digit(c)
Definition: vsnprintf.c:350
#define BSD__hdtoa
Definition: sprintf.c:1257
#define HEXPREFIX
Definition: vsnprintf.c:524
#define IS_PRI_EXTRA_MARK(s)
short _file
Definition: vsnprintf.c:176
#define ZEROPAD
Definition: vsnprintf.c:534
#define LONGDBL
Definition: vsnprintf.c:526
#define upper_hexdigits
Definition: vsnprintf.c:517
const void * iov_base
Definition: vsnprintf.c:225
int uio_iovcnt
Definition: vsnprintf.c:230
#define NULL
Definition: vsnprintf.c:123
#define to_char(n)
Definition: vsnprintf.c:352
#define FLUSH()
#define LONG_MAX
Definition: vsnprintf.c:99
unsigned char * _p
Definition: vsnprintf.c:170
#define LONGINT
Definition: vsnprintf.c:527
#define SARG()
static int BSD__sfvwrite(register FILE *fp, register struct __suio *uio)
Definition: vsnprintf.c:241
#define val
#define INTPTR_MASK
#define __SWR
Definition: vsnprintf.c:187
#define PAD(howmany, with)
#define PRI_EXTRA_MARK
Definition: sprintf.c:1259
RUBY_EXTERN int isinf(double)
Definition: isinf.c:56
short _flags
Definition: vsnprintf.c:175
int err
Definition: win32.c:135
#define __SLBF
Definition: vsnprintf.c:184
#define EOF
Definition: vsnprintf.c:201
#define PAD_L(howmany, with)
#define LADJUST
Definition: vsnprintf.c:525
#define rb_strlen_lit(str)
Definition: intern.h:867
#define PADSIZE
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309
size_t uio_resid
Definition: vsnprintf.c:231
#define GETIOV(extra_work)
struct __siov * uio_iov
Definition: vsnprintf.c:229
#define isnan(x)
Definition: win32.h:346
struct __sFILE FILE
#define MAYBE_UNUSED
Definition: ffi_common.h:32
#define CHAR_BIT
Definition: ruby.h:196
register unsigned int len
Definition: zonetab.h:51
static int BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
Definition: vsnprintf.c:340
int size
Definition: encoding.c:57
static ssize_t BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
Definition: vsnprintf.c:537
#define BUF
Definition: vsnprintf.c:509
size_t _size
Definition: vsnprintf.c:139
#define is_digit(c)
Definition: vsnprintf.c:351
size_t _w
Definition: vsnprintf.c:174
#define FPT
Definition: vsnprintf.c:535
#define PRI_EXTRA_MARK_LEN
#define lower_hexdigits
Definition: vsnprintf.c:514
#define BSD__dtoa
Definition: sprintf.c:1256
#define ALT
Definition: vsnprintf.c:523
static char * BSD__ultoa(register u_long val, char *endp, int base, int octzero, const char *xdigs)
Definition: vsnprintf.c:427
#define u_long
Definition: vsnprintf.c:64
#define PRINT(ptr, len)
#define memcpy(d, s, n)
Definition: ffi_common.h:55
void void xfree(void *)
#define __SNBF
Definition: vsnprintf.c:185
#define UARG()
#define INTPTR_FLAG
int(* vwrite)()
Definition: vsnprintf.c:179
#define SHORTINT
Definition: vsnprintf.c:533
const char *(* vextra)()
Definition: vsnprintf.c:180
#define BSD__sferror(p)
Definition: vsnprintf.c:205
#define bp()
Definition: vm_debug.h:25
#define COPY(n)
static int BSD__sprint(FILE *fp, register struct __suio *uio)
Definition: vsnprintf.c:319
#define __SRW
Definition: vsnprintf.c:189
size_t iov_len
Definition: vsnprintf.c:226