mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
adopted the ruby's style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
459aa9f1c5
commit
597179bb95
3 changed files with 1837 additions and 1813 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Apr 1 01:40:58 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c: adopted the ruby's style.
|
||||
|
||||
* rational.c: ditto.
|
||||
|
||||
Tue Apr 1 00:17:35 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* rational.c: revert.
|
||||
|
|
36
complex.c
36
complex.c
|
@ -405,6 +405,7 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE image)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
|
@ -438,6 +439,7 @@ nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
|
|||
|
||||
return nucomp_s_canonicalize_internal(klass, real, image);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
|
||||
|
@ -662,6 +664,7 @@ m_atan2_bang(VALUE y, VALUE x)
|
|||
return DOUBLE2NUM(atan2(RFLOAT_VALUE(y), RFLOAT_VALUE(x)));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
m_hypot(VALUE x, VALUE y)
|
||||
{
|
||||
|
@ -669,6 +672,7 @@ m_hypot(VALUE x, VALUE y)
|
|||
return DOUBLE2NUM(hypot(RFLOAT_VALUE(x), RFLOAT_VALUE(y)));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nucomp_s_polar(VALUE klass, VALUE abs, VALUE arg)
|
||||
|
@ -829,6 +833,7 @@ nucomp_rdiv(VALUE self, VALUE other)
|
|||
f_to_r(dat->image)), other);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nucomp_fdiv(VALUE self, VALUE other)
|
||||
{
|
||||
|
@ -838,6 +843,7 @@ nucomp_fdiv(VALUE self, VALUE other)
|
|||
f_to_f(dat->real),
|
||||
f_to_f(dat->image)), other);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nucomp_expt(VALUE self, VALUE other)
|
||||
|
@ -991,6 +997,7 @@ nucomp_conjugate(VALUE self)
|
|||
return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->image));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nucomp_real_p(VALUE self)
|
||||
{
|
||||
|
@ -1015,6 +1022,7 @@ nucomp_inexact_p(VALUE self)
|
|||
{
|
||||
return f_boolcast(!nucomp_exact_p(self));
|
||||
}
|
||||
#endif
|
||||
|
||||
extern VALUE rb_lcm(VALUE x, VALUE y);
|
||||
|
||||
|
@ -1099,17 +1107,17 @@ nucomp_to_s(VALUE self)
|
|||
s = rb_str_new2("");
|
||||
else {
|
||||
s = f_to_s(dat->real);
|
||||
rb_str_concat(s, rb_str_new2(!impos ? "-" : "+"));
|
||||
rb_str_cat2(s, !impos ? "-" : "+");
|
||||
}
|
||||
|
||||
if (k_rational_p(dat->image) &&
|
||||
!f_one_p(f_denominator(dat->image))) {
|
||||
rb_str_concat(s, rb_str_new2("("));
|
||||
rb_str_cat2(s, "(");
|
||||
rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
|
||||
rb_str_concat(s, rb_str_new2(")i"));
|
||||
rb_str_cat2(s, ")i");
|
||||
} else {
|
||||
rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
|
||||
rb_str_concat(s, rb_str_new2("i"));
|
||||
rb_str_cat2(s, "i");
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -1124,9 +1132,9 @@ nucomp_inspect(VALUE self)
|
|||
|
||||
s = rb_str_new2("Complex(");
|
||||
rb_str_concat(s, f_inspect(dat->real));
|
||||
rb_str_concat(s, rb_str_new2(", "));
|
||||
rb_str_cat2(s, ", ");
|
||||
rb_str_concat(s, f_inspect(dat->image));
|
||||
rb_str_concat(s, rb_str_new2(")"));
|
||||
rb_str_cat2(s, ")");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -1243,15 +1251,15 @@ static VALUE comp_pat1, comp_pat2, a_slash, a_dot_and_an_e,
|
|||
static void
|
||||
make_patterns(void)
|
||||
{
|
||||
static char *comp_pat1_source = PATTERN1;
|
||||
static char *comp_pat2_source = PATTERN2;
|
||||
static char *image_garbages_pat_source = "[+\\(\\)iIjJ]";
|
||||
static char *underscores_pat_source = "_+";
|
||||
static char comp_pat1_source[] = PATTERN1;
|
||||
static char comp_pat2_source[] = PATTERN2;
|
||||
static char image_garbages_pat_source[] = "[+\\(\\)iIjJ]";
|
||||
static char underscores_pat_source[] = "_+";
|
||||
|
||||
comp_pat1 = rb_reg_new(comp_pat1_source, strlen(comp_pat1_source), 0);
|
||||
comp_pat1 = rb_reg_new(comp_pat1_source, sizeof comp_pat1_source - 1, 0);
|
||||
rb_global_variable(&comp_pat1);
|
||||
|
||||
comp_pat2 = rb_reg_new(comp_pat2_source, strlen(comp_pat2_source), 0);
|
||||
comp_pat2 = rb_reg_new(comp_pat2_source, sizeof comp_pat2_source - 1, 0);
|
||||
rb_global_variable(&comp_pat2);
|
||||
|
||||
a_slash = rb_str_new2("/");
|
||||
|
@ -1261,14 +1269,14 @@ make_patterns(void)
|
|||
rb_global_variable(&a_dot_and_an_e);
|
||||
|
||||
image_garbages_pat = rb_reg_new(image_garbages_pat_source,
|
||||
strlen(image_garbages_pat_source), 0);
|
||||
sizeof image_garbages_pat_source - 1, 0);
|
||||
rb_global_variable(&image_garbages_pat);
|
||||
|
||||
null_string = rb_str_new2("");
|
||||
rb_global_variable(&null_string);
|
||||
|
||||
underscores_pat = rb_reg_new(underscores_pat_source,
|
||||
strlen(underscores_pat_source), 0);
|
||||
sizeof underscores_pat_source - 1, 0);
|
||||
rb_global_variable(&underscores_pat);
|
||||
|
||||
an_underscore = rb_str_new2("_");
|
||||
|
|
30
rational.c
30
rational.c
|
@ -474,6 +474,7 @@ nurat_s_canonicalize_internal_no_reduce(VALUE klass, VALUE num, VALUE den)
|
|||
return nurat_s_new_internal(klass, num, den);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
|
@ -503,6 +504,7 @@ nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass)
|
|||
|
||||
return nurat_s_canonicalize_internal(klass, num, den);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nurat_s_new(int argc, VALUE *argv, VALUE klass)
|
||||
|
@ -999,11 +1001,14 @@ nurat_divmod(VALUE self, VALUE other)
|
|||
return rb_assoc_new(val, f_sub(self, f_mul(other, val)));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nurat_quot(VALUE self, VALUE other)
|
||||
{
|
||||
return f_truncate(f_div(self, other));
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nurat_rem(VALUE self, VALUE other)
|
||||
{
|
||||
|
@ -1011,12 +1016,14 @@ nurat_rem(VALUE self, VALUE other)
|
|||
return f_sub(self, f_mul(other, val));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nurat_quotrem(VALUE self, VALUE other)
|
||||
{
|
||||
VALUE val = f_truncate(f_div(self, other));
|
||||
return rb_assoc_new(val, f_sub(self, f_mul(other, val)));
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nurat_abs(VALUE self)
|
||||
|
@ -1027,11 +1034,13 @@ nurat_abs(VALUE self)
|
|||
return f_negate(self);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
nurat_true(VALUE self)
|
||||
{
|
||||
return Qtrue;
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
nurat_floor(VALUE self)
|
||||
|
@ -1129,7 +1138,7 @@ nurat_to_f(VALUE self)
|
|||
|
||||
nl = i_ilog2(num);
|
||||
dl = i_ilog2(den);
|
||||
ml = (long)(log(DBL_MAX) / log(2) - 1); /* should be a static */
|
||||
ml = (long)(log(DBL_MAX) / log(2.0) - 1); /* should be a static */
|
||||
|
||||
ne = 0;
|
||||
if (nl > ml) {
|
||||
|
@ -1307,7 +1316,8 @@ static VALUE
|
|||
float_to_r(VALUE self)
|
||||
{
|
||||
VALUE a = float_decode(self);
|
||||
return f_mul(RARRAY_PTR(a)[0], f_expt(INT2FIX(FLT_RADIX), RARRAY_PTR(a)[1]));
|
||||
return f_mul(RARRAY_PTR(a)[0],
|
||||
f_expt(INT2FIX(FLT_RADIX), RARRAY_PTR(a)[1]));
|
||||
}
|
||||
|
||||
static VALUE rat_pat, an_e_pat, a_dot_pat, underscores_pat, an_underscore;
|
||||
|
@ -1320,22 +1330,22 @@ static VALUE rat_pat, an_e_pat, a_dot_pat, underscores_pat, an_underscore;
|
|||
static void
|
||||
make_patterns(void)
|
||||
{
|
||||
static char *rat_pat_source = PATTERN;
|
||||
static char *an_e_pat_source = "[eE]";
|
||||
static char *a_dot_pat_source = "\\.";
|
||||
static char *underscores_pat_source = "_+";
|
||||
static char rat_pat_source[] = PATTERN;
|
||||
static char an_e_pat_source[] = "[eE]";
|
||||
static char a_dot_pat_source[] = "\\.";
|
||||
static char underscores_pat_source[] = "_+";
|
||||
|
||||
rat_pat = rb_reg_new(rat_pat_source, strlen(rat_pat_source), 0);
|
||||
rat_pat = rb_reg_new(rat_pat_source, sizeof rat_pat_source - 1, 0);
|
||||
rb_global_variable(&rat_pat);
|
||||
|
||||
an_e_pat = rb_reg_new(an_e_pat_source, strlen(an_e_pat_source), 0);
|
||||
an_e_pat = rb_reg_new(an_e_pat_source, sizeof an_e_pat_source - 1, 0);
|
||||
rb_global_variable(&an_e_pat);
|
||||
|
||||
a_dot_pat = rb_reg_new(a_dot_pat_source, strlen(a_dot_pat_source), 0);
|
||||
a_dot_pat = rb_reg_new(a_dot_pat_source, sizeof a_dot_pat_source - 1, 0);
|
||||
rb_global_variable(&a_dot_pat);
|
||||
|
||||
underscores_pat = rb_reg_new(underscores_pat_source,
|
||||
strlen(underscores_pat_source), 0);
|
||||
sizeof underscores_pat_source - 1, 0);
|
||||
rb_global_variable(&underscores_pat);
|
||||
|
||||
an_underscore = rb_str_new2("_");
|
||||
|
|
Loading…
Reference in a new issue