summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-25 16:03:11 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-25 16:03:11 +0000
commit3380f2ff6ed3ced7965be7f2242c95580f0a45af (patch)
treefd7fc876efc4e506e4fad17d920000678b0e5394 /ext
parent64fd7d878593f1ae226a5d041c495587b4d4ff33 (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/date/date_core.c84
1 files changed, 41 insertions, 43 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index bdb13a8752..b39bb3f89c 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -6651,57 +6651,55 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
const char *default_fmt,
void (*func)(VALUE, struct tmx *))
{
- {
- VALUE vfmt;
- const char *fmt;
- long len;
- char buffer[SMALLBUF], *buf = buffer;
- struct tmx tmx;
- VALUE str;
+ VALUE vfmt;
+ const char *fmt;
+ long len;
+ char buffer[SMALLBUF], *buf = buffer;
+ struct tmx tmx;
+ VALUE str;
- rb_scan_args(argc, argv, "01", &vfmt);
+ rb_scan_args(argc, argv, "01", &vfmt);
- if (argc < 1)
- vfmt = rb_usascii_str_new2(default_fmt);
- else {
- StringValue(vfmt);
- if (!rb_enc_str_asciicompat_p(vfmt)) {
- rb_raise(rb_eArgError,
- "format should have ASCII compatible encoding");
- }
+ if (argc < 1)
+ vfmt = rb_usascii_str_new2(default_fmt);
+ else {
+ StringValue(vfmt);
+ if (!rb_enc_str_asciicompat_p(vfmt)) {
+ rb_raise(rb_eArgError,
+ "format should have ASCII compatible encoding");
}
- fmt = RSTRING_PTR(vfmt);
- len = RSTRING_LEN(vfmt);
- (*func)(self, &tmx);
- if (memchr(fmt, '\0', len)) {
- /* Ruby string may contain \0's. */
- const char *p = fmt, *pe = fmt + len;
-
- str = rb_str_new(0, 0);
- while (p < pe) {
- len = date_strftime_alloc(&buf, p, &tmx);
- rb_str_cat(str, buf, len);
- p += strlen(p);
- if (buf != buffer) {
- xfree(buf);
- buf = buffer;
- }
- for (fmt = p; p < pe && !*p; ++p);
- if (p > fmt) rb_str_cat(str, fmt, p - fmt);
+ }
+ fmt = RSTRING_PTR(vfmt);
+ len = RSTRING_LEN(vfmt);
+ (*func)(self, &tmx);
+ if (memchr(fmt, '\0', len)) {
+ /* Ruby string may contain \0's. */
+ const char *p = fmt, *pe = fmt + len;
+
+ str = rb_str_new(0, 0);
+ while (p < pe) {
+ len = date_strftime_alloc(&buf, p, &tmx);
+ rb_str_cat(str, buf, len);
+ p += strlen(p);
+ if (buf != buffer) {
+ xfree(buf);
+ buf = buffer;
}
- rb_enc_copy(str, vfmt);
- OBJ_INFECT(str, vfmt);
- return str;
+ for (fmt = p; p < pe && !*p; ++p);
+ if (p > fmt) rb_str_cat(str, fmt, p - fmt);
}
- 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;
}
+ 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);
}
-static VALUE
+static int
gengo(VALUE jd, VALUE y, VALUE *a)
{
if (f_lt_p(jd, INT2FIX(2405160)))