summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-26 04:58:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-26 04:58:15 +0000
commit8e86bd59c02bd17e838c89e2dd33e095cc270777 (patch)
tree6d29af9160ee116fe6c7e170f253bfa8d320b599 /marshal.c
parent0acedf8066b7a4654fd9a5e45260a1bc66421f43 (diff)
* common.mk (bignum.o, numeric.o): depend on util.h.
* bignum.c, marshal.c: fixed types. * numeric.c (infinite_value): use ruby_div0. * include/ruby/util.h (ruby_div0): moved from marshal.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/marshal.c b/marshal.c
index 0f9b4a89e8..1d07a83882 100644
--- a/marshal.c
+++ b/marshal.c
@@ -30,7 +30,7 @@
#if SIZEOF_SHORT == SIZEOF_BDIGITS
#define SHORTLEN(x) (x)
#else
-static int
+static long
shortlen(long len, BDIGIT *ds)
{
BDIGIT num;
@@ -188,7 +188,7 @@ class2path(VALUE klass)
static void w_long(long, struct dump_arg*);
static void
-w_nbyte(const char *s, int n, struct dump_arg *arg)
+w_nbyte(const char *s, long n, struct dump_arg *arg)
{
VALUE buf = arg->str;
rb_str_buf_cat(buf, s, n);
@@ -207,7 +207,7 @@ w_byte(char c, struct dump_arg *arg)
}
static void
-w_bytes(const char *s, int n, struct dump_arg *arg)
+w_bytes(const char *s, long n, struct dump_arg *arg)
{
w_long(n, arg);
w_nbyte(s, n, arg);
@@ -245,7 +245,7 @@ w_long(long x, struct dump_arg *arg)
w_byte((char)((x - 5)&0xff), arg);
return;
}
- for (i=1;i<sizeof(long)+1;i++) {
+ for (i=1;i<(int)sizeof(long)+1;i++) {
buf[i] = (char)(x & 0xff);
x = RSHIFT(x,8);
if (x == 0) {
@@ -306,8 +306,9 @@ save_mantissa(double d, char *buf)
}
static double
-load_mantissa(double d, const char *buf, int len)
+load_mantissa(double d, const char *buf, long len)
{
+ if (!len) return d;
if (--len > 0 && !*buf++) { /* binary mantissa mark */
int e, s = d < 0, dig = 0;
unsigned long m;
@@ -363,7 +364,7 @@ w_float(double d, struct dump_arg *arg)
else strcpy(buf, "0");
}
else {
- int len;
+ size_t len;
/* xxx: should not use system's sprintf(3) */
snprintf(buf, sizeof(buf), "%.*g", FLOAT_DIG, d);
@@ -988,7 +989,7 @@ r_long(struct load_arg *arg)
if (4 < c && c < 128) {
return c - 5;
}
- if (c > sizeof(long)) long_toobig(c);
+ if (c > (int)sizeof(long)) long_toobig(c);
x = 0;
for (i=0;i<c;i++) {
x |= (long)r_byte(arg) << (8*i);
@@ -999,7 +1000,7 @@ r_long(struct load_arg *arg)
return c + 5;
}
c = -c;
- if (c > sizeof(long)) long_toobig(c);
+ if (c > (int)sizeof(long)) long_toobig(c);
x = -1;
for (i=0;i<c;i++) {
x &= ~((long)0xff << (8*i));
@@ -1201,19 +1202,7 @@ obj_alloc_by_path(const char *path, struct load_arg *arg)
return rb_obj_alloc(klass);
}
-#if defined _MSC_VER && _MSC_VER >= 1300
-#pragma warning(push)
-#pragma warning(disable:4723)
-#endif
-static double
-div0(double x)
-{
- double t = 0.0;
- return x / t;
-}
-#if defined _MSC_VER && _MSC_VER >= 1300
-#pragma warning(pop)
-#endif
+#define div0(x) ruby_div0(x)
static VALUE
r_object0(struct load_arg *arg, int *ivp, VALUE extmod)