summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-14 16:39:15 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-14 16:39:15 +0000
commitef8ec126af4ab0fba0bff708e2aef1ed4867fc60 (patch)
tree489d3ac0bc9d172e33965204600726fd5d4dbbef
parent15169a6f8f4126946b8cced042acde82fd2dc8c8 (diff)
downloadruby-ef8ec126af4ab0fba0bff708e2aef1ed4867fc60.tar.gz
ruby-ef8ec126af4ab0fba0bff708e2aef1ed4867fc60.tar.xz
ruby-ef8ec126af4ab0fba0bff708e2aef1ed4867fc60.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@6313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog20
-rw-r--r--array.c2
-rw-r--r--eval.c41
-rw-r--r--object.c4
-rw-r--r--range.c10
-rw-r--r--string.c2
-rw-r--r--time.c21
-rw-r--r--variable.c2
8 files changed, 54 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 63f7c6f84..348f48ded 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/array.c b/array.c
index d779f279a..53c50d4bb 100644
--- a/array.c
+++ b/array.c
@@ -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;
}
diff --git a/eval.c b/eval.c
index 56adf0617..97369021a 100644
--- a/eval.c
+++ b/eval.c
@@ -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);
}
diff --git a/object.c b/object.c
index 95d00a973..2fb2bd063 100644
--- a/object.c
+++ b/object.c
@@ -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:
diff --git a/range.c b/range.c
index 66e6070cf..46cc6d0bc 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 c30aaf78b..fcb75821d 100644
--- a/string.c
+++ b/string.c
@@ -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;
diff --git a/time.c b/time.c
index 1a7444c66..abf2967b3 100644
--- a/time.c
+++ b/time.c
@@ -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 24cbf21c0..cb972ba81 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);
}
}
}