#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.
Defines | |
| #define | SYSV_EXT 1 |
| #define | SUNOS_EXT 1 |
| #define | POSIX2_DATE 1 |
| #define | VMS_EXT 1 |
| #define | MAILHEADER_EXT 1 |
| #define | ISO_DATE_EXT 1 |
| #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) |
| #define add | ( | x, | |||
| y | ) | (rb_funcall((x), '+', 1, (y))) |
Definition at line 163 of file date_strftime.c.
Referenced by gmtimew_noleapsecond(), rb_strftime_with_timespec(), time_mdump(), time_mload(), timegmw_noleapsecond(), timew_out_of_timet_range(), and vtm_add_offset().
| #define adddecl | ( | stuff | ) | stuff |
Definition at line 93 of file date_strftime.c.
| #define BIT_OF | ( | n | ) | (1U<<(n)) |
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define div | ( | x, | |||
| y | ) | (rb_funcall((x), rb_intern("div"), 1, (y))) |
Definition at line 167 of file date_strftime.c.
Referenced by BigDecimal_div(), BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_mod(), date_strftime_with_tmx(), fix_divide(), fix_divmod(), fixdivmod(), flo_divmod(), flodivmod(), rb_big_divide(), rb_big_divmod(), rb_strftime_with_timespec(), time_mdump(), VpMidRound(), and VpVtoD().
| #define FILL_PADDING | ( | i | ) |
do { \ if (!(flags & BIT_OF(LEFT)) && precision > (i)) { \ NEEDS(precision); \ memset(s, padding ? padding : ' ', precision - (i)); \ s += precision - (i); \ } \ else { \ NEEDS(i); \ } \ } while (0);
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define FLAG_FOUND | ( | ) |
do { \ if (precision > 0 || flags & (BIT_OF(LOCALE_E)|BIT_OF(LOCALE_O))) \ goto unknown; \ } while (0)
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define FMT | ( | def_pad, | |||
| def_prec, | |||||
| fmt, | |||||
| val | ) |
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)
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define FMTV | ( | def_pad, | |||
| def_prec, | |||||
| fmt, | |||||
| val | ) |
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)
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define ISO_DATE_EXT 1 |
Definition at line 75 of file date_strftime.c.
| #define MAILHEADER_EXT 1 |
Definition at line 74 of file date_strftime.c.
| #define mod | ( | x, | |||
| y | ) | (rb_funcall((x), '%', 1, (y))) |
Definition at line 168 of file date_strftime.c.
Referenced by BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_mod(), bigdivmod(), date_strftime_with_tmx(), fix_divmod(), fix_mod(), fixdivmod(), flo_divmod(), flodivmod(), gmtimew_noleapsecond(), guess_local_offset(), rb_ary_flatten(), rb_ary_flatten_bang(), rb_big_divmod(), rb_module_s_alloc(), rb_str_sum(), rb_strftime_with_timespec(), ruby_float_mod(), time_mdump(), time_round(), and vtm2tm_noyear().
| #define mul | ( | x, | |||
| y | ) | (rb_funcall((x), '*', 1, (y))) |
Definition at line 165 of file date_strftime.c.
Referenced by date_strftime_with_tmx(), gmtimew_noleapsecond(), rb_strftime_with_timespec(), time_round(), timegmw_noleapsecond(), and timew_out_of_timet_range().
| #define NEEDS | ( | n | ) | do if (s >= endp || (n) >= endp - s - 1) goto err; while (0) |
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define POSIX2_DATE 1 |
Definition at line 72 of file date_strftime.c.
| #define quo | ( | x, | |||
| y | ) | (rb_funcall((x), rb_intern("quo"), 1, (y))) |
Definition at line 166 of file date_strftime.c.
Referenced by rb_time_unmagnify_to_float(), time_mload(), time_round(), and time_subsec().
| #define range | ( | low, | |||
| item, | |||||
| hi | ) | max((low), min((item), (hi))) |
Definition at line 125 of file date_strftime.c.
Referenced by date_strftime_with_tmx(), enc_succ_alnum_char(), iso2022jp_check_conv(), rb_range_new(), rb_reg_adjust_startpos(), rb_reg_search(), and rb_strftime_with_timespec().
| #define STRFTIME | ( | fmt | ) |
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)
Referenced by date_strftime_with_tmx(), and rb_strftime_with_timespec().
| #define sub | ( | x, | |||
| y | ) | (rb_funcall((x), '-', 1, (y))) |
Definition at line 164 of file date_strftime.c.
Referenced by rb_str_index_m(), rb_str_rindex_m(), rb_str_substr(), rb_strftime_with_timespec(), time_round(), timegmw_noleapsecond(), timelocalw(), and vtm_add_offset().
| #define SUNOS_EXT 1 |
Definition at line 71 of file date_strftime.c.
| #define SYSV_EXT 1 |
Definition at line 70 of file date_strftime.c.
| #define VMS_EXT 1 |
Definition at line 73 of file date_strftime.c.
| 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().
| static size_t date_strftime_with_tmx | ( | char * | s, | |
| size_t | maxsize, | |||
| const char * | format, | |||
| const struct tmx * | tmx | |||
| ) | [static] |
Definition at line 173 of file date_strftime.c.
References args, BIT_OF, div, err, errno, FILL_PADDING, FIX2LONG, FIXNUM_P, FLAG_FOUND, FMT, FMTV, INT2FIX, ISLOWER, ISUPPER, mod, mul, NEEDS, NULL, NUM2INT, NUM2LONG(), range, rb_funcall(), rb_intern, rb_str_format(), rb_str_new2, result, 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, TOLOWER, and TOUPPER.
Referenced by date_strftime().
| char* getenv | ( | ) |
| void* malloc | ( | ) |
| static int max | ( | int | a, | |
| int | b | |||
| ) | [inline, static] |
Definition at line 149 of file date_strftime.c.
Referenced by econv_putback(), old_thread_select(), optimize_node_left(), rand_int(), rand_range(), random_rand(), ruby_setenv(), and tr_trans().
| static int min | ( | int | a, | |
| int | b | |||
| ) | [inline, static] |
Definition at line 133 of file date_strftime.c.
Referenced by date_zone_to_diff(), datetime_s_civil(), datetime_s_commercial(), datetime_s_jd(), datetime_s_ordinal(), get_c_civil(), get_c_time(), mktime_do(), parse_time2_cb(), rand_range(), rb_enc_mbclen(), rb_w32_fd_copy(), rb_w32_write(), rt_rewrite_frags(), and vtm_add_offset().
| void* realloc | ( | ) |
| char* strchr | ( | ) |
1.6.1