1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2004-05-14 16:35:30 +00:00
parent 0cf6e773be
commit 58f3410e53
3 changed files with 19 additions and 3 deletions

View file

@ -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.

10
range.c
View file

@ -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);
}
}

View file

@ -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;