Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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,
|  |  | y
| ) |  | (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,
|  |  | y
| ) |  | (rb_funcall((x), rb_intern("div"), 1, (y)))

Definition at line 27 of file date_strftime.c.

## ◆ 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);

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

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

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

## ◆ mod

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

Definition at line 28 of file date_strftime.c.

## ◆ mul

#define mul | ( |  | x,
|  |  | y
| ) |  | (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,
|  |  | y
| ) |  | (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.

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

## ◆ sub

#define sub | ( |  | x,
|  |  | y
| ) |  | (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.

rb_str_new2
#define rb_str_new2
Definition: intern.h:903
INT2FIX
#define INT2FIX(i)
Definition: ruby.h:263
snprintf
int snprintf(char *__restrict, size_t, const char *__restrict,...) __attribute__((__format__(__printf__
ERANGE
#define ERANGE
Definition: rb_mjit_min_header-2.7.0.h:10971
UPPER
@ UPPER
Definition: strftime.c:160
else
else
Definition: rb_mjit_min_header-2.7.0.h:13246
tmx
Definition: date_tmx.h:24
FIX2LONG
#define FIX2LONG(x)
Definition: ruby.h:394
LEFT
@ LEFT
Definition: strftime.c:160
if
if((ID)(DISPID) nameid !=nameid)
Definition: win32ole.c:357
rb_str_format
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:204
i
uint32_t i
Definition: rb_mjit_min_header-2.7.0.h:5464
BIT_OF
#define BIT_OF(n)
strlcpy
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
Definition: strlcpy.c:29
FIXNUM_P
#define FIXNUM_P(f)
Definition: ruby.h:396
DateData::s
struct SimpleDateData s
Definition: date_core.c:293
StringValueCStr
#define StringValueCStr(v)
Definition: ruby.h:604
fmt
const VALUE int int int int int int VALUE char * fmt
Definition: rb_mjit_min_header-2.7.0.h:6462
err
int err
Definition: win32.c:135
DateData::flags
unsigned flags
Definition: date_core.c:292