Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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>`
Include dependency graph for vsnprintf.c:
This graph shows which files directly or indirectly include this file:

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 | UNINITIALIZED_VAR(x) x
#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 | 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

## Typedefs
typedef struct __sFILE | FILE

## Functions
static int | BSD__sfvwrite (register FILE *fp, register struct __suio *uio)
static int | BSD__sprint (FILE *fp, register struct __suio *uio)
static int | BSD__sbprintf (register FILE *fp, const char *fmt, va_list ap)
static char * | BSD__ultoa (register u_long val, char *endp, int base, int octzero, const char *xdigs)
static ssize_t | BSD_vfprintf (FILE *fp, const char *fmt0, va_list ap)
int | ruby_vsnprintf (char *str, size_t n, const char *fmt, va_list ap)
int | ruby_snprintf (char *str, size_t n, char const *fmt,...)

## Macro Definition Documentation

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

Definition at line 81 of file vsnprintf.c.

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

Definition at line 199 of file vsnprintf.c.

#define __SEOF 0x0020 /* found EOF */

Definition at line 196 of file vsnprintf.c.

#define __SERR 0x0040 /* found error */

Definition at line 197 of file vsnprintf.c.

#define __SLBF 0x0001 /* line buffered */

Definition at line 190 of file vsnprintf.c.

Referenced by BSD__sfvwrite().

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

Definition at line 198 of file vsnprintf.c.

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

Definition at line 204 of file vsnprintf.c.

#define __SNBF 0x0002 /* unbuffered */

Definition at line 191 of file vsnprintf.c.

Referenced by BSD__sfvwrite(), and BSD_vfprintf().

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

Definition at line 202 of file vsnprintf.c.

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

Definition at line 203 of file vsnprintf.c.

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

Definition at line 201 of file vsnprintf.c.

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

Definition at line 192 of file vsnprintf.c.

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

Definition at line 195 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 200 of file vsnprintf.c.

Referenced by BSD__sfvwrite(), rb_enc_vsprintf(), rb_str_vcatf(), ruby_snprintf(), and ruby_vsnprintf().

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

Definition at line 193 of file vsnprintf.c.

Referenced by BSD_vfprintf(), rb_enc_vsprintf(), rb_str_vcatf(), ruby_snprintf(), and ruby_vsnprintf().

#define _BSD_VA_LIST_ va_list

Definition at line 88 of file vsnprintf.c.

#define ALT 0x001 /* alternate form */

Definition at line 523 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 212 of file vsnprintf.c.

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

Definition at line 210 of file vsnprintf.c.

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

Definition at line 211 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 213 of file vsnprintf.c.

#define BUF 68

Definition at line 515 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 220 of file vsnprintf.c.

Referenced by rb_w32_getc().

#define const

Definition at line 83 of file vsnprintf.c.

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

Referenced by BSD__sfvwrite().

#define EOF (-1)

Definition at line 207 of file vsnprintf.c.

Referenced by appendline(), BSD_vfprintf(), curses_getch(), e_iconv(), e_oconv(), eol_conv(), fold_conv(), h_conv(), j_oconv(), kanji_convert(), mime_begin(), mime_begin_strict(), mime_getc(), mime_integrity(), mime_prechar(), mime_putc(), nfc_getc(), nkf_iconv_utf_16(), nkf_iconv_utf_32(), noconvert(), parser_prepare(), print_guessed_code(), push_hold_buf(), qpencode(), rb_io_getline_1(), rb_w32_getc(), ruby_snprintf(), ruby_vsnprintf(), s_iconv(), s_oconv(), std_putc(), w_iconv(), w_oconv(), w_oconv16(), w_oconv32(), window_getch(), and z_conv().

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

Definition at line 218 of file vsnprintf.c.

Referenced by rb_vm_bugreport().

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

Definition at line 219 of file vsnprintf.c.

Referenced by yaml_file_read_handler().

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

Definition at line 223 of file vsnprintf.c.

Referenced by fseeko(), init_stdhandle(), main(), ossl_pkey_new_from_file(), ossl_x509_new_from_file(), pipe_open(), prep_stdio(), rb_io_initialize(), rb_io_reopen(), rb_read_check(), rb_w32_fclose(), rb_w32_write(), and readline_readline().

#define FLUSH | ( |  | ) |

Value:
{ \
if (uio.uio_resid && BSD__sprint(fp, &uio)) \
goto error; \
uio.uio_iovcnt = 0; \
iovp = iov; \
}
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
BSD__sprint
static int BSD__sprint(FILE *fp, register struct __suio *uio)
Definition: vsnprintf.c:325

Referenced by BSD_vfprintf().

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

Definition at line 535 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define GETIOV | ( |  | extra_work | ) |

Value:
while (len == 0) { \
extra_work; \
p = iov->iov_base; \
len = iov->iov_len; \
iov++; \
}
p
Win32OLEIDispatch * p
Definition: win32ole.c:786
len
size_t len
Definition: tcltklib.c:3568

Referenced by BSD__sfvwrite().

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

Definition at line 524 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define INTPTR_FLAG LONGINT

Referenced by BSD_vfprintf().

#define INTPTR_MASK (LONGINT|SHORTINT)

Referenced by BSD_vfprintf().

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

Definition at line 357 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define LADJUST 0x004 /* left adjustment */

Definition at line 525 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define LONG_MAX 2147483647

Definition at line 99 of file vsnprintf.c.

Referenced by BSD__ultoa().

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

Definition at line 526 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define LONGINT 0x010 /* long integer */

Definition at line 527 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

#define NIOV 8

#define NULL 0

Definition at line 123 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Value:
{ \
if ((n = (howmany)) > 0) { \
while (n > PADSIZE) { \
PRINT((with), PADSIZE); \
n -= PADSIZE; \
} \
PRINT((with), n); \
} \
}
n
ssize_t n
Definition: bigdecimal.c:5655
while
while(a->frac[0]/shift==0)
Definition: bigdecimal.c:5117
PADSIZE
#define PADSIZE
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
PRINT
#define PRINT(ptr, len)

Referenced by BSD_vfprintf().

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

Referenced by BSD_vfprintf().

#define PADSIZE 16 /* pad chunk size */

Referenced by BSD_vfprintf().

#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; \
} \
}
ptr
return ptr
Definition: tcltklib.c:784
NIOV
#define NIOV
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
BSD__sprint
static int BSD__sprint(FILE *fp, register struct __suio *uio)
Definition: vsnprintf.c:325
len
size_t len
Definition: tcltklib.c:3568

Referenced by BSD_vfprintf().

#define SARG | ( |  | ) |

Value:
(flags&LONGINT ? va_arg(ap, long) : \
flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
(long)va_arg(ap, int))
int
VP_EXPORT int
Definition: bigdecimal.c:5050
LONGINT
#define LONGINT
Definition: vsnprintf.c:527
flags
int flags
Definition: tcltklib.c:3023
SHORTINT
#define SHORTINT
Definition: vsnprintf.c:533

Referenced by BSD_vfprintf().

#define SHORTINT 0x040 /* short integer */

Definition at line 533 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 358 of file vsnprintf.c.

Referenced by BSD__ultoa().

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

Definition at line 356 of file vsnprintf.c.

Referenced by BSD_vfprintf().

#define u_int unsigned int

Definition at line 66 of file vsnprintf.c.

#define u_long unsigned long

Definition at line 64 of file vsnprintf.c.

Referenced by BSD_vfprintf(), getaddrinfo(), getnameinfo(), and setfl().

#define u_short unsigned short

Definition at line 65 of file vsnprintf.c.

Referenced by get_addr(), get_name(), getaddrinfo(), and getnameinfo().

#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))
int
VP_EXPORT int
Definition: bigdecimal.c:5050
LONGINT
#define LONGINT
Definition: vsnprintf.c:527
flags
int flags
Definition: tcltklib.c:3023
u_short
#define u_short
Definition: vsnprintf.c:65
u_int
#define u_int
Definition: vsnprintf.c:66
u_long
#define u_long
Definition: vsnprintf.c:64
SHORTINT
#define SHORTINT
Definition: vsnprintf.c:533

Referenced by BSD_vfprintf().

#define UNINITIALIZED_VAR | ( |  | x | ) | x

Definition at line 133 of file vsnprintf.c.

Referenced by BSD_vfprintf().

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

Definition at line 534 of file vsnprintf.c.

Referenced by BSD_vfprintf().

## Typedef Documentation

typedef struct __sFILE FILE

## Function Documentation

static int BSD__sbprintf | ( | register FILE * | fp,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |
| static

Definition at line 346 of file vsnprintf.c.

Referenced by BSD_vfprintf().

static int BSD__sfvwrite | ( | register FILE * | fp,
|  | register struct __suio * | uio
| ) |  |
| static

Definition at line 247 of file vsnprintf.c.

References __SLBF, __SNBF, __SSTR, __sFILE::_flags, __sFILE::_p, __sFILE::_w, COPY, GETIOV, __siov::iov_base, __siov::iov_len, len, p, __suio::uio_iov, and __suio::uio_resid.

Referenced by ruby_snprintf(), and ruby_vsnprintf().

static int BSD__sprint | ( | FILE * | fp,
|  | register struct __suio * | uio
| ) |  |
| static

Definition at line 325 of file vsnprintf.c.

References err, __suio::uio_iovcnt, __suio::uio_resid, and __sFILE::vwrite.

static char* BSD__ultoa | ( | register u_long | val,
|  | char * | endp,
|  | int | base,
|  | int | octzero,
|  | const char * | xdigs
| ) |  |
| static

Definition at line 433 of file vsnprintf.c.

References cp, LONG_MAX, to_char, and val.

Referenced by BSD_vfprintf().

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

Definition at line 537 of file vsnprintf.c.

References __SNBF, __SRW, __SWR, __sFILE::_file, __sFILE::_flags, ALT, BSD__sbprintf(), BSD__sferror, BSD__ultoa(), BUF, buf, CHAR_BIT, cp, done, EOF, flags, FLUSH, fmt, FPT, HEXPREFIX, int, INTPTR_FLAG, INTPTR_MASK, is_digit, isinf(), isnan, LADJUST, LONGDBL, LONGINT, n, NULL, p, PAD, PAD_L, PADSIZE, PRINT, ret, SARG, SHORTINT, size, strlen(), to_digit, u_long, UARG, __suio::uio_iov, __suio::uio_iovcnt, __suio::uio_resid, UNINITIALIZED_VAR, __sFILE::vextra, and ZEROPAD.

Referenced by rb_enc_vsprintf(), rb_str_vcatf(), ruby_snprintf(), and ruby_vsnprintf().

int ruby_snprintf | ( | char * | str,
|  | size_t | n,
|  | char const * | fmt,
|  |  | ...
| ) |  |

Definition at line 1319 of file vsnprintf.c.

References __SSTR, __SWR, __sbuf::_base, __sFILE::_bf, __sFILE::_flags, __sFILE::_p, __sbuf::_size, __sFILE::_w, BSD__sfvwrite(), BSD_vfprintf(), EOF, f, int, ret, va_end(), __sFILE::vextra, and __sFILE::vwrite.

int ruby_vsnprintf | ( | char * | str,
|  | size_t | n,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Definition at line 1301 of file vsnprintf.c.

References __SSTR, __SWR, __sbuf::_base, __sFILE::_bf, __sFILE::_flags, __sFILE::_p, __sbuf::_size, __sFILE::_w, BSD__sfvwrite(), BSD_vfprintf(), EOF, f, int, ret, __sFILE::vextra, and __sFILE::vwrite.