Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions
date_strftime.c File Reference
`#include "ruby/ruby.h"`
`#include "date_tmx.h"`
`#include <stdlib.h>`
`#include <string.h>`
`#include <ctype.h>`
`#include <errno.h>`
Include dependency graph for date_strftime.c:

Go to the source code of this file.

## Macros
#define | range(low, item, hi) (item)
#define | add(x, y) (rb_funcall((x), '+', 1, (y)))
#define | sub(x, y) (rb_funcall((x), '-', 1, (y)))
#define | mul(x, y) (rb_funcall((x), '*', 1, (y)))
#define | quo(x, y) (rb_funcall((x), rb_intern("quo"), 1, (y)))
#define | div(x, y) (rb_funcall((x), rb_intern("div"), 1, (y)))
#define | mod(x, y) (rb_funcall((x), '%', 1, (y)))
#define | BIT_OF(n) (1U<<(n))
#define | FLAG_FOUND()
#define | NEEDS(n) do if (s >= endp || (n) >= endp - s - 1) goto err; while (0)
#define | FILL_PADDING(i)
#define | FMT(def_pad, def_prec, fmt, val)
#define | STRFTIME(fmt)
#define | FMTV(def_pad, def_prec, fmt, val)

## Functions
static void | upcase (char *s, size_t i)
static void | downcase (char *s, size_t i)
static size_t | date_strftime_with_tmx (char *s, size_t maxsize, const char *format, const struct tmx *tmx)
size_t | date_strftime (char *s, size_t maxsize, const char *format, const struct tmx *tmx)

## Macro Definition Documentation

#define add | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), '+', 1, (y)))

Definition at line 23 of file date_strftime.c.

Referenced by add_heap_slots(), allocate_sorted_heaps(), onig_chain_link_add(), ossl_bn_s_generate_prime(), and rb_str_associate().

#define BIT_OF | ( |  | n | ) | (1U<<(n))

Referenced by date_strftime_with_tmx().

#define div | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), rb_intern("div"), 1, (y)))

Definition at line 27 of file date_strftime.c.

Referenced by date_strftime_with_tmx(), rb_strftime_with_timespec(), and time_mdump().

#define FILL_PADDING | ( |  | i | ) |

Value:
do { \
if (!(flags & BIT_OF(LEFT)) && precision > (i)) { \
NEEDS(precision); \
memset(s, padding ? padding : ' ', precision - (i)); \
s += precision - (i); \
} \
else { \
NEEDS(i); \
} \
} while (0);
i
ssize_t i
Definition: bigdecimal.c:5655
memset
memset(y->frac+ix+1, 0,(y->Prec-(ix+1))*sizeof(BDIGIT))
NEEDS
#define NEEDS(n)
flags
int flags
Definition: tcltklib.c:3023
s
register char * s
Definition: os2.c:56
else
else
Definition: bigdecimal.c:1192
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
BIT_OF
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

#define FLAG_FOUND | ( |  | ) |

Value:
do { \
if (precision > 0 || flags & (BIT_OF(LOCALE_E) | BIT_OF(LOCALE_O) | BIT_OF(COLONS))) \
goto unknown; \
} while (0)
flags
int flags
Definition: tcltklib.c:3023
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
BIT_OF
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

#define FMT | ( |  | def_pad,
|  |  | def_prec,
|  |  | fmt,
|  |  | val
| ) |  |

Value:
do { \
int l; \
if (precision <= 0) precision = (def_prec); \
if (flags & BIT_OF(LEFT)) precision = 1; \
l = snprintf(s, endp - s, \
((padding == '0' || (!padding && (def_pad) == '0')) ? \
"%0*"fmt : "%*"fmt), \
precision, (val)); \
if (l < 0) goto err; \
s += l; \
} while (0)
int
VP_EXPORT int
Definition: bigdecimal.c:5050
fmt
const char * fmt
Definition: tcltklib.c:841
while
while(a->frac[0]/shift==0)
Definition: bigdecimal.c:5117
val
#define val
Definition: tcltklib.c:1949
flags
int flags
Definition: tcltklib.c:3023
err
int err
Definition: win32.c:87
s
register char * s
Definition: os2.c:56
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
snprintf
#define snprintf
BIT_OF
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

#define FMTV | ( |  | def_pad,
|  |  | def_prec,
|  |  | fmt,
|  |  | val
| ) |  |

Value:
do { \
VALUE tmp = (val); \
if (FIXNUM_P(tmp)) { \
FMT((def_pad), (def_prec), "l"fmt, FIX2LONG(tmp)); \
} \
else { \
VALUE args[2], result; \
size_t l; \
if (precision <= 0) precision = (def_prec); \
if (flags & BIT_OF(LEFT)) precision = 1; \
args[0] = INT2FIX(precision); \
args[1] = (val); \
if (padding == '0' || (!padding && (def_pad) == '0')) \
result = rb_str_format(2, args, rb_str_new2("%0*"fmt)); \
else \
result = rb_str_format(2, args, rb_str_new2("%*"fmt)); \
l = strlcpy(s, StringValueCStr(result), endp - s); \
if ((size_t)(endp - s) <= l) \
goto err; \
s += l; \
} \
} while (0)
tmp
volatile VALUE tmp
Definition: tcltklib.c:10209
FMT
#define FMT(def_pad, def_prec, fmt, val)
rb_str_new2
#define rb_str_new2
args
VALUE VALUE args
Definition: tcltklib.c:2561
fmt
const char * fmt
Definition: tcltklib.c:841
strlcpy
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
while
while(a->frac[0]/shift==0)
Definition: bigdecimal.c:5117
FIXNUM_P
#define FIXNUM_P(f)
val
#define val
Definition: tcltklib.c:1949
StringValueCStr
#define StringValueCStr(v)
flags
int flags
Definition: tcltklib.c:3023
INT2FIX
#define INT2FIX(i)
FIX2LONG
#define FIX2LONG(x)
err
int err
Definition: win32.c:87
rb_str_format
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:439
result
q result
Definition: tcltklib.c:7070
s
register char * s
Definition: os2.c:56
else
else
Definition: bigdecimal.c:1192
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
VALUE
unsigned long VALUE
Definition: ripper.y:104
BIT_OF
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

#define mod | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), '%', 1, (y)))

Definition at line 28 of file date_strftime.c.

Referenced by BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_mod(), bigdivmod(), class_instance_method_list(), date_strftime_with_tmx(), fix_divmod(), fix_mod(), fixdivmod(), flo_divmod(), flodivmod(), iseq_specialized_instruction(), mod_cvar_of(), mSyslogMacros_included(), rb_ary_flatten(), rb_ary_flatten_bang(), rb_autoload_load(), rb_big_divmod(), rb_class_inherited_p(), rb_mod_alias_method(), rb_mod_const_get(), rb_mod_const_of(), rb_mod_define_method(), rb_mod_remove_method(), rb_mod_undef_method(), rb_module_s_alloc(), rb_str_sum(), and ruby_float_mod().

#define mul | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), '*', 1, (y)))

Definition at line 25 of file date_strftime.c.

Referenced by date_strftime_with_tmx(), enum_cycle_size(), and rb_ary_cycle_size().

#define NEEDS | ( |  | n | ) | do if (s >= endp || (n) >= endp - s - 1) goto err; while (0)

Referenced by date_strftime_with_tmx().

#define quo | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), rb_intern("quo"), 1, (y)))

Definition at line 26 of file date_strftime.c.

#define range | ( |  | low,
|  |  | item,
|  |  | hi
| ) |  | (item)

Definition at line 21 of file date_strftime.c.

Referenced by date_strftime_with_tmx(), enc_succ_alnum_char(), iso2022jp_check_conv(), onig_search_gpos(), range_bsearch(), range_each(), range_loader(), range_step(), rb_range_new(), rb_reg_adjust_startpos(), and rb_reg_search().

#define STRFTIME | ( |  | fmt | ) |

Value:
do { \
i = date_strftime_with_tmx(s, endp - s, (fmt), tmx); \
if (!i) return 0; \
if (flags & BIT_OF(UPPER)) \
upcase(s, i); \
if (!(flags & BIT_OF(LEFT)) && precision > i) { \
if (start + maxsize < s + precision) { \
errno = ERANGE; \
return 0; \
} \
memmove(s + precision - i, s, i); \
memset(s, padding ? padding : ' ', precision - i); \
s += precision; \
} \
else s += i; \
} while (0)
tmx
Definition: date_tmx.h:24
return
return
Definition: bigdecimal.c:5800
i
ssize_t i
Definition: bigdecimal.c:5655
memmove
RUBY_EXTERN void * memmove(void *, const void *, size_t)
Definition: memmove.c:7
date_strftime_with_tmx
static size_t date_strftime_with_tmx(char *s, size_t maxsize, const char *format, const struct tmx *tmx)
Definition: date_strftime.c:51
fmt
const char * fmt
Definition: tcltklib.c:841
memset
memset(y->frac+ix+1, 0,(y->Prec-(ix+1))*sizeof(BDIGIT))
flags
int flags
Definition: tcltklib.c:3023
errno
int errno
s
register char * s
Definition: os2.c:56
else
else
Definition: bigdecimal.c:1192
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
upcase
static void upcase(char *s, size_t i)
Definition: date_strftime.c:31
BIT_OF
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

#define sub | ( |  | x,
|  |  | y
| ) |  | (rb_funcall((x), '-', 1, (y)))

Definition at line 24 of file date_strftime.c.

Referenced by rb_str_index_m(), and rb_str_rindex_m().

## Function Documentation

size_t date_strftime | ( | char * | s,
|  | size_t | maxsize,
|  | const char * | format,
|  | const struct tmx * | tmx
| ) |  |

Definition at line 623 of file date_strftime.c.

References date_strftime_with_tmx().

Referenced by date_strftime_alloc().

static size_t date_strftime_with_tmx | ( | char * | s,
|  | size_t | maxsize,
|  | const char * | format,
|  | const struct tmx * | tmx
| ) |  |
| static

Definition at line 51 of file date_strftime.c.

References args, BIT_OF, div, downcase(), e, err, errno, FILL_PADDING, FIX2LONG, FIXNUM_P, FLAG_FOUND, flags, FMT, FMTV, i, int, INT2FIX, memcpy(), mod, mul, n, NEEDS, NULL, NUM2INT, range, rb_str_format(), rb_str_new2, result, s, snprintf, strchr(), STRFTIME, StringValueCStr, strlcpy(), strlen(), tmx_cwday, tmx_cweek, tmx_cwyear, tmx_hour, tmx_mday, tmx_min, tmx_mon, tmx_msecs, tmx_offset, tmx_sec, tmx_sec_fraction, tmx_secs, tmx_wday, tmx_wnum0, tmx_wnum1, tmx_yday, tmx_year, tmx_zone, tp, upcase(), v, and void.

Referenced by date_strftime().

static void downcase | ( | char * | s,
|  | size_t | i
| ) |  |
| static

Definition at line 40 of file date_strftime.c.

References ISUPPER, and TOLOWER.

Referenced by date_strftime_with_tmx().

static void upcase | ( | char * | s,
|  | size_t | i
| ) |  |
| static

Definition at line 31 of file date_strftime.c.

References ISLOWER, and TOUPPER.

Referenced by date_strftime_with_tmx().