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

ruby-changes:35799

From: normal <ko1@a...>
Date: Sat, 11 Oct 2014 15:34:13 +0900 (JST)
Subject: [ruby-changes:35799] normal:r47881 (trunk): compile.c: fix RB_GC_GUARD usage

normal	2014-10-11 15:33:58 +0900 (Sat, 11 Oct 2014)

  New Revision: 47881

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47881

  Log:
    compile.c: fix RB_GC_GUARD usage
    
    * compile.c (iseq_build_from_ary_exception): move RB_GC_GUARD
      (iseq_build_from_ary_body): use PRIsVALUE instead of RB_GC_GUARD
    
    Currently unused functions, but we should set good examples for
    using RB_GC_GUARD (and favoring PRIsVALUE in format strings).

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47880)
+++ ChangeLog	(revision 47881)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 11 15:32:08 2014  Eric Wong  <e@8...>
+
+	* compile.c (iseq_build_from_ary_exception): move RB_GC_GUARD
+	  (iseq_build_from_ary_body): use PRIsVALUE instead of RB_GC_GUARD
+
 Sat Oct 11 14:57:08 2014  Eric Wong  <e@8...>
 
 	* string.c (rb_str_intern): remove unnecessary RB_GC_GUARD
Index: compile.c
===================================================================
--- compile.c	(revision 47880)
+++ compile.c	(revision 47881)
@@ -5567,7 +5567,7 @@ iseq_build_from_ary_exception(rb_iseq_t https://github.com/ruby/ruby/blob/trunk/compile.c#L5567
 	LABEL *lstart, *lend, *lcont;
 	int sp;
 
-	RB_GC_GUARD(v) = rb_convert_type(RARRAY_AREF(exception, i), T_ARRAY,
+	v = rb_convert_type(RARRAY_AREF(exception, i), T_ARRAY,
 					 "Array", "to_ary");
 	if (RARRAY_LEN(v) != 6) {
 	    rb_raise(rb_eSyntaxError, "wrong exception entry");
@@ -5589,6 +5589,8 @@ iseq_build_from_ary_exception(rb_iseq_t https://github.com/ruby/ruby/blob/trunk/compile.c#L5589
 	(void)sp;
 
 	ADD_CATCH_ENTRY(type, lstart, lend, eiseqval, lcont);
+
+	RB_GC_GUARD(v);
     }
     return COMPILE_OK;
 }
@@ -5662,9 +5664,9 @@ iseq_build_from_ary_body(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L5664
 	    insn = (argc < 0) ? Qnil : RARRAY_AREF(obj, 0);
 	    if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) {
 		/* TODO: exception */
-		RB_GC_GUARD(insn) = rb_inspect(insn);
 		rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
-				 "unknown instruction: %s", RSTRING_PTR(insn));
+				 "unknown instruction: %"PRIsVALUE,
+				 rb_inspect(insn));
 	    }
 
 	    if (argc != insn_len((VALUE)insn_id)-1) {

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

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