summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-14 16:35:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-14 16:35:30 +0000
commit58f3410e53bdc62343123891e0225a710b515554 (patch)
tree2aa48325d5a89004997add9617e3e9967e5ea7c8
parent0cf6e773be4ab563decd19c6a285568e489e80ea (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--ChangeLog10
-rw-r--r--range.c10
-rw-r--r--string.c2
3 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0752750afb..bb5ff4475b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/range.c b/range.c
index 66e6070cf8..46cc6d0bc8 100644
--- a/range.c
+++ b/range.c
@@ -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);
}
}
diff --git a/string.c b/string.c
index 4bd5de968e..93ccae1790 100644
--- a/string.c
+++ b/string.c
@@ -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;