diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-14 16:35:30 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-14 16:35:30 +0000 |
commit | 58f3410e53bdc62343123891e0225a710b515554 (patch) | |
tree | 2aa48325d5a89004997add9617e3e9967e5ea7c8 | |
parent | 0cf6e773be4ab563decd19c6a285568e489e80ea (diff) |
* 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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | range.c | 10 | ||||
-rw-r--r-- | string.c | 2 |
3 files changed, 19 insertions, 3 deletions
@@ -1,3 +1,13 @@ +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 18:39:25 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/lib/tk/canvas.rb: improve coords support for canvas items. @@ -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); } } @@ -164,7 +164,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; |