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

ruby-changes:4672

From: ko1@a...
Date: Wed, 23 Apr 2008 02:31:36 +0900 (JST)
Subject: [ruby-changes:4672] knu - Ruby:r16166 (ruby_1_8_7): Merge from ruby_1_8.

knu	2008-04-23 02:29:39 +0900 (Wed, 23 Apr 2008)

  New Revision: 16166

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/NEWS
    branches/ruby_1_8_7/enumerator.c
    branches/ruby_1_8_7/eval.c
    branches/ruby_1_8_7/file.c
    branches/ruby_1_8_7/intern.h
    branches/ruby_1_8_7/object.c
    branches/ruby_1_8_7/regex.c
    branches/ruby_1_8_7/sprintf.c
    branches/ruby_1_8_7/test/ruby/test_symbol.rb
    branches/ruby_1_8_7/test/yaml/test_yamlstore.rb
    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/test/yaml/test_yamlstore.rb?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/enumerator.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/test/ruby/test_symbol.rb?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/eval.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/ChangeLog?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/NEWS?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/sprintf.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/object.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/file.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/version.h?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/regex.c?r1=16166&r2=16165&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/intern.h?r1=16166&r2=16165&diff_format=u

Index: ruby_1_8_7/intern.h
===================================================================
--- ruby_1_8_7/intern.h	(revision 16165)
+++ ruby_1_8_7/intern.h	(revision 16166)
@@ -194,7 +194,6 @@
 VALUE rb_class_new_instance _((int, VALUE*, VALUE));
 VALUE rb_block_proc _((void));
 VALUE rb_f_lambda _((void));
-VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
 VALUE rb_proc_call _((VALUE, VALUE));
 VALUE rb_obj_method _((VALUE, VALUE));
 VALUE rb_protect _((VALUE (*)(VALUE), VALUE, int*));
Index: ruby_1_8_7/NEWS
===================================================================
--- ruby_1_8_7/NEWS	(revision 16165)
+++ ruby_1_8_7/NEWS	(revision 16166)
@@ -232,6 +232,10 @@
 
     Return an enumerator if no block is given.
 
+  * Symbol#to_proc
+
+    New method.
+
   * __method__
 
     New global function that returns the name of the current method as
@@ -335,6 +339,12 @@
 
   * content:encoded with RSS 2.0 support
 
+=== Interpreter Implementation
+
+* stack trace
+
+  On non-SystemStackError exception, full stack trace is shown.
+
 === Compatibility issues (excluding feature bug fixes)
 
 * tempfile
Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 16165)
+++ ruby_1_8_7/ChangeLog	(revision 16166)
@@ -1,3 +1,55 @@
+Wed Apr 23 00:42:49 2008  Tanaka Akira  <akr@f...>
+
+	* eval.c (error_print): show full stack grace except SystemStackError.
+	  backport from 1.9.  [ruby-dev:31014]
+
+Wed Apr 23 00:18:45 2008  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* test/ruby/test_symbol.rb (TestSymbol#test_to_proc): Improve
+	  tests of Symbol#to_proc.
+
+Tue Apr 22 22:43:05 2008  Akinori MUSHA  <knu@i...>
+
+	* eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
+	  YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for
+	  arguments.  This fixes a bug where [1,[2,3]].map(&:object_id)
+	  fails.
+
+	* intern.h, object.c: Hide rb_proc_new() from intern.h.  It should
+	  not be considered an official API function yet.
+
+Tue Apr 22 21:24:32 2008  Akinori MUSHA  <knu@i...>
+
+	* eval.c (rb_proc_new): Turn the BLOCK_LAMBDA flag on.
+
+	* object.c (sym_to_proc), test/ruby/test_symbol.rb: Add back
+	  Symbol#to_proc, now that it passes the tests.
+
+Tue Apr 22 19:35:03 2008  Akinori MUSHA  <knu@i...>
+
+	* enumerator.c (enumerator_initialize): Remove an undocumented
+	  feature (passing a block to the constructor) that's broken.
+	  This is not what I intended.
+
+Tue Apr 22 17:49:46 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* sprintf.c (rb_f_sprintf): should protect temporary string from
+	  GC.   [ruby-dev:34480]
+
+Tue Apr 22 17:12:05 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* regex.c (re_search): string might be NULL.  [ruby-core:16478]
+
+Tue Apr 22 16:44:00 2008  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* object.c (rb_obj_tap): Correct documentation; pointed out by
+	  okkez in [ruby-dev:34472].
+
+Tue Apr 22 10:05:51 2008  NAKAMURA Usaku  <usa@r...>
+
+	* file.c (eaccess): workaround for recent msvcrt's behavior.
+	  [ruby-core:16460]
+
 Mon Apr 21 16:06:47 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* enumerator.c (enumerator_init): preserve the method name in ID.
Index: ruby_1_8_7/enumerator.c
===================================================================
--- ruby_1_8_7/enumerator.c	(revision 16165)
+++ ruby_1_8_7/enumerator.c	(revision 16166)
@@ -51,7 +51,6 @@
 {
     struct enumerator *ptr = p;
     rb_gc_mark(ptr->obj);
-    rb_gc_mark(ptr->proc);
     rb_gc_mark(ptr->args);
 }
 
@@ -258,13 +257,7 @@
 
     ptr->obj  = obj;
     ptr->meth = rb_to_id(meth);
-    if (rb_block_given_p()) {
-	ptr->proc = rb_block_proc();
-	ptr->iter = enumerator_iter_i;
-    }
-    else {
-	ptr->iter = enumerator_each_i;
-    }
+    ptr->iter = enumerator_each_i;
     if (argc) ptr->args = rb_ary_new4(argc, argv);
 
     return enum_obj;
@@ -316,7 +309,6 @@
 
     ptr1->obj  = ptr0->obj;
     ptr1->meth = ptr0->meth;
-    ptr1->proc = ptr0->proc;
     ptr1->iter = ptr0->iter;
     ptr1->args = ptr0->args;
 
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 16165)
+++ ruby_1_8_7/version.h	(revision 16166)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2008-04-21"
+#define RUBY_RELEASE_DATE "2008-04-23"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20080421
+#define RUBY_RELEASE_CODE 20080423
 #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 4
-#define RUBY_RELEASE_DAY 21
+#define RUBY_RELEASE_DAY 23
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8_7/object.c
===================================================================
--- ruby_1_8_7/object.c	(revision 16165)
+++ ruby_1_8_7/object.c	(revision 16166)
@@ -502,10 +502,15 @@
  *  The primary purpose of this method is to "tap into" a method chain,
  *  in order to perform operations on intermediate results within the chain.
  *
- *	(1..10)                .tap {|x| puts "original: #{x.inspect}"}
- *	  .to_a                .tap {|x| puts "array: #{x.inspect}"}
- *	  .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
- *	  .map { |x| x*x }     .tap {|x| puts "squares: #{x.inspect}"}
+ *	(1..10).tap {
+ *	  |x| puts "original: #{x.inspect}"
+ *	}.to_a.tap {
+ *	  |x| puts "array: #{x.inspect}"
+ *	}.select {|x| x%2==0}.tap {
+ *	  |x| puts "evens: #{x.inspect}"
+ *	}.map {|x| x*x}.tap {
+ *	  |x| puts "squares: #{x.inspect}"
+ *	}
  *
  */
 
@@ -1207,6 +1212,37 @@
 }
 
 
+static VALUE
+sym_call(args, mid)
+    VALUE args, mid;
+{
+    VALUE obj;
+
+    if (RARRAY(args)->len < 1) {
+	rb_raise(rb_eArgError, "no receiver given");
+    }
+    obj = rb_ary_shift(args);
+    return rb_apply(obj, (ID)mid, args);
+}
+
+VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
+
+/*
+ * call-seq:
+ *   sym.to_proc
+ *
+ * Returns a _Proc_ object which respond to the given method by _sym_.
+ *
+ *   (1..3).collect(&:to_s)  #=> ["1", "2", "3"]
+ */
+
+static VALUE
+sym_to_proc(VALUE sym)
+{
+    return rb_proc_new(sym_call, (VALUE)SYM2ID(sym));
+}
+
+
 /***********************************************************************
  *
  * Document-class: Module
@@ -2750,6 +2786,7 @@
     rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
     rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
     rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
+    rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0);
     rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1); 
 
     rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
Index: ruby_1_8_7/test/ruby/test_symbol.rb
===================================================================
--- ruby_1_8_7/test/ruby/test_symbol.rb	(revision 16165)
+++ ruby_1_8_7/test/ruby/test_symbol.rb	(revision 16166)
@@ -74,4 +74,19 @@
     assert_inspect_evaled(':$0')
     assert_inspect_evaled(':$1')
   end
+
+  def test_to_proc
+    assert_equal %w(1 2 3), (1..3).map(&:to_s)
+    [
+      [],
+      [1],
+      [1, 2],
+      [1, [2, 3]],
+    ].each do |ary|
+      ary_id = ary.object_id
+      assert_equal ary_id, :object_id.to_proc.call(ary)
+      ary_ids = ary.collect{|x| x.object_id }
+      assert_equal ary_ids, ary.collect(&:object_id)
+    end
+  end
 end

Property changes on: ruby_1_8_7/test/yaml/test_yamlstore.rb
___________________________________________________________________
Name: snv:eol-style
   + LF

Index: ruby_1_8_7/regex.c
===================================================================
--- ruby_1_8_7/regex.c	(revision 16165)
+++ ruby_1_8_7/regex.c	(revision 16166)
@@ -3177,6 +3177,10 @@
   /* Check for out-of-range starting position.  */
   if (startpos < 0  ||  startpos > size)
     return -1;
+  if (!string) {
+    if (size == 0) string = "";
+    else return -1;
+  }
 
   /* Update the fastmap now if not correct already.  */
   if (fastmap && !bufp->fastmap_accurate) {
Index: ruby_1_8_7/file.c
===================================================================
--- ruby_1_8_7/file.c	(revision 16165)
+++ ruby_1_8_7/file.c	(revision 16166)
@@ -891,8 +891,8 @@
 
     return -1;
 #else
-# if _MSC_VER >= 1400
-    mode &= 6;
+# if defined(_MSC_VER) || defined(__MINGW32__)
+    mode &= ~1;
 # endif
     return access(path, mode);
 #endif
Index: ruby_1_8_7/sprintf.c
===================================================================
--- ruby_1_8_7/sprintf.c	(revision 16165)
+++ ruby_1_8_7/sprintf.c	(revision 16166)
@@ -471,7 +471,7 @@
 		long v = 0;
 		int base, bignum = 0;
 		int len, pos;
-		VALUE tmp;
+		volatile VALUE tmp;
                 volatile VALUE tmp1;
 
 		switch (*p) {
Index: ruby_1_8_7/eval.c
===================================================================
--- ruby_1_8_7/eval.c	(revision 16165)
+++ ruby_1_8_7/eval.c	(revision 16166)
@@ -1111,6 +1111,7 @@
 #define YIELD_PUBLIC_DEF  4
 #define YIELD_FUNC_AVALUE 1
 #define YIELD_FUNC_SVALUE 2
+#define YIELD_FUNC_LAMBDA 3
 
 static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int,VALUE));
 static VALUE module_setup _((VALUE,NODE*));
@@ -1306,6 +1307,7 @@
     if (!NIL_P(errat)) {
 	long i;
 	struct RArray *ep = RARRAY(errat);
+        int truncate = eclass == rb_eSysStackError;
 
 #define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
 #define TRACE_HEAD 8
@@ -1316,7 +1318,7 @@
 	    if (TYPE(ep->ptr[i]) == T_STRING) {
 		warn_printf("\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
 	    }
-	    if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
+	    if (truncate && i == TRACE_HEAD && ep->len > TRACE_MAX) {
 		warn_printf("\t ... %ld levels...\n",
 			ep->len - TRACE_HEAD - TRACE_TAIL);
 		i = ep->len - TRACE_TAIL;
@@ -5014,12 +5016,18 @@
     if ((state = EXEC_TAG()) == 0) {
       redo:
 	if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
-	    if (node->nd_state == YIELD_FUNC_AVALUE) {
+	    switch (node->nd_state) {
+	      case YIELD_FUNC_LAMBDA:
 		if (!avalue) {
+		    val = rb_ary_new3(1, val);
+		}
+		break;
+	      case YIELD_FUNC_AVALUE:
+		if (!avalue) {
 		    val = svalue_to_avalue(val);
 		}
-	    }
-	    else {
+		break;
+	      default:
 		if (avalue) {
 		    val = avalue_to_svalue(val);
 		}
@@ -9635,7 +9643,8 @@
     VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
 
     Data_Get_Struct(proc, struct BLOCK, data);
-    data->body->nd_state = YIELD_FUNC_AVALUE;
+    data->body->nd_state = YIELD_FUNC_LAMBDA;
+    data->flags |= BLOCK_LAMBDA;
     return proc;
 }
 

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

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