Ruby: ext/date/date_strptime.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
date_strptime.c File Reference
`#include "ruby.h"`
`#include "ruby/encoding.h"`
`#include "ruby/re.h"`
`#include <ctype.h>`

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
VALUE | date_zone_to_diff (VALUE)
VALUE | date__strptime (const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)

## Macro Definition Documentation

## ◆ del_hash

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

Definition at line 121 of file date_strptime.c.

## ◆ f_add

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

Definition at line 39 of file date_strptime.c.

## ◆ f_aref

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

Definition at line 53 of file date_strptime.c.

## ◆ f_div

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

Definition at line 42 of file date_strptime.c.

## ◆ f_end

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

Definition at line 54 of file date_strptime.c.

## ◆ f_expt

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

Definition at line 45 of file date_strptime.c.

## ◆ f_ge_p

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

Definition at line 50 of file date_strptime.c.

## ◆ f_gt_p

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

Definition at line 48 of file date_strptime.c.

## ◆ f_idiv

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

Definition at line 43 of file date_strptime.c.

## ◆ f_le_p

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

Definition at line 49 of file date_strptime.c.

## ◆ f_lt_p

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

Definition at line 47 of file date_strptime.c.

## ◆ f_match

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

Definition at line 52 of file date_strptime.c.

## ◆ f_mod

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

Definition at line 44 of file date_strptime.c.

## ◆ f_mul

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

Definition at line 41 of file date_strptime.c.

## ◆ f_negate

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

Definition at line 38 of file date_strptime.c.

## ◆ f_sub

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

Definition at line 40 of file date_strptime.c.

## ◆ fail

#define fail | ( |  | ) |

Value:
do { \
set_hash("_fail", Qtrue); \
return 0; \
} while (0)
Qtrue
#define Qtrue
Definition: special_consts.h:52

Definition at line 123 of file date_strptime.c.

## ◆ fail_p

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

Definition at line 129 of file date_strptime.c.

## ◆ issign

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

Definition at line 56 of file date_strptime.c.

## ◆ NUM_PATTERN_P

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

Definition at line 75 of file date_strptime.c.

## ◆ READ_DIGITS

#define READ_DIGITS | ( |  | n,
|  |  | w
| ) |  |

Value:
do { \
size_t l; \
l = read_digits(&str[si], &n, w); \
if (l == 0) \
fail(); \
si += l; \
} while (0)
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18

Definition at line 131 of file date_strptime.c.

## ◆ READ_DIGITS_MAX

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

Definition at line 140 of file date_strptime.c.

## ◆ recur

#define recur | ( |  | fmt | ) |

Value:
do { \
size_t l; \
l = date__strptime_internal(&str[si], slen - si, \
fmt, sizeof fmt - 1, hash); \
if (fail_p()) \
return 0; \
si += l; \
} while (0)
fail_p
#define fail_p()
Definition: date_strptime.c:129

Definition at line 152 of file date_strptime.c.

## ◆ ref_hash

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

Definition at line 120 of file date_strptime.c.

## ◆ set_hash

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

Definition at line 119 of file date_strptime.c.

## ◆ sizeof_array

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

Definition at line 36 of file date_strptime.c.

## Function Documentation

## ◆ date__strptime()

VALUE date__strptime | ( | const char * | str,
|  | size_t | slen,
|  | const char * | fmt,
|  | size_t | flen,
|  | VALUE | hash
| ) |  |

Definition at line 655 of file date_strptime.c.

References del_hash, f_add, f_mod, f_mul, fail_p, INT2FIX, NIL_P, Qnil, rb_usascii_str_new, ref_hash, set_hash, and str.

## ◆ date_zone_to_diff()

VALUE date_zone_to_diff | ( | VALUE | str | ) |

Definition at line 411 of file date_parse.c.

Referenced by date__parse().