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

ruby-changes:5643

From: tadf <ko1@a...>
Date: Fri, 13 Jun 2008 21:30:35 +0900 (JST)
Subject: [ruby-changes:5643] Ruby:r17150 (trunk): * complex.c (string_to_c, nucomp_s_convert): preserve the current

tadf	2008-06-13 21:29:50 +0900 (Fri, 13 Jun 2008)

  New Revision: 17150

  Modified files:
    trunk/ChangeLog
    trunk/complex.c
    trunk/include/ruby/intern.h
    trunk/rational.c

  Log:
    * complex.c (string_to_c, nucomp_s_convert): preserve the current
      backref.
    
    * rational.c (string_to_r, nurat_s_convert): ditto.
    
    * include/ruby/intern.h (rb_match_busy): added a declaration.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/complex.c?r1=17150&r2=17149&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17150&r2=17149&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/rational.c?r1=17150&r2=17149&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=17150&r2=17149&diff_format=u

Index: complex.c
===================================================================
--- complex.c	(revision 17149)
+++ complex.c	(revision 17150)
@@ -1153,10 +1153,8 @@
 	return rb_assoc_new(Qnil, self);
 
     {
-	VALUE m, sr, si, re, r, i, backref;
+	VALUE m, sr, si, re, r, i;
 
-	backref = rb_backref_get();
-	rb_match_busy(backref);
 	m = f_match(comp_pat1, s);
 	if (!NIL_P(m)) {
 	    sr = Qnil;
@@ -1173,7 +1171,6 @@
 	if (NIL_P(m)) {
 	    m = f_match(comp_pat2, s);
 	    if (NIL_P(m)) {
-		rb_backref_set(backref);
 		return rb_assoc_new(Qnil, self);
 	    }
 	    sr = f_aref(m, INT2FIX(1));
@@ -1210,7 +1207,6 @@
 	    else
 		i = f_to_i(si);
 	}
-	rb_backref_set(backref);
 	return rb_assoc_new(rb_complex_new2(r, i), re);
     }
 }
@@ -1233,8 +1229,16 @@
 static VALUE
 string_to_c(VALUE self)
 {
-    VALUE s = f_gsub(self, underscores_pat, an_underscore);
-    VALUE a = string_to_c_internal(s);
+    VALUE s, a, backref;
+
+    backref = rb_backref_get();
+    rb_match_busy(backref);
+
+    s = f_gsub(self, underscores_pat, an_underscore);
+    a = string_to_c_internal(s);
+
+    rb_backref_set(backref);
+
     if (!NIL_P(RARRAY_PTR(a)[0]))
 	return RARRAY_PTR(a)[0];
     return rb_complex_new1(INT2FIX(0));
@@ -1243,10 +1247,13 @@
 static VALUE
 nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
 {
-    VALUE a1, a2;
+    VALUE a1, a2, backref;
 
     rb_scan_args(argc, argv, "02", &a1, &a2);
 
+    backref = rb_backref_get();
+    rb_match_busy(backref);
+
     switch (TYPE(a1)) {
       case T_FIXNUM:
       case T_BIGNUM:
@@ -1267,6 +1274,8 @@
 	break;
     }
 
+    rb_backref_set(backref);
+
     switch (TYPE(a1)) {
       case T_COMPLEX:
 	{
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 17149)
+++ include/ruby/intern.h	(revision 17150)
@@ -478,6 +478,7 @@
 /* re.c */
 #define rb_memcmp memcmp
 int rb_memcicmp(const void*,const void*,long);
+void rb_match_busy(VALUE);
 VALUE rb_reg_nth_defined(int, VALUE);
 VALUE rb_reg_nth_match(int, VALUE);
 VALUE rb_reg_last_match(VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17149)
+++ ChangeLog	(revision 17150)
@@ -1,3 +1,12 @@
+Fri Jun 13 21:26:39 2008  Tadayoshi Funaba  <tadf@d...>
+
+	* complex.c (string_to_c, nucomp_s_convert): preserve the current
+	  backref.
+
+	* rational.c (string_to_r, nurat_s_convert): ditto.
+
+	* include/ruby/intern.h (rb_match_busy): added a declaration.
+
 Fri Jun 13 18:08:10 2008  Tanaka Akira  <akr@f...>
 
 	* lib/time.rb (Time.xmlschema): don't accept decimal dot without
Index: rational.c
===================================================================
--- rational.c	(revision 17149)
+++ rational.c	(revision 17150)
@@ -1274,15 +1274,13 @@
 static VALUE
 string_to_r_internal(VALUE self)
 {
-    VALUE s, m, backref;
+    VALUE s, m;
 
     s = f_strip(self);
 
     if (RSTRING_LEN(s) == 0)
 	return rb_assoc_new(Qnil, self);
 
-    backref = rb_backref_get();
-    rb_match_busy(backref);
     m = f_match(rat_pat, s);
 
     if (!NIL_P(m)) {
@@ -1335,10 +1333,8 @@
 	if (!NIL_P(de))
 	    v = f_div(v, f_to_i(de));
 
-	rb_backref_set(backref);
 	return rb_assoc_new(v, re);
     }
-    rb_backref_set(backref);
     return rb_assoc_new(Qnil, self);
 }
 
@@ -1360,8 +1356,16 @@
 static VALUE
 string_to_r(VALUE self)
 {
-    VALUE s = f_gsub(self, underscores_pat, an_underscore);
-    VALUE a = string_to_r_internal(s);
+    VALUE s, a, backref;
+
+    backref = rb_backref_get();
+    rb_match_busy(backref);
+
+    s = f_gsub(self, underscores_pat, an_underscore);
+    a = string_to_r_internal(s);
+
+    rb_backref_set(backref);
+
     if (!NIL_P(RARRAY_PTR(a)[0]))
 	return RARRAY_PTR(a)[0];
     return rb_rational_new1(INT2FIX(0));
@@ -1373,7 +1377,7 @@
 static VALUE
 nurat_s_convert(int argc, VALUE *argv, VALUE klass)
 {
-    VALUE a1, a2;
+    VALUE a1, a2, backref;
 
     rb_scan_args(argc, argv, "02", &a1, &a2);
 
@@ -1397,6 +1401,9 @@
 	a2 = RCOMPLEX(a2)->real;
     }
 
+    backref = rb_backref_get();
+    rb_match_busy(backref);
+
     switch (TYPE(a1)) {
       case T_FIXNUM:
       case T_BIGNUM:
@@ -1421,6 +1428,8 @@
 	break;
     }
 
+    rb_backref_set(backref);
+
     switch (TYPE(a1)) {
       case T_RATIONAL:
 	if (NIL_P(a2) || f_zero_p(a2))

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

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