summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-11 02:39:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-11 02:39:59 +0000
commitfaab8f264d035e98f07ed57e74fb53d11d1608e5 (patch)
tree3beaaaf1394b37df36570409af32a59af7d08aff /ext/bigdecimal
parentc5d4ee4a39df0f11a6ba98a8f5f19c9b64144baa (diff)
* configure.in (ieeefp.h), numeric.c: needed for finite() on
Solaris. [ruby-core:01921] * file.c (rb_stat_inspect): adjust format specifier. * parse.c (arg_prepend): nodetype() is for debug use. * ruby.h (ISASCII, etc): cast to int to get rid of warning. * ruby.h (alloca.h): include even in GCC. [ruby-core:01925] * ext/bigdecimal/bigdecimal.c (GetVpValue): adjust format specifier. * ext/bigdecimal/bigdecimal.c (BigDecimal_prec, BigDecimal_coerce, BigDecimal_divmod): use rb_assoc_new() to suppress memory usage. * ext/bigdecimal/bigdecimal.c (BigDecimal_split): ditto. * ext/dl/sym.c (rb_dlsym_guardcall): guard itself should be volatile. * ext/iconv/iconv.c (iconv_convert): ensure actual parameter with format specifier. * ext/pty/pty.c (MasterDevice, SlaveDevice, deviceNo): do not define unless used. * ext/pty/pty.c (getDevice): get rid of warning. * ext/socket/socket.c (port_str, sock_s_getaddrinfo, sock_s_getnameinfo): FIX2INT() now returns long. * ext/socket/socket.c (init_inetsock_internal): uninitialized variable. * ext/syck/rubyext.c (syck_parser_assign_io): add prototype. * ext/syck/rubyext.c (rb_syck_mktime, yaml_org_handler): use ISDIGIT() instead of isdigit() to avoid warnings and for platforms which don't support non-ascii charater. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index ae5f7a0895..6a9940d335 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -103,7 +103,7 @@ GetVpValue(VALUE v, int must)
}
break;
case T_FIXNUM:
- sprintf(szD, "%d", FIX2INT(v));
+ sprintf(szD, "%ld", FIX2LONG(v));
return VpCreateRbObject(VpBaseFig() * 2 + 1, szD);
#ifdef ENABLE_NUMERIC_STRING
@@ -146,9 +146,8 @@ BigDecimal_prec(VALUE self)
VALUE obj;
GUARD_OBJ(p,GetVpValue(self,1));
- obj = rb_ary_new();
- obj = rb_ary_push(obj,INT2NUM(p->Prec*VpBaseFig()));
- obj = rb_ary_push(obj,INT2NUM(p->MaxPrec*VpBaseFig()));
+ obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
+ INT2NUM(p->MaxPrec*VpBaseFig()));
return obj;
}
@@ -427,14 +426,10 @@ BigDecimal_coerce(VALUE self, VALUE other)
VALUE obj;
Real *b;
if(TYPE(other) == T_FLOAT) {
- obj = rb_ary_new();
- obj = rb_ary_push(obj,other);
- obj = rb_ary_push(obj,BigDecimal_to_f(self));
+ obj = rb_assoc_new(other, BigDecimal_to_f(self));
} else {
GUARD_OBJ(b,GetVpValue(other,1));
- obj = rb_ary_new();
- obj = rb_ary_push(obj, b->obj);
- obj = rb_ary_push(obj, self);
+ obj = rb_assoc_new(b->obj, self);
}
return obj;
}
@@ -780,9 +775,7 @@ BigDecimal_divmod(VALUE self, VALUE r)
obj = BigDecimal_DoDivmod(self,r,&div,&mod);
if(obj!=(VALUE)0) return obj;
SAVE(div);SAVE(mod);
- obj = rb_ary_new();
- rb_ary_push(obj, ToValue(div));
- rb_ary_push(obj, ToValue(mod));
+ obj = rb_assoc_new(ToValue(div), ToValue(mod));
return obj;
}
@@ -1124,7 +1117,7 @@ BigDecimal_split(VALUE self)
if(psz1[0]=='N') s=0; /* NaN */
e = VpExponent10(vp);
obj1 = rb_str_new2(psz1);
- obj = rb_ary_new();
+ obj = rb_ary_new2(4);
rb_ary_push(obj, INT2FIX(s));
rb_ary_push(obj, obj1);
rb_ary_push(obj, INT2FIX(10));