Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

sprintf.c File Reference

#include "ruby.h"
#include <ctype.h>
#include <math.h>

Go to the source code of this file.

Defines

#define BIT_DIGITS(N)   (((N)*146)/485 + 1)
#define FNONE   0
#define FSHARP   1
#define FMINUS   2
#define FPLUS   4
#define FZERO   8
#define FSPACE   16
#define FWIDTH   32
#define FPREC   64
#define CHECK(l)
#define PUSH(s, l)
#define GETARG()
#define GETPOSARG(n)
#define GETNTHARG(nth)   ((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[nth])
#define GETASTER(val)

Functions

void fmt_setup (char *, int, int, int, int)
char * remove_sign_bits (char *str, int base)
char sign_bits (int base, const char *p)
VALUE rb_f_sprintf (int argc, VALUE *argv)


Define Documentation

#define BIT_DIGITS  )     (((N)*146)/485 + 1)
 

Definition at line 19 of file sprintf.c.

Referenced by rb_f_sprintf().

#define CHECK  ) 
 

Value:

do {\
    while (blen + (l) >= bsiz) {\
        bsiz*=2;\
    }\
    rb_str_resize(result, bsiz);\
    buf = RSTRING(result)->ptr;\
} while (0)

Definition at line 85 of file sprintf.c.

#define FMINUS   2
 

Definition at line 78 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FNONE   0
 

Definition at line 76 of file sprintf.c.

Referenced by rb_f_sprintf().

#define FPLUS   4
 

Definition at line 79 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FPREC   64
 

Definition at line 83 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FSHARP   1
 

Definition at line 77 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FSPACE   16
 

Definition at line 81 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FWIDTH   32
 

Definition at line 82 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

#define FZERO   8
 

Definition at line 80 of file sprintf.c.

Referenced by fmt_setup(), and rb_f_sprintf().

 
#define GETARG  ) 
 

Value:

(nextvalue != Qundef ? nextvalue : \
    posarg < 0 ? \
    (rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
    (posarg = nextarg++, GETNTHARG(posarg)))

Definition at line 99 of file sprintf.c.

Referenced by rb_f_sprintf().

#define GETASTER val   ) 
 

Value:

do { \
    t = p++; \
    n = 0; \
    for (; p < end && ISDIGIT(*p); p++) { \
        int next_n = 10 * n + (*p - '0'); \
        if (next_n / 10 != n) {\
            rb_raise(rb_eArgError, #val " too big"); \
        } \
        n = next_n; \
    } \
    if (p >= end) { \
        rb_raise(rb_eArgError, "malformed format string - %%*[0-9]"); \
    } \
    if (*p == '$') { \
        tmp = GETPOSARG(n); \
    } \
    else { \
        tmp = GETARG(); \
        p = t; \
    } \
    val = NUM2INT(tmp); \
} while (0)

Definition at line 112 of file sprintf.c.

Referenced by rb_f_sprintf().

#define GETNTHARG nth   )     ((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[nth])
 

Definition at line 109 of file sprintf.c.

Referenced by rb_f_sprintf().

#define GETPOSARG  ) 
 

Value:

(posarg > 0 ? \
    (rb_raise(rb_eArgError, "numbered(%d) after unnumbered(%d)", n, posarg), 0) : \
    ((n < 1) ? (rb_raise(rb_eArgError, "invalid index - %d$", n), 0) : \
               (posarg = -1, GETNTHARG(n))))

Definition at line 104 of file sprintf.c.

Referenced by rb_f_sprintf().

#define PUSH s,
 ) 
 

Value:

do { \
    CHECK(l);\
    memcpy(&buf[blen], s, l);\
    blen += (l);\
} while (0)

Definition at line 93 of file sprintf.c.

Referenced by rb_f_sprintf(), and ruby_qsort().


Function Documentation

void fmt_setup char *  ,
int  ,
int  ,
int  ,
int 
[static]
 

Definition at line 797 of file sprintf.c.

References FMINUS, FPLUS, FPREC, FSHARP, FSPACE, FWIDTH, and FZERO.

Referenced by rb_f_sprintf().

char* remove_sign_bits char *  str,
int  base
[static]
 

Definition at line 24 of file sprintf.c.

Referenced by rb_f_sprintf().

char sign_bits int  base,
const char *  p
[static]
 

Definition at line 57 of file sprintf.c.

Referenced by rb_f_sprintf().


Generated on Wed Jan 18 23:32:11 2006 for Ruby by doxygen 1.3.5