diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-14 16:39:15 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-14 16:39:15 +0000 |
commit | 6a60393280046a4991da8a415a77c60c7be240b5 (patch) | |
tree | 489d3ac0bc9d172e33965204600726fd5d4dbbef | |
parent | 35ae7c90450157e1d8d415be819da40c9c1289a6 (diff) | |
download | ruby-6a60393280046a4991da8a415a77c60c7be240b5.tar.gz |
* range.c (range_each_func): terminates loop if generating value
is same to @end. [ruby-talk:100269]
* string.c (rb_str_new4): should not reuse frozen shared string if
the original is not an instance of String. [ruby-talk:100193]
* time.c (time_mdump): preserve GMT bit in the marshal data.
[ruby-talk:100213]
* eval.c (is_defined): do not protect exception during receiver
evaluation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | eval.c | 41 | ||||
-rw-r--r-- | object.c | 4 | ||||
-rw-r--r-- | range.c | 10 | ||||
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | time.c | 21 | ||||
-rw-r--r-- | variable.c | 2 |
8 files changed, 54 insertions, 48 deletions
@@ -1,3 +1,18 @@ +Sat May 15 01:33:12 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * range.c (range_each_func): terminates loop if generating value + is same to @end. [ruby-talk:100269] + +Fri May 14 22:08:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * string.c (rb_str_new4): should not reuse frozen shared string if + the original is not an instance of String. [ruby-talk:100193] + +Fri May 14 21:29:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * time.c (time_mdump): preserve GMT bit in the marshal data. + [ruby-talk:100213] + Fri May 14 18:37:49 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/lib/tk/canvas.rb: improve coords support for canvas @@ -58,6 +73,11 @@ Wed May 12 11:51:08 2004 Dave Thomas <dave@pragprog.com> * class.c (rb_obj_singleton_methods): fix rdoc +Tue May 11 07:09:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (is_defined): do not protect exception during receiver + evaluation. + Mon May 10 22:28:14 2004 Minero Aoki <aamine@loveruby.net> * lib/net/protocol.rb (each_crlf_line): remove junk line. @@ -227,9 +227,9 @@ rb_values_new2(n, elts) val = ary_new(rb_cValues, n); if (n > 0 && elts) { + RARRAY(val)->len = n; MEMCPY(RARRAY(val)->ptr, elts, VALUE, n); } - RARRAY(val)->len = n; return val; } @@ -2225,15 +2225,7 @@ is_defined(self, node, buf) val = self; if (node->nd_recv == (NODE *)1) goto check_bound; case NODE_CALL: - PUSH_TAG(PROT_NONE); - if ((state = EXEC_TAG()) == 0) { - val = rb_eval(self, node->nd_recv); - } - POP_TAG(); - if (state) { - ruby_errinfo = Qnil; - return 0; - } + val = rb_eval(self, node->nd_recv); check_bound: { int call = nd_type(node)==NODE_CALL; @@ -2324,26 +2316,16 @@ is_defined(self, node, buf) break; case NODE_COLON2: - PUSH_TAG(PROT_NONE); - if ((state = EXEC_TAG()) == 0) { - val = rb_eval(self, node->nd_head); - } - POP_TAG(); - if (state) { - ruby_errinfo = Qnil; - return 0; - } - else { - switch (TYPE(val)) { - case T_CLASS: - case T_MODULE: - if (rb_const_defined_from(val, node->nd_mid)) - return "constant"; - break; - default: - if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) { - return "method"; - } + val = rb_eval(self, node->nd_head); + switch (TYPE(val)) { + case T_CLASS: + case T_MODULE: + if (rb_const_defined_from(val, node->nd_mid)) + return "constant"; + break; + default: + if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) { + return "method"; } } break; @@ -4809,6 +4791,7 @@ rb_yield_values(n, va_alist) for (i=0; i<n; i++) { RARRAY(val)->ptr[i] = va_arg(args, VALUE); } + RARRAY(val)->len = n; va_end(args); return rb_yield_0(val, 0, 0, 0, Qtrue); } @@ -208,9 +208,7 @@ init_copy(dest, obj) } RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR); RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT); - if (FL_TEST(obj, FL_EXIVAR)) { - rb_copy_generic_ivar(dest, obj); - } + rb_copy_generic_ivar(dest, obj); rb_gc_copy_finalizer(dest, obj); switch (TYPE(obj)) { case T_OBJECT: @@ -155,10 +155,13 @@ static int r_le(a, b) VALUE a, b; { + int c; VALUE r = rb_funcall(a, id_cmp, 1, b); if (NIL_P(r)) return Qfalse; - if (rb_cmpint(r, a, b) <= 0) return Qtrue; + c = rb_cmpint(r, a, b); + if (c == 0) return INT2FIX(0); + if (c < 0) return Qtrue; return Qfalse; } @@ -247,6 +250,8 @@ range_each_func(range, func, v, e, arg) VALUE v, e; void *arg; { + int c; + if (EXCL(range)) { while (r_lt(v, e)) { (*func)(v, arg); @@ -254,8 +259,9 @@ range_each_func(range, func, v, e, arg) } } else { - while (r_le(v, e)) { + while (RTEST(c = r_le(v, e))) { (*func)(v, arg); + if (c == INT2FIX(0)) break; v = rb_funcall(v, id_succ, 0, 0); } } @@ -163,7 +163,7 @@ rb_str_new4(orig) if (OBJ_FROZEN(orig)) return orig; klass = rb_obj_class(orig); - if (FL_TEST(orig, ELTS_SHARED) && RSTRING(orig)->aux.shared) { + if (FL_TEST(orig, ELTS_SHARED) && (str = RSTRING(orig)->aux.shared) && klass == RBASIC(str)->klass) { long ofs; str = RSTRING(orig)->aux.shared; ofs = RSTRING(str)->len - RSTRING(orig)->len; @@ -1898,11 +1898,12 @@ time_mdump(time) t = tobj->tv.tv_sec; tm = gmtime(&t); - if ((tm->tm_year & 0x1ffff) != tm->tm_year) + if ((tm->tm_year & 0xffff) != tm->tm_year) rb_raise(rb_eArgError, "year too big to marshal"); p = 0x1 << 31 | /* 1 */ - tm->tm_year << 14 | /* 17 */ + tobj->gmt << 30 | /* 1 */ + tm->tm_year << 14 | /* 16 */ tm->tm_mon << 10 | /* 4 */ tm->tm_mday << 5 | /* 5 */ tm->tm_hour; /* 5 */ @@ -1939,10 +1940,7 @@ time_dump(argc, argv, time) rb_scan_args(argc, argv, "01", 0); str = time_mdump(time); - if (FL_TEST(time, FL_EXIVAR)) { - rb_copy_generic_ivar(str, time); - FL_SET(str, FL_EXIVAR); - } + rb_copy_generic_ivar(str, time); return str; } @@ -1960,7 +1958,7 @@ time_mload(time, str) time_t sec, usec; unsigned char *buf; struct tm tm; - int i; + int i, gmt; time_modify(time); StringValue(str); @@ -1983,7 +1981,8 @@ time_mload(time, str) } else { p &= ~(1<<31); - tm.tm_year = (p >> 14) & 0x1ffff; + gmt = (p >> 30) & 0x1; + tm.tm_year = (p >> 14) & 0xffff; tm.tm_mon = (p >> 10) & 0xf; tm.tm_mday = (p >> 5) & 0x1f; tm.tm_hour = p & 0x1f; @@ -1998,6 +1997,7 @@ time_mload(time, str) GetTimeval(time, tobj); tobj->tm_got = 0; + tobj->gmt = gmt; tobj->tv.tv_sec = sec; tobj->tv.tv_usec = usec; return time; @@ -2016,10 +2016,7 @@ time_load(klass, str) { VALUE time = time_s_alloc(klass); - if (FL_TEST(str, FL_EXIVAR)) { - rb_copy_generic_ivar(time, str); - FL_SET(time, FL_EXIVAR); - } + rb_copy_generic_ivar(time, str); time_mload(time, str); return time; } diff --git a/variable.c b/variable.c index 24cbf21c04..cb972ba81d 100644 --- a/variable.c +++ b/variable.c @@ -978,6 +978,7 @@ rb_copy_generic_ivar(clone, obj) st_table *tbl; if (!generic_iv_tbl) return; + if (!FL_TEST(obj, FL_EXIVAR)) return; if (st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) { st_table *old; @@ -987,6 +988,7 @@ rb_copy_generic_ivar(clone, obj) } else { st_add_direct(generic_iv_tbl, clone, (st_data_t)st_copy(tbl)); + FL_SET(clone, FL_EXIVAR); } } } |