Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Functions
vsnprintf.c File Reference
`#include <sys/types.h>`
`#include <varargs.h>`
`#include <stddef.h>`
`#include <math.h>`
`#include <float.h>`

Go to the source code of this file.

## Data Structures
struct | __sbuf
struct | __sFILE
struct | __siov
struct | __suio

## Macros
#define | u_long unsigned long
#define | u_short unsigned short
#define | u_int unsigned int
#define | __P(x) ()
#define | const
#define | _BSD_VA_LIST_ va_list
#define | LONG_MAX 2147483647
#define | NULL 0
#define | __SLBF 0x0001 /* line buffered */
#define | __SNBF 0x0002 /* unbuffered */
#define | __SRD 0x0004 /* OK to read */
#define | __SWR 0x0008 /* OK to write */
#define | __SRW 0x0010 /* open for reading & writing */
#define | __SEOF 0x0020 /* found EOF */
#define | __SERR 0x0040 /* found error */
#define | __SMBF 0x0080 /* _buf is from malloc */
#define | __SAPP 0x0100 /* fdopen()ed in append mode */
#define | __SSTR 0x0200 /* this is an sprintf/snprintf string */
#define | __SOPT 0x0400 /* do fseek() optimisation */
#define | __SNPT 0x0800 /* do not do fseek() optimisation */
#define | __SOFF 0x1000 /* set iff _offset is in fact correct */
#define | __SMOD 0x2000 /* true => fgetln modified _p text */
#define | EOF (-1)
#define | BSD__sfeof(p) (((p)->_flags & __SEOF) != 0)
#define | BSD__sferror(p) (((p)->_flags & __SERR) != 0)
#define | BSD__sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define | BSD__sfileno(p) ((p)->_file)
#define | feof(p) BSD__sfeof(p)
#define | ferror(p) BSD__sferror(p)
#define | clearerr(p) BSD__sclearerr(p)
#define | fileno(p) BSD__sfileno(p)
#define | MIN(a, b) ((a) < (b) ? (a) : (b))
#define | COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
#define | GETIOV(extra_work)
#define | to_digit(c) ((c) - '0')
#define | is_digit(c) ((unsigned)to_digit(c) <= 9)
#define | to_char(n) (char)((n) + '0')
#define | BUF 68
#define | lower_hexdigits "0123456789abcdef"
#define | upper_hexdigits "0123456789ABCDEF"
#define | ALT 0x001 /* alternate form */
#define | HEXPREFIX 0x002 /* add 0x or 0X prefix */
#define | LADJUST 0x004 /* left adjustment */
#define | LONGDBL 0x008 /* long double; unimplemented */
#define | LONGINT 0x010 /* long integer */
#define | SHORTINT 0x040 /* short integer */
#define | ZEROPAD 0x080 /* zero (as opposed to blank) pad */
#define | FPT 0x100 /* Floating point number */
#define | NIOV 8
#define | PADSIZE 16 /* pad chunk size */
#define | PRINT(ptr, len)
#define | PAD(howmany, with)
#define | PAD_L(howmany, with) PAD((howmany), (with))
#define | FLUSH()
#define | SARG()
#define | UARG()
#define | INTPTR_MASK (LONGINT|SHORTINT)
#define | INTPTR_FLAG LONGINT
#define | PRI_EXTRA_MARK_LEN 0
#define | IS_PRI_EXTRA_MARK(s) 1

## Typedefs
typedef struct __sFILE | FILE

## Functions
| ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS (static ssize_t BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap))

## Macro Definition Documentation

## ◆ __P

#define __P | ( |  | x | ) | ()

Definition at line 81 of file vsnprintf.c.

## ◆ __SAPP

#define __SAPP 0x0100 /* fdopen()ed in append mode */

Definition at line 195 of file vsnprintf.c.

## ◆ __SEOF

#define __SEOF 0x0020 /* found EOF */

Definition at line 192 of file vsnprintf.c.

## ◆ __SERR

#define __SERR 0x0040 /* found error */

Definition at line 193 of file vsnprintf.c.

## ◆ __SLBF

#define __SLBF 0x0001 /* line buffered */

Definition at line 186 of file vsnprintf.c.

## ◆ __SMBF

#define __SMBF 0x0080 /* _buf is from malloc */

Definition at line 194 of file vsnprintf.c.

## ◆ __SMOD

#define __SMOD 0x2000 /* true => fgetln modified _p text */

Definition at line 200 of file vsnprintf.c.

## ◆ __SNBF

#define __SNBF 0x0002 /* unbuffered */

Definition at line 187 of file vsnprintf.c.

## ◆ __SNPT

#define __SNPT 0x0800 /* do not do fseek() optimisation */

Definition at line 198 of file vsnprintf.c.

## ◆ __SOFF

#define __SOFF 0x1000 /* set iff _offset is in fact correct */

Definition at line 199 of file vsnprintf.c.

## ◆ __SOPT

#define __SOPT 0x0400 /* do fseek() optimisation */

Definition at line 197 of file vsnprintf.c.

## ◆ __SRD

#define __SRD 0x0004 /* OK to read */

Definition at line 188 of file vsnprintf.c.

## ◆ __SRW

#define __SRW 0x0010 /* open for reading & writing */

Definition at line 191 of file vsnprintf.c.

## ◆ __SSTR

#define __SSTR 0x0200 /* this is an sprintf/snprintf string */

Definition at line 196 of file vsnprintf.c.

## ◆ __SWR

#define __SWR 0x0008 /* OK to write */

Definition at line 189 of file vsnprintf.c.

## ◆ _BSD_VA_LIST_

#define _BSD_VA_LIST_ va_list

Definition at line 88 of file vsnprintf.c.

## ◆ ALT

#define ALT 0x001 /* alternate form */

Definition at line 525 of file vsnprintf.c.

## ◆ BSD__sclearerr

#define BSD__sclearerr | ( |  | p | ) | ((void)((p)->_flags &= ~(__SERR|__SEOF)))

Definition at line 208 of file vsnprintf.c.

## ◆ BSD__sfeof

#define BSD__sfeof | ( |  | p | ) | (((p)->_flags & __SEOF) != 0)

Definition at line 206 of file vsnprintf.c.

## ◆ BSD__sferror

#define BSD__sferror | ( |  | p | ) | (((p)->_flags & __SERR) != 0)

Definition at line 207 of file vsnprintf.c.

## ◆ BSD__sfileno

#define BSD__sfileno | ( |  | p | ) | ((p)->_file)

Definition at line 209 of file vsnprintf.c.

## ◆ BUF

#define BUF 68

Definition at line 511 of file vsnprintf.c.

## ◆ clearerr

#define clearerr | ( |  | p | ) | BSD__sclearerr(p)

Definition at line 216 of file vsnprintf.c.

## ◆ const

#define const

Definition at line 83 of file vsnprintf.c.

## ◆ COPY

#define COPY | ( |  | n | ) | (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))

## ◆ EOF

#define EOF (-1)

Definition at line 203 of file vsnprintf.c.

## ◆ feof

#define feof | ( |  | p | ) | BSD__sfeof(p)

Definition at line 214 of file vsnprintf.c.

## ◆ ferror

#define ferror | ( |  | p | ) | BSD__sferror(p)

Definition at line 215 of file vsnprintf.c.

## ◆ fileno

#define fileno | ( |  | p | ) | BSD__sfileno(p)

Definition at line 219 of file vsnprintf.c.

## ◆ FLUSH

#define FLUSH | ( |  | ) |

Value:
{ \
if (uio.uio_resid && BSD__sprint(fp, &uio)) \
goto error; \
uio.uio_iovcnt = 0; \
iovp = iov; \
}

## ◆ FPT

#define FPT 0x100 /* Floating point number */

Definition at line 537 of file vsnprintf.c.

## ◆ GETIOV

#define GETIOV | ( |  | extra_work | ) |

Value:
while (len == 0) { \
extra_work; \
p = iov->iov_base; \
len = iov->iov_len; \
iov++; \
}

## ◆ HEXPREFIX

#define HEXPREFIX 0x002 /* add 0x or 0X prefix */

Definition at line 526 of file vsnprintf.c.

## ◆ INTPTR_FLAG

#define INTPTR_FLAG LONGINT

## ◆ INTPTR_MASK

#define INTPTR_MASK (LONGINT|SHORTINT)

## ◆ is_digit

#define is_digit | ( |  | c | ) | ((unsigned)to_digit(c) <= 9)

Definition at line 353 of file vsnprintf.c.

## ◆ IS_PRI_EXTRA_MARK

#define IS_PRI_EXTRA_MARK | ( |  | s | ) | 1

## ◆ LADJUST

#define LADJUST 0x004 /* left adjustment */

Definition at line 527 of file vsnprintf.c.

## ◆ LONG_MAX

#define LONG_MAX 2147483647

Definition at line 99 of file vsnprintf.c.

## ◆ LONGDBL

#define LONGDBL 0x008 /* long double; unimplemented */

Definition at line 528 of file vsnprintf.c.

## ◆ LONGINT

#define LONGINT 0x010 /* long integer */

Definition at line 529 of file vsnprintf.c.

## ◆ lower_hexdigits

#define lower_hexdigits "0123456789abcdef"

Definition at line 516 of file vsnprintf.c.

## ◆ MIN

#define MIN | ( |  | a,
|  |  | b
| ) |  | ((a) < (b) ? (a) : (b))

## ◆ NIOV

#define NIOV 8

## ◆ NULL

#define NULL 0

Definition at line 123 of file vsnprintf.c.

## ◆ PAD

#define PAD | ( |  | howmany,
|  |  | with
| ) |  |

Value:
{ \
if ((n = (howmany)) > 0) { \
while (n > PADSIZE) { \
PRINT((with), PADSIZE); \
n -= PADSIZE; \
} \
PRINT((with), n); \
} \
}

## ◆ PAD_L

#define PAD_L | ( |  | howmany,
|  |  | with
| ) |  | PAD((howmany), (with))

## ◆ PADSIZE

#define PADSIZE 16 /* pad chunk size */

## ◆ PRI_EXTRA_MARK_LEN

#define PRI_EXTRA_MARK_LEN 0

## ◆ PRINT

#define PRINT | ( |  | ptr,
|  |  | len
| ) |  |

Value:
{ \
iovp->iov_base = (ptr); \
iovp->iov_len = (len); \
uio.uio_resid += (len); \
iovp++; \
if (++uio.uio_iovcnt >= NIOV) { \
if (BSD__sprint(fp, &uio)) \
goto error; \
iovp = iov; \
} \
}

## ◆ SARG

#define SARG | ( |  | ) |

Value:
(flags&LONGINT ? va_arg(ap, long) : \
flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
(long)va_arg(ap, int))

## ◆ SHORTINT

#define SHORTINT 0x040 /* short integer */

Definition at line 535 of file vsnprintf.c.

## ◆ to_char

#define to_char | ( |  | n | ) | (char)((n) + '0')

Definition at line 354 of file vsnprintf.c.

## ◆ to_digit

#define to_digit | ( |  | c | ) | ((c) - '0')

Definition at line 352 of file vsnprintf.c.

## ◆ u_int

#define u_int unsigned int

Definition at line 66 of file vsnprintf.c.

## ◆ u_long

#define u_long unsigned long

Definition at line 64 of file vsnprintf.c.

## ◆ u_short

#define u_short unsigned short

Definition at line 65 of file vsnprintf.c.

## ◆ UARG

#define UARG | ( |  | ) |

Value:
(flags&LONGINT ? va_arg(ap, u_long) : \
flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \
(u_long)va_arg(ap, u_int))

## ◆ upper_hexdigits

#define upper_hexdigits "0123456789ABCDEF"

Definition at line 519 of file vsnprintf.c.

## ◆ ZEROPAD

#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */

Definition at line 536 of file vsnprintf.c.

## Typedef Documentation

## ◆ FILE

typedef struct __sFILE FILE

## Function Documentation

## ◆ ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS()

ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS | ( | static ssize_t | BSD_vfprintfFILE *fp, const char *fmt0, va_list ap | ) |

u_int
unsigned int u_int
Definition: rb_mjit_min_header-2.7.0.h:1291
va_arg
#define va_arg(v, l)
Definition: rb_mjit_min_header-2.7.0.h:3980
howmany
#define howmany(x, y)
Definition: rb_mjit_min_header-2.7.0.h:11087
short
#define short
Definition: rb_mjit_min_header-2.7.0.h:2877
int
__inline__ int
Definition: rb_mjit_min_header-2.7.0.h:2839
ptr
struct RIMemo * ptr
Definition: debug.c:74
error
const rb_iseq_t const char * error
Definition: rb_mjit_min_header-2.7.0.h:13506
NIOV
#define NIOV
u_long
unsigned long u_long
Definition: rb_mjit_min_header-2.7.0.h:1293
PADSIZE
#define PADSIZE
long
#define long
Definition: rb_mjit_min_header-2.7.0.h:2880
LONGINT
#define LONGINT
Definition: vsnprintf.c:529
n
const char size_t n
Definition: rb_mjit_min_header-2.7.0.h:5456
SHORTINT
#define SHORTINT
Definition: vsnprintf.c:535
len
uint8_t len
Definition: escape.c:17
u_short
unsigned short u_short
Definition: rb_mjit_min_header-2.7.0.h:1289