Ruby  2.0.0p451(2014-02-24revision45167)
Macros | Functions | Variables
date_strptime.c File Reference
#include "ruby.h"
#include "ruby/encoding.h"
#include "ruby/re.h"
#include <ctype.h>
Include dependency graph for date_strptime.c:

Go to the source code of this file.

Macros

#define sizeof_array(o)   (sizeof o / sizeof o[0])
 
#define f_negate(x)   rb_funcall(x, rb_intern("-@"), 0)
 
#define f_add(x, y)   rb_funcall(x, '+', 1, y)
 
#define f_sub(x, y)   rb_funcall(x, '-', 1, y)
 
#define f_mul(x, y)   rb_funcall(x, '*', 1, y)
 
#define f_div(x, y)   rb_funcall(x, '/', 1, y)
 
#define f_idiv(x, y)   rb_funcall(x, rb_intern("div"), 1, y)
 
#define f_mod(x, y)   rb_funcall(x, '%', 1, y)
 
#define f_expt(x, y)   rb_funcall(x, rb_intern("**"), 1, y)
 
#define f_lt_p(x, y)   rb_funcall(x, '<', 1, y)
 
#define f_gt_p(x, y)   rb_funcall(x, '>', 1, y)
 
#define f_le_p(x, y)   rb_funcall(x, rb_intern("<="), 1, y)
 
#define f_ge_p(x, y)   rb_funcall(x, rb_intern(">="), 1, y)
 
#define f_match(r, s)   rb_funcall(r, rb_intern("match"), 1, s)
 
#define f_aref(o, i)   rb_funcall(o, rb_intern("[]"), 1, i)
 
#define f_end(o, i)   rb_funcall(o, rb_intern("end"), 1, i)
 
#define issign(c)   ((c) == '-' || (c) == '+')
 
#define NUM_PATTERN_P()   num_pattern_p(&fmt[fi + 1])
 
#define set_hash(k, v)   rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
 
#define ref_hash(k)   rb_hash_aref(hash, ID2SYM(rb_intern(k)))
 
#define del_hash(k)   rb_hash_delete(hash, ID2SYM(rb_intern(k)))
 
#define fail()
 
#define fail_p()   (!NIL_P(ref_hash("_fail")))
 
#define READ_DIGITS(n, w)
 
#define READ_DIGITS_MAX(n)   READ_DIGITS(n, LONG_MAX)
 
#define recur(fmt)
 

Functions

static int num_pattern_p (const char *s)
 
static long read_digits (const char *s, VALUE *n, size_t width)
 
static int valid_range_p (VALUE v, int a, int b)
 
VALUE date_zone_to_diff (VALUE)
 
static size_t date__strptime_internal (const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
 
VALUE date__strptime (const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
 

Variables

static const char * day_names []
 
static const char * month_names []
 
static const char * merid_names []
 
static const char * extz_pats []
 

Macro Definition Documentation

#define del_hash (   k)    rb_hash_delete(hash, ID2SYM(rb_intern(k)))

Definition at line 116 of file date_strptime.c.

Referenced by date__strptime().

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

Definition at line 39 of file date_strptime.c.

Referenced by date__strptime().

#define f_aref (   o,
  i 
)    rb_funcall(o, rb_intern("[]"), 1, i)

Definition at line 53 of file date_strptime.c.

#define f_div (   x,
 
)    rb_funcall(x, '/', 1, y)

Definition at line 42 of file date_strptime.c.

#define f_end (   o,
  i 
)    rb_funcall(o, rb_intern("end"), 1, i)

Definition at line 54 of file date_strptime.c.

Referenced by date__strptime_internal().

#define f_expt (   x,
 
)    rb_funcall(x, rb_intern("**"), 1, y)

Definition at line 45 of file date_strptime.c.

Referenced by date__strptime_internal().

#define f_ge_p (   x,
 
)    rb_funcall(x, rb_intern(">="), 1, y)

Definition at line 50 of file date_strptime.c.

Referenced by date__strptime_internal().

#define f_gt_p (   x,
 
)    rb_funcall(x, '>', 1, y)

Definition at line 48 of file date_strptime.c.

Referenced by valid_range_p().

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

Definition at line 43 of file date_strptime.c.

#define f_le_p (   x,
 
)    rb_funcall(x, rb_intern("<="), 1, y)

Definition at line 49 of file date_strptime.c.

#define f_lt_p (   x,
 
)    rb_funcall(x, '<', 1, y)

Definition at line 47 of file date_strptime.c.

Referenced by valid_range_p().

#define f_match (   r,
 
)    rb_funcall(r, rb_intern("match"), 1, s)

Definition at line 52 of file date_strptime.c.

Referenced by date__strptime_internal().

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

Definition at line 44 of file date_strptime.c.

Referenced by date__strptime().

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

Definition at line 41 of file date_strptime.c.

Referenced by date__strptime().

#define f_negate (   x)    rb_funcall(x, rb_intern("-@"), 0)

Definition at line 38 of file date_strptime.c.

Referenced by date__strptime_internal().

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

Definition at line 40 of file date_strptime.c.

#define fail ( )
#define fail_p ( )    (!NIL_P(ref_hash("_fail")))

Definition at line 124 of file date_strptime.c.

Referenced by date__strptime().

#define issign (   c)    ((c) == '-' || (c) == '+')

Definition at line 56 of file date_strptime.c.

Referenced by date__strptime_internal().

#define NUM_PATTERN_P ( )    num_pattern_p(&fmt[fi + 1])

Definition at line 75 of file date_strptime.c.

Referenced by date__strptime_internal().

#define READ_DIGITS (   n,
 
)
Value:
{ \
size_t l; \
l = read_digits(&str[si], &n, w); \
if (l == 0) \
fail(); \
si += l; \
}
#define fail()
static long read_digits(const char *s, VALUE *n, size_t width)
Definition: date_strptime.c:78
if(c== ')') lex_state
Definition: ripper.y:7588

Definition at line 126 of file date_strptime.c.

Referenced by date__strptime_internal().

#define READ_DIGITS_MAX (   n)    READ_DIGITS(n, LONG_MAX)

Definition at line 135 of file date_strptime.c.

Referenced by date__strptime_internal().

#define recur (   fmt)
Value:
{ \
size_t l; \
l = date__strptime_internal(&str[si], slen - si, \
fmt, sizeof fmt - 1, hash); \
return 0; \
si += l; \
}
#define fail_p()
return
Definition: ripper.y:7641
static size_t date__strptime_internal(const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
static unsigned int hash(const char *str, unsigned int len)
Definition: lex.c:56
if(c== ')') lex_state
Definition: ripper.y:7588

Definition at line 147 of file date_strptime.c.

Referenced by class_instance_method_list(), date__strptime_internal(), rb_mod_const_defined(), rb_mod_const_get(), rb_obj_methods(), and rb_obj_singleton_methods().

#define ref_hash (   k)    rb_hash_aref(hash, ID2SYM(rb_intern(k)))

Definition at line 115 of file date_strptime.c.

Referenced by date__strptime().

#define set_hash (   k,
  v 
)    rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)

Definition at line 114 of file date_strptime.c.

Referenced by date__strptime(), and date__strptime_internal().

#define sizeof_array (   o)    (sizeof o / sizeof o[0])

Definition at line 36 of file date_strptime.c.

Referenced by date__strptime_internal().

Function Documentation

VALUE date__strptime ( const char *  str,
size_t  slen,
const char *  fmt,
size_t  flen,
VALUE  hash 
)
static size_t date__strptime_internal ( const char *  str,
size_t  slen,
const char *  fmt,
size_t  flen,
VALUE  hash 
)
static
VALUE date_zone_to_diff ( VALUE  )
static int num_pattern_p ( const char *  s)
static

Definition at line 59 of file date_strptime.c.

References strchr().

static long read_digits ( const char *  s,
VALUE n,
size_t  width 
)
static

Definition at line 78 of file date_strptime.c.

References ALLOCA_N, CHAR_BIT, LONG2NUM, rb_cstr_to_inum(), and v.

static int valid_range_p ( VALUE  v,
int  a,
int  b 
)
static

Definition at line 138 of file date_strptime.c.

References f_gt_p, f_lt_p, FIX2INT, FIXNUM_P, and INT2NUM.

Referenced by date__strptime_internal().

Variable Documentation

const char* day_names[]
static
Initial value:
= {
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat"
}

Definition at line 10 of file date_strptime.c.

Referenced by date__strptime_internal().

const char* extz_pats[]
static
Initial value:
= {
":z",
"::z",
":::z"
}

Definition at line 30 of file date_strptime.c.

Referenced by date__strptime_internal().

const char* merid_names[]
static
Initial value:
= {
"am", "pm",
"a.m.", "p.m."
}

Definition at line 25 of file date_strptime.c.

Referenced by date__strptime_internal().

const char* month_names[]
static
Initial value:
= {
"January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}

Definition at line 17 of file date_strptime.c.

Referenced by date__strptime_internal().