summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-03 07:06:51 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-03 07:06:51 +0000
commitab801dbdb7ff8a99b5e0976516b879b27bcf3e1b (patch)
tree2657a1ca78c166beda5dfb609f9c53c5bae6f85c /marshal.c
parent1a2003d1f176001f4c691d14a080e722bb12fc7b (diff)
1.1b9_29
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/marshal.c b/marshal.c
index 73ae8a6..4234c98 100644
--- a/marshal.c
+++ b/marshal.c
@@ -207,10 +207,6 @@ w_object(obj, arg, limit)
if (limit == 0) {
Fail("exceed depth limit");
}
- limit--;
- c_arg.limit = limit;
- c_arg.arg = arg;
-
if (obj == Qnil) {
w_byte(TYPE_NIL, arg);
}
@@ -225,19 +221,23 @@ w_object(obj, arg, limit)
w_byte(TYPE_FIXNUM, arg);
w_long(FIX2INT(obj), arg);
#else
- if (RSHIFT(obj, 32) == 0 || RSHIFT(obj, 32) == -1) {
+ if (RSHIFT((long)obj, 32) == 0 || RSHIFT((long)obj, 32) == -1) {
w_byte(TYPE_FIXNUM, arg);
- w_long(FIX2INT(obj), arg);
+ w_long(FIX2LONG(obj), arg);
}
else {
- obj = int2big(FIX2INT(obj));
- goto write_bignum;
+ w_object(int2big(FIX2LONG(obj)), arg, limit);
+ return;
}
#endif
}
else {
int num;
+ limit--;
+ c_arg.limit = limit;
+ c_arg.arg = arg;
+
if (st_lookup(arg->data, obj, &num)) {
w_byte(TYPE_LINK, arg);
w_long(num, arg);
@@ -339,7 +339,7 @@ w_object(obj, arg, limit)
Fatal("non-initialized struct");
}
for (i=0; i<len; i++) {
- w_symbol(FIX2INT(RARRAY(mem)->ptr[i]), arg);
+ w_symbol(FIX2LONG(RARRAY(mem)->ptr[i]), arg);
w_object(RSTRUCT(obj)->ptr[i], arg, limit);
}
}
@@ -456,7 +456,7 @@ r_byte(arg)
struct load_arg *arg;
{
if (arg->fp) return getc(arg->fp);
- if (arg->ptr < arg->end) return *arg->ptr++;
+ if (arg->ptr < arg->end) return *(unsigned char*)arg->ptr++;
return EOF;
}
@@ -511,8 +511,9 @@ r_long(arg)
return x;
}
+static long blen; /* hidden length register */
#define r_bytes(s, arg) \
- (s = (char*)r_long(arg), r_bytes0(&s,ALLOCA_N(char,(long)s),(long)s,arg))
+ (blen = r_long(arg), r_bytes0(&s,ALLOCA_N(char,blen),blen,arg))
static int
r_bytes0(sp, s, len, arg)