Ruby  2.5.0dev(2017-10-22revision60238)
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>

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

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)))

Definition at line 23 of file date_strftime.c.

◆ BIT_OF

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

◆ div

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

Definition at line 27 of file date_strftime.c.

Referenced by rb_big_divmod(), VpMidRound(), and VpVtoD().

◆ 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);
Definition: strftime.c:160
unsigned flags
Definition: date_core.c:283
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:284

◆ FLAG_FOUND

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

◆ 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: zonetab.h:883
Definition: strftime.c:160
unsigned flags
Definition: date_core.c:283
#define val
#define snprintf
Definition: subst.h:6
int err
Definition: win32.c:135
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:284

◆ 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: zonetab.h:883
Definition: strftime.c:160
unsigned flags
Definition: date_core.c:283
#define FIXNUM_P(f)
Definition: ruby.h:365
#define val
#define rb_str_new2
Definition: intern.h:835
int err
Definition: win32.c:135
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:464
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
Definition: strlcpy.c:29
#define StringValueCStr(v)
Definition: ruby.h:571
#define INT2FIX(i)
Definition: ruby.h:232
#define FIX2LONG(x)
Definition: ruby.h:363
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:284

◆ mod

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

Definition at line 28 of file date_strftime.c.

Referenced by rb_big_divmod(), rb_mod_const_of(), and ruby_float_mod().

◆ mul

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

Definition at line 25 of file date_strftime.c.

◆ NEEDS

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

◆ quo

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

Definition at line 26 of file date_strftime.c.

◆ range

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

Definition at line 21 of file date_strftime.c.

Referenced by onig_search_gpos(), rb_range_new(), and rb_reg_adjust_startpos().

◆ STRFTIME

#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)
Definition: date_tmx.h:24
Definition: strftime.c:160
unsigned flags
Definition: date_core.c:283
#define BIT_OF(n)
struct SimpleDateData s
Definition: date_core.c:284

◆ sub

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

Definition at line 24 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 628 of file date_strftime.c.