From 9b01ce69546380c57cb602e045be4fc012cd81b7 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Tue, 21 Oct 1997 13:31:29 +0900 Subject: version 1.0-971021 https://cache.ruby-lang.org/pub/ruby/1.0/ruby-1.0-971021.tar.gz Tue Oct 21 13:31:29 1997 Yukihiro Matsumoto * version 1.0-971021 Mon Oct 20 12:18:29 1997 WATANABE Hirofumi * ruby.c (load_file): wrong condition for #! check with -x. * file.c (file_s_dirname): did return "" for "/a". Fri Oct 17 14:29:09 1997 Yukihiro Matsumoto * bignum.c (bigadd): some undefined side effect order assumed. Co-authored-by: WATANABE Hirofumi --- ext/marshal/marshal.c | 52 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'ext/marshal/marshal.c') diff --git a/ext/marshal/marshal.c b/ext/marshal/marshal.c index a74ecd70eb..99e87d0b5f 100644 --- a/ext/marshal/marshal.c +++ b/ext/marshal/marshal.c @@ -50,7 +50,7 @@ static ID s_dump, s_load; struct dump_arg { VALUE obj; FILE *fp; - struct RString *str; + VALUE str; st_table *symbol; st_table *data; }; @@ -69,7 +69,7 @@ w_byte(c, arg) struct dump_arg *arg; { if (arg->fp) putc(c, arg->fp); - else str_cat(arg->str, &c, 1); + else str_cat(arg->str, (UCHAR*)&c, 1); } static void @@ -92,8 +92,11 @@ w_short(x, arg) int x; struct dump_arg *arg; { - w_byte( x & 0xff, arg); - w_byte((x>> 8) & 0xff, arg); + int i; + + for (i=0; i> (i*8)) & 0xff, arg); + } } static void @@ -225,10 +228,19 @@ w_object(obj, arg, limit) w_byte(TYPE_FALSE, arg); } else if (FIXNUM_P(obj)) { - if (sizeof(long) == 4) { +#if SIZEOF_LONG <= 4 + w_byte(TYPE_FIXNUM, arg); + w_long(FIX2INT(obj), arg); +#else + if (RSHIFT(obj, 32) == 0 || RSHIFT(obj, 32) == -1) { w_byte(TYPE_FIXNUM, arg); w_long(FIX2INT(obj), arg); } + else { + obj = int2big(FIX2INT(obj)); + goto write_bignum; + } +#endif } else { int num; @@ -268,6 +280,7 @@ w_object(obj, arg, limit) return; case T_BIGNUM: + write_bignum: w_byte(TYPE_BIGNUM, arg); { char sign = RBIGNUM(obj)->sign?'+':'-'; @@ -419,7 +432,7 @@ marshal_dump(argc, argv) else { arg.fp = 0; port = str_new(0, 0); - arg.str = RSTRING(port); + arg.str = port; } arg.symbol = st_init_numtable(); @@ -452,14 +465,18 @@ r_byte(arg) return EOF; } -static int +static USHORT r_short(arg) struct load_arg *arg; { - register short x; - x = r_byte(arg); - x |= r_byte(arg) << 8; - /* XXX If your short is > 16 bits, add sign-extension here!!! */ + USHORT x; + int i; + + x = 0; + for (i=0; idata->num_entries; - st_insert(arg->data, num, 15); /* temp reg. */ class = rb_path2class(r_unique(arg)); mem = rb_ivar_get(class, rb_intern("__member__")); if (mem == Qnil) { -- cgit v1.2.3