* ext/date/date_core.c (date_strftime_internal): removed meaningless braces.
* ext/date/date_core.c (gengo): the value should be int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
64fd7d8785
commit
3380f2ff6e
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jun 26 01:00:15 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* ext/date/date_core.c (date_strftime_internal): removed meaningless braces.
|
||||||
|
* ext/date/date_core.c (gengo): the value should be int.
|
||||||
|
|
||||||
Sat Jun 25 23:45:30 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
Sat Jun 25 23:45:30 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_search_superclass): avoid control frame
|
* vm_insnhelper.c (vm_search_superclass): avoid control frame
|
||||||
|
@ -6651,57 +6651,55 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
|
|||||||
const char *default_fmt,
|
const char *default_fmt,
|
||||||
void (*func)(VALUE, struct tmx *))
|
void (*func)(VALUE, struct tmx *))
|
||||||
{
|
{
|
||||||
{
|
VALUE vfmt;
|
||||||
VALUE vfmt;
|
const char *fmt;
|
||||||
const char *fmt;
|
long len;
|
||||||
long len;
|
char buffer[SMALLBUF], *buf = buffer;
|
||||||
char buffer[SMALLBUF], *buf = buffer;
|
struct tmx tmx;
|
||||||
struct tmx tmx;
|
VALUE str;
|
||||||
VALUE str;
|
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", &vfmt);
|
rb_scan_args(argc, argv, "01", &vfmt);
|
||||||
|
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
vfmt = rb_usascii_str_new2(default_fmt);
|
vfmt = rb_usascii_str_new2(default_fmt);
|
||||||
else {
|
else {
|
||||||
StringValue(vfmt);
|
StringValue(vfmt);
|
||||||
if (!rb_enc_str_asciicompat_p(vfmt)) {
|
if (!rb_enc_str_asciicompat_p(vfmt)) {
|
||||||
rb_raise(rb_eArgError,
|
rb_raise(rb_eArgError,
|
||||||
"format should have ASCII compatible encoding");
|
"format should have ASCII compatible encoding");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fmt = RSTRING_PTR(vfmt);
|
}
|
||||||
len = RSTRING_LEN(vfmt);
|
fmt = RSTRING_PTR(vfmt);
|
||||||
(*func)(self, &tmx);
|
len = RSTRING_LEN(vfmt);
|
||||||
if (memchr(fmt, '\0', len)) {
|
(*func)(self, &tmx);
|
||||||
/* Ruby string may contain \0's. */
|
if (memchr(fmt, '\0', len)) {
|
||||||
const char *p = fmt, *pe = fmt + len;
|
/* Ruby string may contain \0's. */
|
||||||
|
const char *p = fmt, *pe = fmt + len;
|
||||||
|
|
||||||
str = rb_str_new(0, 0);
|
str = rb_str_new(0, 0);
|
||||||
while (p < pe) {
|
while (p < pe) {
|
||||||
len = date_strftime_alloc(&buf, p, &tmx);
|
len = date_strftime_alloc(&buf, p, &tmx);
|
||||||
rb_str_cat(str, buf, len);
|
rb_str_cat(str, buf, len);
|
||||||
p += strlen(p);
|
p += strlen(p);
|
||||||
if (buf != buffer) {
|
if (buf != buffer) {
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
buf = buffer;
|
buf = buffer;
|
||||||
}
|
|
||||||
for (fmt = p; p < pe && !*p; ++p);
|
|
||||||
if (p > fmt) rb_str_cat(str, fmt, p - fmt);
|
|
||||||
}
|
}
|
||||||
rb_enc_copy(str, vfmt);
|
for (fmt = p; p < pe && !*p; ++p);
|
||||||
OBJ_INFECT(str, vfmt);
|
if (p > fmt) rb_str_cat(str, fmt, p - fmt);
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
len = date_strftime_alloc(&buf, fmt, &tmx);
|
|
||||||
|
|
||||||
str = rb_str_new(buf, len);
|
|
||||||
if (buf != buffer) xfree(buf);
|
|
||||||
rb_enc_copy(str, vfmt);
|
rb_enc_copy(str, vfmt);
|
||||||
OBJ_INFECT(str, vfmt);
|
OBJ_INFECT(str, vfmt);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
len = date_strftime_alloc(&buf, fmt, &tmx);
|
||||||
|
|
||||||
|
str = rb_str_new(buf, len);
|
||||||
|
if (buf != buffer) xfree(buf);
|
||||||
|
rb_enc_copy(str, vfmt);
|
||||||
|
OBJ_INFECT(str, vfmt);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6972,7 +6970,7 @@ d_lite_httpdate(VALUE self)
|
|||||||
return strftimev("%a, %d %b %Y %T GMT", dup, set_tmx);
|
return strftimev("%a, %d %b %Y %T GMT", dup, set_tmx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static int
|
||||||
gengo(VALUE jd, VALUE y, VALUE *a)
|
gengo(VALUE jd, VALUE y, VALUE *a)
|
||||||
{
|
{
|
||||||
if (f_lt_p(jd, INT2FIX(2405160)))
|
if (f_lt_p(jd, INT2FIX(2405160)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user