Ruby  1.9.3p551(2014-11-13revision48407)
Macros | Functions
date_strftime.c File Reference
#include "ruby/ruby.h"
#include "date_tmx.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <errno.h>
#include <math.h>

Go to the source code of this file.

Macros

#define SYSV_EXT   1 /* stuff in System V ascftime routine */
 
#define SUNOS_EXT   1 /* stuff in SunOS strftime routine */
 
#define POSIX2_DATE   1 /* stuff in Posix 1003.2 date command */
 
#define VMS_EXT   1 /* include %v for VMS date format */
 
#define MAILHEADER_EXT   1 /* add %z for HHMM format */
 
#define ISO_DATE_EXT   1 /* %G and %g for year of ISO week */
 
#define adddecl(stuff)   stuff
 
#define range(low, item, hi)   max((low), min((item), (hi)))
 
#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

void * malloc ()
 
void * realloc ()
 
char * getenv ()
 
char * strchr ()
 
static int min (int a, int b)
 
static int max (int a, int b)
 
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

◆ add

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

◆ adddecl

#define adddecl (   stuff)    stuff

Definition at line 93 of file date_strftime.c.

◆ BIT_OF

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

Referenced by date_strftime_with_tmx().

◆ div

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

◆ FILL_PADDING

#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);
int i
Definition: win32ole.c:776
unsigned flags
Definition: date_core.c:290
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:291

Referenced by date_strftime_with_tmx().

◆ FLAG_FOUND

#define FLAG_FOUND ( )
Value:
do { \
if (precision > 0 || flags & (BIT_OF(LOCALE_E)|BIT_OF(LOCALE_O))) \
goto unknown; \
} while (0)
unsigned flags
Definition: date_core.c:290
#define BIT_OF(n)

Referenced by date_strftime_with_tmx().

◆ FMT

#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)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: name2ctype.h:23841
unsigned flags
Definition: date_core.c:290
#define snprintf
Definition: subst.h:6
int err
Definition: win32.c:78
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:291

Referenced by date_strftime_with_tmx().

◆ FMTV

#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)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: name2ctype.h:23841
unsigned flags
Definition: date_core.c:290
#define FIXNUM_P(f)
Definition: ruby.h:338
int args
Definition: win32ole.c:777
int err
Definition: win32.c:78
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:439
static VALUE result
Definition: nkf.c:40
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
Definition: strlcpy.c:44
#define StringValueCStr(v)
Definition: ruby.h:468
#define INT2FIX(i)
Definition: ruby.h:225
#define FIX2LONG(x)
Definition: ruby.h:336
#define BIT_OF(n)
VALUE rb_str_new2(const char *)
struct SimpleDateData s
Definition: date_core.c:291

Referenced by date_strftime_with_tmx().

◆ ISO_DATE_EXT

#define ISO_DATE_EXT   1 /* %G and %g for year of ISO week */

Definition at line 75 of file date_strftime.c.

◆ MAILHEADER_EXT

#define MAILHEADER_EXT   1 /* add %z for HHMM format */

Definition at line 74 of file date_strftime.c.

◆ mod

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

Definition at line 168 of file date_strftime.c.

Referenced by add_modules(), autoload_delete(), autoload_node(), autoload_node_id(), BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_DoDivmod(), BigDecimal_mod(), bigdivmod(), check_definition(), class_instance_method_list(), date_strftime_with_tmx(), fix_divmod(), fix_mod(), fixdivmod(), flo_divmod(), flodivmod(), rb_ary_flatten(), rb_ary_flatten_bang(), rb_autoload(), rb_autoload_load(), rb_autoload_p(), rb_big_divmod(), rb_class_inherited_p(), rb_class_instance_methods(), rb_class_private_instance_methods(), rb_class_protected_instance_methods(), rb_class_public_instance_methods(), rb_const_remove(), rb_define_notimplement_method_id(), rb_mod_alias_method(), rb_mod_ancestors(), rb_mod_autoload(), rb_mod_autoload_p(), rb_mod_cmp(), rb_mod_const_at(), rb_mod_const_defined(), rb_mod_const_get(), rb_mod_const_of(), rb_mod_const_set(), rb_mod_constants(), rb_mod_define_method(), rb_mod_eqq(), rb_mod_extend_object(), rb_mod_freeze(), rb_mod_ge(), rb_mod_gt(), rb_mod_include_p(), rb_mod_included_modules(), rb_mod_instance_method(), rb_mod_lt(), rb_mod_method_arity(), rb_mod_method_defined(), rb_mod_module_eval(), rb_mod_module_exec(), rb_mod_name(), rb_mod_private_method_defined(), rb_mod_protected_method_defined(), rb_mod_public_instance_method(), rb_mod_public_method_defined(), rb_mod_remove_const(), rb_mod_remove_cvar(), rb_mod_remove_method(), rb_mod_s_constants(), rb_mod_sys_fail(), rb_mod_sys_fail_str(), rb_mod_syserr_fail(), rb_mod_syserr_fail_str(), rb_mod_undef_method(), rb_module_s_alloc(), rb_str_sum(), ruby_float_mod(), and set_const_visibility().

◆ mul

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

Definition at line 165 of file date_strftime.c.

Referenced by date_strftime_with_tmx().

◆ NEEDS

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

Referenced by date_strftime_with_tmx().

◆ POSIX2_DATE

#define POSIX2_DATE   1 /* stuff in Posix 1003.2 date command */

Definition at line 72 of file date_strftime.c.

◆ quo

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

Definition at line 166 of file date_strftime.c.

◆ range

#define range (   low,
  item,
  hi 
)    max((low), min((item), (hi)))

◆ STRFTIME

#define STRFTIME (   fmt)
Value:
do { \
i = date_strftime_with_tmx(s, endp - s, (fmt), tmx); \
if (!i) return 0; \
if (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)
Definition: date_tmx.h:24
int i
Definition: win32ole.c:776
static size_t date_strftime_with_tmx(char *s, size_t maxsize, const char *format, const struct tmx *tmx)
struct SimpleDateData s
Definition: date_core.c:291

Referenced by date_strftime_with_tmx().

◆ sub

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

◆ SUNOS_EXT

#define SUNOS_EXT   1 /* stuff in SunOS strftime routine */

Definition at line 71 of file date_strftime.c.

◆ SYSV_EXT

#define SYSV_EXT   1 /* stuff in System V ascftime routine */

Definition at line 70 of file date_strftime.c.

◆ VMS_EXT

#define VMS_EXT   1 /* include %v for VMS date format */

Definition at line 73 of file date_strftime.c.

Function Documentation

◆ date_strftime()

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

Definition at line 807 of file date_strftime.c.

References date_strftime_with_tmx().

Referenced by date_strftime_alloc().

◆ date_strftime_with_tmx()

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

◆ getenv()

char* getenv ( )

◆ malloc()

void* malloc ( )

◆ max()

static int max ( int  a,
int  b 
)
inlinestatic

◆ min()

static int min ( int  a,
int  b 
)
inlinestatic

◆ realloc()

void* realloc ( )

◆ strchr()

char* strchr ( )

Referenced by date_strftime_with_tmx().