diff --git a/ChangeLog b/ChangeLog index 9ac66a28f1..c2e73e4e38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,36 @@ +Mon Nov 20 13:45:21 2000 Yukihiro Matsumoto + + * eval.c (rb_eval): should treat class variables specially in a + method defined in the singleton class. + Mon Nov 20 10:20:21 2000 WATANABE Hirofumi * dir.c, win32/win32.c, ruby.h: add rb_iglob(). +Mon Nov 20 00:18:16 2000 Yukihiro Matsumoto + + * array.c (rb_ary_subseq): should return nil for outbound start + index. + + * marshal.c (marshal_load): show format versions explicitly when + format version mismatch happens. + +Sun Nov 19 06:13:24 2000 Kazuhiro NISHIYAMA + + * marshal.c: use long for string/array length. + + * pack.c (swaps): use bit-or(|) instead of plus(+). + + * pack.c (swapl): ditto. + +Sat Nov 18 15:18:16 2000 Kazuhiro NISHIYAMA + + * array.c (rb_ary_replace): array size should be in long. + + * array.c (rb_ary_concat): ditto. + + * array.c (rb_ary_hash): ditto. + Sat Nov 18 14:07:20 2000 Minero Aoki * lib/net/http.rb: Socket#readline() reads until "\n", not "\r\n" @@ -40,7 +69,7 @@ Thu Nov 16 23:06:07 2000 Minero Aoki * lib/net/http.rb: not check Connection:/Proxy-Connection; always read until eof. - * lib/net/protocol: detects and catches "break" from block. + * lib/net/protocol.rb: detects and catches "break" from block. Thu Nov 16 16:32:45 2000 Masahiro Tanaka @@ -266,7 +295,7 @@ Mon Oct 16 14:06:00 2000 Yukihiro Matsumoto * pack.c (I32,U32): 32 bit sized integer. - * pack.c (OFF16,OFF32B): big endien offset for network byteorder. + * pack.c (OFF16,OFF32B): big endian offset for network byteorder. Mon Oct 16 06:39:32 2000 Minero Aoki diff --git a/array.c b/array.c index 617f6e22ac..825227fc36 100644 --- a/array.c +++ b/array.c @@ -22,7 +22,7 @@ VALUE rb_cArray; void rb_mem_clear(mem, size) register VALUE *mem; - register size_t size; + register long size; { while (size--) { *mem++ = Qnil; @@ -32,7 +32,7 @@ rb_mem_clear(mem, size) static void memfill(mem, size, val) register VALUE *mem; - register size_t size; + register long size; register VALUE val; { while (size--) { @@ -400,11 +400,8 @@ rb_ary_subseq(ary, beg, len) VALUE ary2; if (beg > RARRAY(ary)->len) return Qnil; - if (beg < 0) { - len += beg; - beg = 0; - } - if (len < 0) return Qnil; + if (beg < 0 || len < 0) return Qnil; + if (beg + len > RARRAY(ary)->len) { len = RARRAY(ary)->len - beg; } @@ -532,7 +529,7 @@ rb_ary_replace(ary, beg, len, rpl) VALUE ary, rpl; long beg, len; { - int rlen; + long rlen; if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len); if (beg < 0) { @@ -1254,8 +1251,8 @@ VALUE rb_ary_concat(x, y) VALUE x, y; { - int xlen = RARRAY(x)->len; - int ylen; + long xlen = RARRAY(x)->len; + long ylen; y = to_ary(y); ylen = RARRAY(y)->len; @@ -1371,7 +1368,8 @@ rb_ary_hash(ary) VALUE ary; { long i; - int n, h; + VALUE n; + long h; h = RARRAY(ary)->len; for (i=0; ilen; i++) { diff --git a/eval.c b/eval.c index c0d47bf4f6..03ae3775e5 100644 --- a/eval.c +++ b/eval.c @@ -2594,17 +2594,19 @@ rb_eval(self, n) rb_const_set(ruby_class, node->nd_vid, result); break; - case NODE_CVASGN2: - result = rb_eval(self, node->nd_value); - rb_cvar_set_singleton(self, node->nd_vid, result); - break; - case NODE_CVDECL: if (NIL_P(ruby_cbase)) { rb_raise(rb_eTypeError, "no class/module to define class variable"); } + if (!FL_TEST(ruby_cbase, FL_SINGLETON)) { + result = rb_eval(self, node->nd_value); + rb_cvar_declare(ruby_cbase, node->nd_vid, result); + break; + } + /* fall through */ + case NODE_CVASGN2: result = rb_eval(self, node->nd_value); - rb_cvar_declare(ruby_cbase, node->nd_vid, result); + rb_cvar_set_singleton(self, node->nd_vid, result); break; case NODE_LVAR: diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 54d5d861f8..e5c2c2ece0 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -269,40 +269,61 @@ module TkComm end class Event - def initialize(seq,b,f,h,k,s,t,w,x,y,aa,ee,kk,nn,ww,tt,xx,yy) + def initialize(seq,a,b,c,d,f,h,k,m,o,p,s,t,w,x,y, + aa,bb,dd,ee,kk,nn,rr,ss,tt,ww,xx,yy) @serial = seq + @above = a @num = b + @count = c + @detail = d @focus = (f == 1) @height = h @keycode = k + @mode = m + @override = (o == 1) + @place = p @state = s @time = t @width = w @x = x @y = y @char = aa + @borderwidth = bb + @wheel_delta = dd @send_event = (ee == 1) @keysym = kk @keysym_num = nn + @rootwin_id = rr + @subwindow = ss @type = tt @widget = ww @x_root = xx @y_root = yy end attr :serial + attr :above attr :num + attr :count + attr :detail attr :focus attr :height attr :keycode + attr :mode + attr :override + attr :place attr :state attr :time attr :width attr :x attr :y attr :char + attr :borderwidth + attr :wheel_delta attr :send_event attr :keysym attr :keysym_num + attr :rootwin_id + attr :subwindow attr :type attr :widget attr :x_root @@ -319,7 +340,8 @@ module TkComm id = install_cmd(proc{|arg| TkUtil.eval_cmd cmd, Event.new(*arg) }) - id + ' %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y' + id + ' %# %a %b %c %d %f %h %k %m %o %p %s %t %w %x %y' + + ' %A %B %D %E %K %N %R %S %T %W %X %Y' end end @@ -550,6 +572,10 @@ module TkCore tk_call 'tk_chooseColor', *hash_kv(keys) end + def chooseDirectory(keys = nil) + tk_call 'tk_chooseDirectory', *hash_kv(keys) + end + def tk_call(*args) print args.join(" "), "\n" if $DEBUG args.collect! {|x|ruby2tcl(x)} @@ -2352,7 +2378,7 @@ class TkRadiobuttonsign?'+':'-'; - int len = RBIGNUM(obj)->len; + long len = RBIGNUM(obj)->len; BDIGIT *d = RBIGNUM(obj)->digits; w_byte(sign, arg); - w_long(SHORTLEN(len), arg); + w_long(SHORTLEN(len), arg); /* w_short? */ while (len--) { #if SIZEOF_BDIGITS > SIZEOF_SHORT BDIGIT num = *d; @@ -390,7 +390,7 @@ w_object(obj, arg, limit) w_uclass(obj, rb_cArray, arg); w_byte(TYPE_ARRAY, arg); { - int len = RARRAY(obj)->len; + long len = RARRAY(obj)->len; VALUE *ptr = RARRAY(obj)->ptr; w_long(len, arg); @@ -419,10 +419,10 @@ w_object(obj, arg, limit) case T_STRUCT: w_byte(TYPE_STRUCT, arg); { - int len = RSTRUCT(obj)->len; + long len = RSTRUCT(obj)->len; char *path = rb_class2name(CLASS_OF(obj)); VALUE mem; - int i; + long i; w_unique(path, arg); w_long(len, arg); @@ -597,12 +597,12 @@ r_long(arg) struct load_arg *arg; { register long x; - int c = (char)r_byte(arg); + int c = r_byte(arg); int i; if (c == 0) return 0; if (c > 0) { - if (c > sizeof(long)) long_toobig((int)c); + if (c > sizeof(long)) long_toobig(c); x = 0; for (i=0;i sizeof(long)) long_toobig((int)c); + if (c > sizeof(long)) long_toobig(c); x = -1; for (i=0;ifp) { @@ -655,7 +655,7 @@ r_symlink(arg) struct load_arg *arg; { ID id; - int num = r_long(arg); + long num = r_long(arg); if (st_lookup(arg->symbol, num, &id)) { return id; @@ -699,7 +699,7 @@ r_string(arg) struct load_arg *arg; { char *buf; - int len; + long len; r_bytes2(buf, len, arg); return rb_str_new(buf, len); @@ -723,7 +723,7 @@ r_ivar(obj, arg) VALUE obj; struct load_arg *arg; { - int len; + long len; len = r_long(arg); if (len > 0) { @@ -780,7 +780,7 @@ r_object(arg) case TYPE_FIXNUM: { - int i = r_long(arg); + long i = r_long(arg); return INT2FIX(i); } @@ -795,7 +795,7 @@ r_object(arg) case TYPE_BIGNUM: { - int len; + long len; BDIGIT *digits; NEWOBJ(big, struct RBignum); @@ -835,7 +835,7 @@ r_object(arg) case TYPE_REGEXP: { char *buf; - int len; + long len; int options; r_bytes2(buf, len, arg); @@ -845,7 +845,7 @@ r_object(arg) case TYPE_ARRAY: { - volatile int len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */ + volatile long len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */ v = rb_ary_new2(len); r_regist(v, arg); @@ -858,7 +858,7 @@ r_object(arg) case TYPE_HASH: case TYPE_HASH_DEF: { - int len = r_long(arg); + long len = r_long(arg); v = rb_hash_new(); r_regist(v, arg); @@ -876,8 +876,8 @@ r_object(arg) case TYPE_STRUCT: { VALUE klass, mem, values; - volatile int i; /* gcc 2.7.2.3 -O2 bug?? */ - int len; + volatile long i; /* gcc 2.7.2.3 -O2 bug?? */ + long len; ID slot; klass = rb_path2class(r_unique(arg)); @@ -1001,10 +1001,11 @@ marshal_load(argc, argv) VALUE *argv; { VALUE port, proc; - int major; + int major, minor; VALUE v; OpenFile *fptr; struct load_arg arg; + volatile VALUE hash; /* protect from GC */ rb_scan_args(argc, argv, "11", &port, &proc); if (rb_obj_is_kind_of(port, rb_cIO)) { @@ -1027,21 +1028,23 @@ marshal_load(argc, argv) } major = r_byte(&arg); - if (major == MARSHAL_MAJOR) { - volatile VALUE hash; /* protect from GC */ + minor = r_byte(&arg); + if (major != MARSHAL_MAJOR) { + rb_raise(rb_eTypeError, "incompatible marshal file format (can't be read)\n\ +\tformat version %d.%d required; %d.%d given", + MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); + } + if (minor != MARSHAL_MINOR) { + rb_warn("incompatible marshal file format (can be read)\n\ +\tformat version %d.%d required; %d.%d given", + MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); + } - if (r_byte(&arg) != MARSHAL_MINOR) { - rb_warn("Old marshal file format (can be read)"); - } - arg.symbol = st_init_numtable(); - arg.data = hash = rb_hash_new(); - if (NIL_P(proc)) arg.proc = 0; - else arg.proc = proc; - v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg); - } - else { - rb_raise(rb_eTypeError, "old marshal file format (can't read)"); - } + arg.symbol = st_init_numtable(); + arg.data = hash = rb_hash_new(); + if (NIL_P(proc)) arg.proc = 0; + else arg.proc = proc; + v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg); return v; } diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 5e252a28ae..ed35801958 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -592,7 +592,7 @@ An end of a defun is found by moving forward from the beginning of one." (setq start (ruby-calculate-indent)) (if (eobp) nil - (while (and (not (bobp)) (not done)) + (while (and (not (bobp)) (not (eobp)) (not done)) (forward-line n) (cond ((looking-at "^$")) diff --git a/pack.c b/pack.c index d06cec1c6f..5538600449 100644 --- a/pack.c +++ b/pack.c @@ -71,13 +71,13 @@ TOKEN_PASTE(swap,x)(z) \ } #if SIZEOF_SHORT == 2 -#define swaps(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF)) +#define swaps(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) #else #if SIZEOF_SHORT == 4 #define swaps(x) ((((x)&0xFF)<<24) \ - +(((x)>>24)&0xFF) \ - +(((x)&0x0000FF00)<<8) \ - +(((x)&0x00FF0000)>>8) ) + |(((x)>>24)&0xFF) \ + |(((x)&0x0000FF00)<<8) \ + |(((x)&0x00FF0000)>>8) ) #else define_swapx(s,short); #endif @@ -85,19 +85,19 @@ define_swapx(s,short); #if SIZEOF_LONG == 4 #define swapl(x) ((((x)&0xFF)<<24) \ - +(((x)>>24)&0xFF) \ - +(((x)&0x0000FF00)<<8) \ - +(((x)&0x00FF0000)>>8) ) + |(((x)>>24)&0xFF) \ + |(((x)&0x0000FF00)<<8) \ + |(((x)&0x00FF0000)>>8) ) #else #if SIZEOF_LONG == 8 #define swapl(x) ((((x)&0x00000000000000FF)<<56) \ - +(((x)&0xFF00000000000000)>>56) \ - +(((x)&0x000000000000FF00)<<40) \ - +(((x)&0x00FF000000000000)>>40) \ - +(((x)&0x0000000000FF0000)<<24) \ - +(((x)&0x0000FF0000000000)>>24) \ - +(((x)&0x00000000FF000000)<<8) \ - +(((x)&0x000000FF00000000)>>8)) + |(((x)&0xFF00000000000000)>>56) \ + |(((x)&0x000000000000FF00)<<40) \ + |(((x)&0x00FF000000000000)>>40) \ + |(((x)&0x0000000000FF0000)<<24) \ + |(((x)&0x0000FF0000000000)>>24) \ + |(((x)&0x00000000FF000000)<<8) \ + |(((x)&0x000000FF00000000)>>8)) #else define_swapx(l,long); #endif diff --git a/re.c b/re.c index a69cf1c7ec..bb9898fdb4 100644 --- a/re.c +++ b/re.c @@ -73,7 +73,7 @@ static const char casetable[] = { int rb_memcmp(p1, p2, len) char *p1, *p2; - size_t len; + long len; { int tmp; @@ -1054,7 +1054,7 @@ rb_reg_s_quote(argc, argv) for (; s < send; s++) { if (ismbchar(*s)) { - size_t n = mbclen(*s); + int n = mbclen(*s); while (n-- && s < send) *t++ = *s++; diff --git a/ruby.c b/ruby.c index 52c551c017..83fbc72176 100644 --- a/ruby.c +++ b/ruby.c @@ -208,7 +208,7 @@ ruby_init_loadpath() #if defined(_WIN32) || defined(DJGPP) || defined(__EMX__) char libpath[FILENAME_MAX+1]; char *p; - size_t rest; + int rest; #if defined(_WIN32) GetModuleFileName(NULL, libpath, sizeof libpath); #elif defined(DJGPP)