[前][次][番号順一覧][スレッド一覧]

ruby-changes:5080

From: knu <ko1@a...>
Date: Sun, 25 May 2008 02:49:46 +0900 (JST)
Subject: [ruby-changes:5080] Ruby:r16575 (ruby_1_8_7): Merge from ruby_1_8.

knu	2008-05-25 02:49:34 +0900 (Sun, 25 May 2008)

  New Revision: 16575

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/enumerator.c
    branches/ruby_1_8_7/error.c
    branches/ruby_1_8_7/eval.c
    branches/ruby_1_8_7/lib/rational.rb
    branches/ruby_1_8_7/marshal.c
    branches/ruby_1_8_7/object.c
    branches/ruby_1_8_7/version.h

  Log:
    Merge from ruby_1_8.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/marshal.c?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/enumerator.c?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/eval.c?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/ChangeLog?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/object.c?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/lib/rational.rb?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/version.h?r1=16575&r2=16574&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/error.c?r1=16575&r2=16574&diff_format=u

Index: ruby_1_8_7/error.c
===================================================================
--- ruby_1_8_7/error.c	(revision 16574)
+++ ruby_1_8_7/error.c	(revision 16575)
@@ -952,18 +952,16 @@
     VALUE self, exc;
 {
     VALUE num, e;
+    ID en = rb_intern("errno");
 
-    if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) return Qfalse;
-    if (self == rb_eSystemCallError) return Qtrue;
+    if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) {
+	if (!rb_respond_to(exc, en)) return Qfalse;
+    }
+    else if (self == rb_eSystemCallError) return Qtrue;
 
-    num = rb_attr_get(exc, rb_intern("errno"));
+    num = rb_attr_get(exc, en);
     if (NIL_P(num)) {
-	VALUE klass = CLASS_OF(exc);
-
-	while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
-	    klass = (VALUE)RCLASS(klass)->super;
-	}
-	num = rb_const_get(klass, rb_intern("Errno"));
+	num = rb_funcall(exc, en, 0, 0);
     }
     e = rb_const_get(self, rb_intern("Errno"));
     if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 16574)
+++ ruby_1_8_7/ChangeLog	(revision 16575)
@@ -1,3 +1,31 @@
+Sun May 25 02:45:49 2008  Akinori MUSHA  <knu@i...>
+
+	* error.c (syserr_eqq): Use en.
+
+Sat May 24 22:32:49 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* object.c (rb_cstr_to_dbl): should clear errno before calling
+	  strtod(3).  [ruby-dev:34834]
+
+Sat May 24 22:27:44 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* marshal.c (marshal_load): should initialize arg.data used for
+	  reentrant check.  [ruby-dev:34837]
+
+Sat May 24 00:34:59 2008  Tanaka Akira  <akr@f...>
+
+	* lib/rational.rb (Rational#to_i): fix rdoc.  Rational(-7,4).to_i
+	  should be -1.
+
+Fri May 23 20:22:44 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* marshal.c (reentrant_check): check reentrance via callcc.
+	  [ruby-dev:34802]
+
+Fri May 23 16:46:28 2008  Akinori MUSHA  <knu@i...>
+
+	* enumerator.c (proc_call): Remove an unused static function.
+
 Fri May 23 13:46:09 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (cflags): commit miss.
@@ -9,6 +37,11 @@
 
 	* ext/extmk.rb: load purelib.rb only when not cross compiling.
 
+Fri May 23 08:47:02 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* error.c (syserr_eqq): === should be able to handle delegated
+	  objects as well.
+
 Fri May 23 04:22:19 2008  Hidetoshi NAGAI  <nagai@a...>
 
 	* ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak.
Index: ruby_1_8_7/enumerator.c
===================================================================
--- ruby_1_8_7/enumerator.c	(revision 16574)
+++ ruby_1_8_7/enumerator.c	(revision 16575)
@@ -25,17 +25,6 @@
 
 VALUE rb_eStopIteration;
 
-static VALUE
-proc_call(proc, args)
-    VALUE proc;
-    VALUE args;
-{
-    if (TYPE(args) != T_ARRAY) {
-	args = rb_ary_new3(1, args);
-    }
-    return rb_proc_call(proc, args);
-}
-
 struct enumerator {
     VALUE obj;
     ID    meth;
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 16574)
+++ ruby_1_8_7/version.h	(revision 16575)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2008-05-23"
+#define RUBY_RELEASE_DATE "2008-05-25"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20080523
+#define RUBY_RELEASE_CODE 20080525
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 23
+#define RUBY_RELEASE_DAY 25
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8_7/object.c
===================================================================
--- ruby_1_8_7/object.c	(revision 16574)
+++ ruby_1_8_7/object.c	(revision 16575)
@@ -2354,6 +2354,7 @@
     else {
 	while (ISSPACE(*p) || *p == '_') p++;
     }
+    errno = 0;
     d = strtod(p, &end);
     if (errno == ERANGE) {
 	OutOfRange();
Index: ruby_1_8_7/lib/rational.rb
===================================================================
--- ruby_1_8_7/lib/rational.rb	(revision 16574)
+++ ruby_1_8_7/lib/rational.rb	(revision 16575)
@@ -344,12 +344,12 @@
   # Converts the rational to an Integer.  Not the _nearest_ integer, the
   # truncated integer.  Study the following example carefully:
   #   Rational(+7,4).to_i             # -> 1
-  #   Rational(-7,4).to_i             # -> -2
+  #   Rational(-7,4).to_i             # -> -1
   #   (-1.75).to_i                    # -> -1
   #
   # In other words:
   #   Rational(-7,4) == -1.75                 # -> true
-  #   Rational(-7,4).to_i == (-1.75).to_i     # false
+  #   Rational(-7,4).to_i == (-1.75).to_i     # -> true
   #
 
 
Index: ruby_1_8_7/marshal.c
===================================================================
--- ruby_1_8_7/marshal.c	(revision 16574)
+++ ruby_1_8_7/marshal.c	(revision 16575)
@@ -84,6 +84,16 @@
 static ID s_dump_data, s_load_data, s_alloc;
 static ID s_getc, s_read, s_write, s_binmode;
 
+static void
+reentrant_check(obj, sym)
+    VALUE obj;
+    ID sym;
+{
+    if (obj && RBASIC(obj)->klass) {
+        rb_raise(rb_eRuntimeError, "%s reentered", rb_id2name(sym));
+    }
+}
+
 struct dump_arg {
     VALUE obj;
     VALUE str, dest;
@@ -505,6 +515,7 @@
 	    volatile VALUE v;
 
 	    v = rb_funcall(obj, s_mdump, 0, 0);
+	    reentrant_check(arg->str, s_mdump);
 	    w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
 	    w_object(v, arg, limit);
 	    if (ivtbl) w_ivar(0, &c_arg);
@@ -514,6 +525,7 @@
 	    VALUE v;
 
 	    v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
+	    reentrant_check(arg->str, s_dump);
 	    if (TYPE(v) != T_STRING) {
 		rb_raise(rb_eTypeError, "_dump() must return string");
 	    }
@@ -658,6 +670,7 @@
 			     rb_obj_classname(obj));
 		}
 		v = rb_funcall(obj, s_dump_data, 0);
+		reentrant_check(arg->str, s_dump_data);
 		w_class(TYPE_DATA, obj, arg, Qtrue);
 		w_object(v, arg, limit);
 	    }
@@ -690,11 +703,13 @@
 dump_ensure(arg)
     struct dump_arg *arg;
 {
+    if (RBASIC(arg->str)->klass) return; /* ignore reentrant */
     st_free_table(arg->symbols);
     st_free_table(arg->data);
     if (arg->taint) {
 	OBJ_TAINT(arg->str);
     }
+
     return 0;
 }
 
@@ -747,20 +762,21 @@
 	else port = a1;
     }
     arg.dest = 0;
+    arg.str = rb_str_buf_new(0);
+    RBASIC(arg.str)->klass = 0;
     if (!NIL_P(port)) {
 	if (!rb_respond_to(port, s_write)) {
 	  type_error:
 	    rb_raise(rb_eTypeError, "instance of IO needed");
 	}
-	arg.str = rb_str_buf_new(0);
 	arg.dest = port;
 	if (rb_respond_to(port, s_binmode)) {
 	    rb_funcall2(port, s_binmode, 0, 0);
+	    reentrant_check(arg.str, s_dump_data);
 	}
     }
     else {
-	port = rb_str_buf_new(0);
-	arg.str = port;
+	port = arg.str;
     }
 
     arg.symbols = st_init_numtable();
@@ -774,6 +790,7 @@
     w_byte(MARSHAL_MINOR, &arg);
 
     rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
+    RBASIC(arg.str)->klass = rb_cString;
 
     return port;
 }
@@ -806,6 +823,7 @@
     else {
 	VALUE src = arg->src;
 	VALUE v = rb_funcall2(src, s_getc, 0, 0);
+	reentrant_check(arg->data, s_getc);
 	if (NIL_P(v)) rb_eof_error();
 	c = (unsigned char)FIX2INT(v);
     }
@@ -886,6 +904,7 @@
 	VALUE src = arg->src;
 	VALUE n = LONG2NUM(len);
 	str = rb_funcall2(src, s_read, 1, &n);
+	reentrant_check(arg->data, s_read);
 	if (NIL_P(str)) goto too_short;
 	StringValue(str);
 	if (RSTRING(str)->len != len) goto too_short;
@@ -1236,6 +1255,7 @@
 		*ivp = Qfalse;
 	    }
 	    v = rb_funcall(klass, s_load, 1, data);
+	    reentrant_check(arg->data, s_load);
 	    r_entry(v, arg);
 	}
         break;
@@ -1259,6 +1279,7 @@
 	    r_entry(v, arg);
 	    data = r_object(arg);
 	    rb_funcall(v, s_mload, 1, data);
+	    reentrant_check(arg->data, s_mload);
 	}
         break;
 
@@ -1285,6 +1306,7 @@
 		   warn = Qfalse;
 	       }
 	       v = rb_funcall(klass, s_alloc, 0);
+	       reentrant_check(arg->data, s_alloc);
            }
 	   else {
 	       v = rb_obj_alloc(klass);
@@ -1299,6 +1321,7 @@
                         rb_class2name(klass));
            }
            rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extmod));
+	   reentrant_check(arg->data, s_load_data);
        }
        break;
 
@@ -1341,7 +1364,9 @@
 	break;
     }
     if (proc) {
-	rb_funcall(proc, rb_intern("call"), 1, v);
+	ID s_call = 
+	rb_funcall(proc, s_call, 1, v);
+	reentrant_check(arg->data, s_call);
     }
     return v;
 }
@@ -1364,6 +1389,7 @@
 load_ensure(arg)
     struct load_arg *arg;
 {
+    if (RBASIC(arg->data)->klass) return; /* ignore reentrant */
     st_free_table(arg->symbols);
     return 0;
 }
@@ -1405,6 +1431,7 @@
     }
     arg.src = port;
     arg.offset = 0;
+    arg.data = 0;
 
     major = r_byte(&arg);
     minor = r_byte(&arg);
@@ -1421,9 +1448,11 @@
 
     arg.symbols = st_init_numtable();
     arg.data   = rb_hash_new();
+    RBASIC(arg.data)->klass = 0;
     if (NIL_P(proc)) arg.proc = 0;
     else             arg.proc = proc;
     v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
+    RBASIC(arg.data)->klass = rb_cHash;
 
     return v;
 }
Index: ruby_1_8_7/eval.c
===================================================================
--- ruby_1_8_7/eval.c	(revision 16574)
+++ ruby_1_8_7/eval.c	(revision 16575)
@@ -5526,7 +5526,7 @@
     POP_TAG();
     retval = prot_tag ? prot_tag->retval : Qnil;	/* save retval */
     if (!thread_no_ensure()) {
-    (*e_proc)(data2);
+	(*e_proc)(data2);
     }
     if (prot_tag) return_value(retval);
     if (state) JUMP_TAG(state);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]