mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
05093ae437
commit
c7f4ebc8b7
4 changed files with 44 additions and 16 deletions
25
complex.c
25
complex.c
|
@ -1153,10 +1153,8 @@ string_to_c_internal(VALUE self)
|
|||
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 @@ string_to_c_internal(VALUE self)
|
|||
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 @@ string_to_c_internal(VALUE self)
|
|||
else
|
||||
i = f_to_i(si);
|
||||
}
|
||||
rb_backref_set(backref);
|
||||
return rb_assoc_new(rb_complex_new2(r, i), re);
|
||||
}
|
||||
}
|
||||
|
@ -1233,8 +1229,16 @@ string_to_c_strict(VALUE self)
|
|||
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 @@ string_to_c(VALUE self)
|
|||
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 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
|
|||
break;
|
||||
}
|
||||
|
||||
rb_backref_set(backref);
|
||||
|
||||
switch (TYPE(a1)) {
|
||||
case T_COMPLEX:
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue