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
|
|
@ -1,3 +1,12 @@
|
|||
Fri Jun 13 21:26:39 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* 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@fsij.org>
|
||||
|
||||
* lib/time.rb (Time.xmlschema): don't accept decimal dot without
|
||||
|
|
|
|||
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:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@ double rb_genrand_real(void);
|
|||
/* 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);
|
||||
|
|
|
|||
25
rational.c
25
rational.c
|
|
@ -1274,15 +1274,13 @@ make_patterns(void)
|
|||
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 @@ string_to_r_internal(VALUE self)
|
|||
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 @@ string_to_r_strict(VALUE self)
|
|||
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 @@ string_to_r(VALUE self)
|
|||
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 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass)
|
|||
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 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass)
|
|||
break;
|
||||
}
|
||||
|
||||
rb_backref_set(backref);
|
||||
|
||||
switch (TYPE(a1)) {
|
||||
case T_RATIONAL:
|
||||
if (NIL_P(a2) || f_zero_p(a2))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue