From 03581d5826a7f2ed7b7f9c0691220c1a5ac00988 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 5 Dec 2000 09:36:54 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- marshal.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'marshal.c') diff --git a/marshal.c b/marshal.c index f777a0d43b..cf84e5ed24 100644 --- a/marshal.c +++ b/marshal.c @@ -52,7 +52,7 @@ shortlen(len, ds) #endif #define MARSHAL_MAJOR 4 -#define MARSHAL_MINOR 4 +#define MARSHAL_MINOR 5 #define TYPE_NIL '0' #define TYPE_TRUE 'T' @@ -143,10 +143,25 @@ w_long(x, arg) char buf[sizeof(long)+1]; int i, len = 0; +#if SIZEOF_LONG > 4 + if (!(RSHIFT(x, 32) == 0 || RSHIFT(x, 32) == -1)) { + /* big long does not fit in 4 bytes */ + rb_raise(rb_eTypeError, "long too big to dump"); + } +#endif + if (x == 0) { w_byte(0, arg); return; } + if (0 < x && x < 123) { + w_byte(x + 5, arg); + return; + } + if (-124 < x && x < 0) { + w_byte((x - 5)&0xff, arg); + return; + } for (i=1;i 0) { + if (4 < c && c < 128) { + return c - 5; + } if (c > sizeof(long)) long_toobig(c); x = 0; for (i=0;i sizeof(long)) long_toobig(c); x = -1; -- cgit v1.2.3