diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | bignum.c | 13 | ||||
-rw-r--r-- | ext/marshal/marshal.c | 52 | ||||
-rw-r--r-- | file.c | 2 | ||||
-rw-r--r-- | ruby.c | 7 | ||||
-rw-r--r-- | sample/export.rb | 4 | ||||
-rw-r--r-- | sample/exyacc.rb | 2 | ||||
-rw-r--r-- | version.h | 4 |
8 files changed, 72 insertions, 26 deletions
@@ -1,3 +1,17 @@ +Tue Oct 21 13:31:29 1997 Yukihiro Matsumoto <[email protected]> + + * version 1.0-971021 + +Mon Oct 20 12:18:29 1997 WATANABE Hirofumi <[email protected]> + + * 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 <[email protected]> + + * bignum.c (bigadd): some undefined side effect order assumed. + Wed Oct 15 18:08:37 1997 Yukihiro Matsumoto <[email protected]> * version 1.0-971015 @@ -101,6 +101,13 @@ bignorm(x) } VALUE +big_norm(x) + VALUE x; +{ + return bignorm(x); +} + +VALUE uint2big(n) UINT n; { @@ -514,7 +521,8 @@ bigsub(x, y) num = BIGDN(num); } while (i < x->len) { - zds[i++] = BDIGITS(x)[i]; + zds[i] = BDIGITS(x)[i]; + i++; } return bignorm(z); @@ -555,7 +563,8 @@ bigadd(x, y, sign) num = BIGDN(num); } while (i < y->len) { - BDIGITS(z)[i++] = BDIGITS(y)[i]; + BDIGITS(z)[i] = BDIGITS(y)[i]; + i++; } BDIGITS(z)[i] = num; 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<sizeof(USHORT); i++) { + w_byte((x >> (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; i<sizeof(USHORT); i++) { + x |= r_byte(arg)<<(i*8); + } + return x; } @@ -475,7 +492,7 @@ static long r_long(arg) struct load_arg *arg; { - char c = r_byte(arg), i; + int c = r_byte(arg), i; register long x; if (c == 0) return 0; @@ -499,7 +516,7 @@ r_long(arg) } #define r_bytes(s, arg) \ - (s = (char*)r_long(arg), r_bytes0(&s,ALLOCA_N(char,(int)s),(int)s,arg)) + (s = (char*)r_long(arg), r_bytes0(&s,ALLOCA_N(char,(long)s),(long)s,arg)) static int r_bytes0(sp, s, len, arg) @@ -582,7 +599,7 @@ r_object(arg) switch (type) { case EOF: - eof_error("EOF read where object expected"); + eof_error(); return Qnil; case TYPE_LINK: @@ -643,7 +660,11 @@ r_object(arg) while (len--) { *digits++ = r_short(arg); } - return r_regist(big, arg); + big = RBIGNUM(big_norm((VALUE)big)); + if (TYPE(big) == T_BIGNUM) { + r_regist(big, arg); + } + return (VALUE)big; } case TYPE_STRING: @@ -688,7 +709,6 @@ r_object(arg) int i, len; int num = arg->data->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) { @@ -1375,6 +1375,8 @@ file_s_dirname(obj, fname) if (!p) { return str_new2("."); } + if (p == fname->ptr) + p++; return str_taint(str_new(fname->ptr, p - fname->ptr)); } @@ -436,8 +436,8 @@ load_file(fname, script) while (!NIL_P(line = io_gets(f))) { line_start++; if (RSTRING(line)->len > 2 - || RSTRING(line)->ptr[0] != '#' - || RSTRING(line)->ptr[1] != '!') { + && RSTRING(line)->ptr[0] == '#' + && RSTRING(line)->ptr[1] == '!') { if (strstr(RSTRING(line)->ptr, "ruby")) { goto start_read; } @@ -453,8 +453,7 @@ load_file(fname, script) line_start++; if (RSTRING(line)->len > 2 - || RSTRING(line)->ptr[0] != '#' - || RSTRING(line)->ptr[1] != '!') { + && RSTRING(line)->ptr[0] == '!') { char *p; diff --git a/sample/export.rb b/sample/export.rb index 750b5c1948..949e5b10bf 100644 --- a/sample/export.rb +++ b/sample/export.rb @@ -22,7 +22,9 @@ end f = Foo.new #Foo.private :printf -Foo.public :foobar +class Foo # redefines foobar's scope + public :foobar +end f.foobar f.printf "%s\n", Foo diff --git a/sample/exyacc.rb b/sample/exyacc.rb index dafcb037cc..dbe0dee710 100644 --- a/sample/exyacc.rb +++ b/sample/exyacc.rb @@ -13,7 +13,7 @@ while gets() gsub!(/'}'/, "'\002'") gsub!('\*/', "\003\003") gsub!("/\\*[^\003]*\003\003", '') - while gsub!(/{[^}{]*}/, ''); end + while gsub!(/\{[^{}]*}/, ''); end gsub!(/'\001'/, "'{'") gsub!(/'\002'/, "'}'") while gsub!(/^[ \t]*\n(\s)/, '\1'); end @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.0-971015" -#define VERSION_DATE "97/10/15" +#define RUBY_VERSION "1.0-971021" +#define VERSION_DATE "97/10/21" |