#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.
|
#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) |
|
◆ add
#define add |
( |
|
x, |
|
|
|
y |
|
) |
| (rb_funcall((x), '+', 1, (y))) |
◆ BIT_OF
#define BIT_OF |
( |
|
n | ) |
(1U<<(n)) |
◆ div
◆ FILL_PADDING
#define FILL_PADDING |
( |
|
i | ) |
|
Value:do { \
NEEDS(precision); \
memset(
s, padding ? padding :
' ', precision - (i)); \
s += precision - (i); \
} \
else { \
NEEDS(i); \
} \
} while (0);
◆ FLAG_FOUND
Value:do { \
goto unknown; \
} while (0)
◆ FMT
#define FMT |
( |
|
def_pad, |
|
|
|
def_prec, |
|
|
|
fmt, |
|
|
|
val |
|
) |
| |
Value:do { \
int l; \
if (precision <= 0) precision = (def_prec); \
((padding == '0' || (!padding && (def_pad) == '0')) ? \
"%0*"fmt : "%*"fmt), \
s += l; \
} while (0)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
◆ FMTV
#define FMTV |
( |
|
def_pad, |
|
|
|
def_prec, |
|
|
|
fmt, |
|
|
|
val |
|
) |
| |
Value:do { \
FMT((def_pad), (def_prec),
"l"fmt,
FIX2LONG(tmp)); \
} \
else { \
VALUE args[2], result; \
size_t l; \
if (precision <= 0) precision = (def_prec); \
if (padding == '0' || (!padding && (def_pad) == '0')) \
else \
result = rb_str_format(2, args,
rb_str_new2("%*"fmt)); \
if ((
size_t)(endp - s) <= l) \
s += l; \
} \
} while (0)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
VALUE rb_str_format(int, const VALUE *, VALUE)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
#define StringValueCStr(v)
◆ mod
#define mod |
( |
|
x, |
|
|
|
y |
|
) |
| (rb_funcall((x), '%', 1, (y))) |
◆ mul
#define mul |
( |
|
x, |
|
|
|
y |
|
) |
| (rb_funcall((x), '*', 1, (y))) |
◆ NEEDS
#define NEEDS |
( |
|
n | ) |
do if (s >= endp || (n) >= endp - s - 1) goto err; while (0) |
◆ quo
◆ range
#define range |
( |
|
low, |
|
|
|
item, |
|
|
|
hi |
|
) |
| (item) |
◆ STRFTIME
Value:do { \
i = date_strftime_with_tmx(
s, endp -
s, (fmt),
tmx); \
if (!i) return 0; \
if (start + maxsize <
s + precision) { \
errno = ERANGE; \
return 0; \
} \
memmove(
s + precision - i,
s, i); \
memset(
s, padding ? padding :
' ', precision - i); \
s += precision; \
} \
} while (0)
◆ sub
#define sub |
( |
|
x, |
|
|
|
y |
|
) |
| (rb_funcall((x), '-', 1, (y))) |
◆ date_strftime()
size_t date_strftime |
( |
char * |
s, |
|
|
size_t |
maxsize, |
|
|
const char * |
format, |
|
|
const struct tmx * |
tmx |
|
) |
| |