diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ToDo | 1 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | intern.h | 2 | ||||
-rw-r--r-- | keywords | 4 | ||||
-rw-r--r-- | lex.c | 4 | ||||
-rw-r--r-- | lib/timeout.rb | 16 | ||||
-rw-r--r-- | marshal.c | 7 | ||||
-rw-r--r-- | object.c | 10 | ||||
-rw-r--r-- | parse.y | 10 | ||||
-rw-r--r-- | range.c | 2 | ||||
-rw-r--r-- | regex.c | 3 | ||||
-rw-r--r-- | string.c | 4 | ||||
-rw-r--r-- | struct.c | 32 | ||||
-rw-r--r-- | variable.c | 31 | ||||
-rw-r--r-- | version.h | 4 |
16 files changed, 101 insertions, 52 deletions
@@ -1,3 +1,20 @@ +Mon Aug 20 13:24:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * range.c (range_step): 'iter' here should be an array. + +Mon Aug 20 12:43:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * marshal.c (w_object): should retrieve __member__ data from + non-singleton class. + +Sat Aug 18 23:11:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * variable.c (rb_cvar_get): class variable override check added. + + * variable.c (rb_cvar_set): ditto + + * variable.c (rb_cvar_declare): ditto. + Fri Aug 17 12:13:48 2001 Minero Aoki <aamine@loveruby.net> * lib/net/protocol.rb: Protocol.new requires at least one arg. @@ -8,6 +25,10 @@ Fri Aug 17 12:13:48 2001 Minero Aoki <aamine@loveruby.net> * lib/net/http.rb: ditto. +Fri Aug 17 00:49:51 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (parse_regx): handle backslash escaping of delimiter here. + Thu Aug 16 13:54:04 2001 Usaku Nakamura <usa@ruby-lang.org> * ext/socket/socket.c (s_recvfrom): fix typo. @@ -27,6 +27,7 @@ Language Spec. * raise exception by `` error * jar like combined library package. * resumable Exception via Exception#resume. +* method combination, e.g. before, after, around, etc. Hacking Interpreter @@ -732,7 +732,7 @@ rb_ary_dup(ary) { VALUE dup = rb_ary_new2(RARRAY(ary)->len); - OBJSETUP(dup, rb_obj_type(ary), T_ARRAY); + OBJSETUP(dup, rb_obj_class(ary), T_ARRAY); MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len); RARRAY(dup)->len = RARRAY(ary)->len; OBJ_INFECT(dup, ary); @@ -244,7 +244,7 @@ VALUE rb_obj_tainted _((VALUE)); VALUE rb_obj_untaint _((VALUE)); VALUE rb_obj_freeze _((VALUE)); VALUE rb_obj_id _((VALUE)); -VALUE rb_obj_type _((VALUE)); +VALUE rb_obj_class _((VALUE)); VALUE rb_class_real _((VALUE)); VALUE rb_convert_type _((VALUE,int,const char*,const char*)); VALUE rb_to_int _((VALUE)); @@ -7,7 +7,7 @@ END, klEND, klEND, EXPR_END alias, kALIAS, kALIAS, EXPR_FNAME and, kAND, kAND, EXPR_BEG begin, kBEGIN, kBEGIN, EXPR_BEG -break, kBREAK, kBREAK, EXPR_END +break, kBREAK, kBREAK, EXPR_MID case, kCASE, kCASE, EXPR_BEG class, kCLASS, kCLASS, EXPR_CLASS def, kDEF, kDEF, EXPR_FNAME @@ -22,7 +22,7 @@ for, kFOR, kFOR, EXPR_BEG if, kIF, kIF_MOD, EXPR_BEG in, kIN, kIN, EXPR_BEG module, kMODULE, kMODULE, EXPR_BEG -next, kNEXT, kNEXT, EXPR_END +next, kNEXT, kNEXT, EXPR_MID nil, kNIL, kNIL, EXPR_END not, kNOT, kNOT, EXPR_BEG or, kOR, kOR, EXPR_BEG @@ -97,14 +97,14 @@ rb_reserved_word (str, len) {"defined?", kDEFINED, kDEFINED, EXPR_ARG}, {"super", kSUPER, kSUPER, EXPR_ARG}, {"undef", kUNDEF, kUNDEF, EXPR_FNAME}, - {"break", kBREAK, kBREAK, EXPR_END}, + {"break", kBREAK, kBREAK, EXPR_MID}, {"in", kIN, kIN, EXPR_BEG}, {"do", kDO, kDO, EXPR_BEG}, {"nil", kNIL, kNIL, EXPR_END}, {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG}, {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG}, {"or", kOR, kOR, EXPR_BEG}, - {"next", kNEXT, kNEXT, EXPR_END}, + {"next", kNEXT, kNEXT, EXPR_MID}, {"when", kWHEN, kWHEN, EXPR_BEG}, {"redo", kREDO, kREDO, EXPR_END}, {"and", kAND, kAND, EXPR_BEG}, diff --git a/lib/timeout.rb b/lib/timeout.rb index dd7cb306cf..afa4e0b68c 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -25,7 +25,7 @@ # #=end -class TimeoutError<StandardError +class TimeoutError<Interrupt end def timeout(sec) @@ -37,14 +37,20 @@ def timeout(sec) x.raise TimeoutError, "execution expired" if x.alive? } yield sec - return true +# return true ensure - Thread.kill y if y and y.alive? + y.kill if y and y.alive? end end if __FILE__ == $0 - timeout(5) { - p 10 + p timeout(5) { + 45 + } + p timeout(5) { + loop { + p 10 + sleep 1 + } } end @@ -293,7 +293,7 @@ w_object(obj, arg, limit) w_byte(TYPE_FIXNUM, arg); w_long(FIX2INT(obj), arg); #else - if (RSHIFT((long)obj, 32) == 0 || RSHIFT((long)obj, 32) == -1) { + if (RSHIFT((long)obj, 30) == 0 || RSHIFT((long)obj, 30) == -1) { w_byte(TYPE_FIXNUM, arg); w_long(FIX2LONG(obj), arg); } @@ -447,13 +447,12 @@ w_object(obj, arg, limit) w_byte(TYPE_STRUCT, arg); { long len = RSTRUCT(obj)->len; - char *path = rb_class2name(CLASS_OF(obj)); VALUE mem; long i; - w_unique(path, arg); + w_unique(rb_class2name(CLASS_OF(obj)), arg); w_long(len, arg); - mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__")); + mem = rb_ivar_get(rb_obj_class(obj), rb_intern("__member__")); if (mem == Qnil) { rb_raise(rb_eTypeError, "uninitialized struct"); } @@ -81,7 +81,7 @@ rb_class_real(cl) } VALUE -rb_obj_type(obj) +rb_obj_class(obj) VALUE obj; { return rb_class_real(CLASS_OF(obj)); @@ -116,7 +116,7 @@ rb_obj_dup(obj) rb_raise(rb_eTypeError, "dupulicated object must be same type"); } if (!SPECIAL_CONST_P(dup)) { - OBJSETUP(dup, rb_obj_type(obj), BUILTIN_TYPE(obj)); + OBJSETUP(dup, rb_obj_class(obj), BUILTIN_TYPE(obj)); OBJ_INFECT(dup, obj); if (FL_TEST(obj, FL_EXIVAR)) { FL_SET(dup, FL_EXIVAR); @@ -233,7 +233,7 @@ rb_obj_is_instance_of(obj, c) rb_raise(rb_eTypeError, "class or module required"); } - if (rb_obj_type(obj) == c) return Qtrue; + if (rb_obj_class(obj) == c) return Qtrue; return Qfalse; } @@ -1155,8 +1155,8 @@ Init_Object() rb_define_method(rb_mKernel, "hash", rb_obj_id, 0); rb_define_method(rb_mKernel, "id", rb_obj_id, 0); rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0); - rb_define_method(rb_mKernel, "type", rb_obj_type, 0); - rb_define_method(rb_mKernel, "class", rb_obj_type, 0); + rb_define_method(rb_mKernel, "type", rb_obj_class, 0); + rb_define_method(rb_mKernel, "class", rb_obj_class, 0); rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0); rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0); @@ -2327,7 +2327,8 @@ read_escape() } static int -tokadd_escape() +tokadd_escape(term) + int term; { int c; @@ -2388,7 +2389,7 @@ tokadd_escape() tokadd('\\'); tokadd('c'); escaped: if ((c = nextc()) == '\\') { - return tokadd_escape(); + return tokadd_escape(term); } else if (c == -1) goto eof; tokadd(c); @@ -2400,7 +2401,8 @@ tokadd_escape() return -1; default: - tokadd('\\'); + if (c == '/' && c != term) + tokadd('\\'); tokadd(c); } return 0; @@ -2431,7 +2433,7 @@ parse_regx(term, paren) continue; case '\\': - if (tokadd_escape() < 0) + if (tokadd_escape(term) < 0) return 0; continue; @@ -286,7 +286,7 @@ range_step(argc, argv, range) } else if (TYPE(b) == T_STRING) { VALUE args[5]; - long *iter; + long iter[2]; args[0] = b; args[1] = e; args[2] = range; iter[0] = 1; iter[1] = NUM2LONG(step); @@ -2897,6 +2897,7 @@ re_compile_fastmap(bufp) case duplicate: bufp->can_be_null = 1; + if (*p >= bufp->re_nsub) break; fastmap['\n'] = 1; case anychar_repeat: case anychar: @@ -3740,6 +3741,8 @@ re_match(bufp, string_arg, size, pos, regs) int regno = *p++; /* Get which register to match against */ register unsigned char *d2, *dend2; + /* Check if there's corresponding group */ + if (regno >= num_regs) goto fail; /* Check if corresponding group is still open */ if (IS_ACTIVE(reg_info[regno])) goto fail; @@ -100,7 +100,7 @@ rb_str_new4(orig) { VALUE klass; - klass = rb_obj_type(orig); + klass = rb_obj_class(orig); if (RSTRING(orig)->orig) { VALUE str; @@ -257,7 +257,7 @@ rb_str_dup(str) VALUE klass; StringValue(str); - klass = rb_obj_type(str); + klass = rb_obj_class(str); if (OBJ_FROZEN(str)) str2 = rb_str_new3(str); else if (FL_TEST(str, STR_NO_ORIG)) { @@ -17,16 +17,6 @@ VALUE rb_cStruct; static VALUE struct_alloc _((int, VALUE*, VALUE)); static VALUE -class_of(obj) - VALUE obj; -{ - obj = CLASS_OF(obj); - if (FL_TEST(obj, FL_SINGLETON)) - return RCLASS(obj)->super; - return obj; -} - -static VALUE iv_get(obj, name) VALUE obj; char *name; @@ -68,7 +58,7 @@ static VALUE rb_struct_members(obj) VALUE obj; { - return rb_struct_s_members(class_of(obj)); + return rb_struct_s_members(rb_obj_class(obj)); } VALUE @@ -79,7 +69,7 @@ rb_struct_getmember(obj, id) VALUE member, slot; long i; - member = iv_get(class_of(obj), "__member__"); + member = iv_get(rb_obj_class(obj), "__member__"); if (NIL_P(member)) { rb_bug("uninitialized struct"); } @@ -140,7 +130,7 @@ rb_struct_set(obj, val) VALUE member, slot; long i; - member = iv_get(class_of(obj), "__member__"); + member = iv_get(rb_obj_class(obj), "__member__"); if (NIL_P(member)) { rb_bug("non-initialized struct"); } @@ -260,7 +250,7 @@ static VALUE rb_struct_initialize(self, values) VALUE self, values; { - VALUE klass = CLASS_OF(self); + VALUE klass = rb_obj_class(self); VALUE size; long n; @@ -349,7 +339,7 @@ static VALUE rb_struct_to_s(s) VALUE s; { - char *cname = rb_class2name(CLASS_OF(s)); + char *cname = rb_class2name(rb_obj_class(s)); VALUE str = rb_str_new(0, strlen(cname) + 4); sprintf(RSTRING(str)->ptr, "#<%s>", cname); @@ -361,11 +351,11 @@ static VALUE inspect_struct(s) VALUE s; { - char *cname = rb_class2name(CLASS_OF(s)); + char *cname = rb_class2name(rb_obj_class(s)); VALUE str, member; long i; - member = iv_get(CLASS_OF(s), "__member__"); + member = iv_get(rb_obj_class(s), "__member__"); if (NIL_P(member)) { rb_bug("non-initialized struct"); } @@ -398,7 +388,7 @@ rb_struct_inspect(s) VALUE s; { if (rb_inspecting_p(s)) { - char *cname = rb_class2name(CLASS_OF(s)); + char *cname = rb_class2name(rb_obj_class(s)); VALUE str = rb_str_new(0, strlen(cname) + 8); sprintf(RSTRING(str)->ptr, "#<%s:...>", cname); @@ -436,7 +426,7 @@ rb_struct_aref_id(s, id) VALUE member; long i, len; - member = iv_get(CLASS_OF(s), "__member__"); + member = iv_get(rb_obj_class(s), "__member__"); if (NIL_P(member)) { rb_bug("non-initialized struct"); } @@ -480,7 +470,7 @@ rb_struct_aset_id(s, id, val) VALUE member; long i, len; - member = iv_get(CLASS_OF(s), "__member__"); + member = iv_get(rb_obj_class(s), "__member__"); if (NIL_P(member)) { rb_bug("non-initialized struct"); } @@ -527,7 +517,7 @@ rb_struct_equal(s, s2) long i; if (TYPE(s2) != T_STRUCT) return Qfalse; - if (CLASS_OF(s) != CLASS_OF(s2)) return Qfalse; + if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse; if (RSTRUCT(s)->len != RSTRUCT(s2)->len) { rb_bug("inconsistent struct"); /* should never happen */ } diff --git a/variable.c b/variable.c index 8090efd76c..eab951d102 100644 --- a/variable.c +++ b/variable.c @@ -1376,6 +1376,22 @@ rb_cvar_singleton(obj) return CLASS_OF(obj); } +static void +cvar_override_check(id, a, b) + VALUE a, b; +{ + a = RCLASS(a)->super; + while (a) { + if (!RCLASS(a)->iv_tbl) continue; + if (st_lookup(RCLASS(a)->iv_tbl,id,0)) { + rb_warning("class variable %s of %s is overridden by %s", + rb_id2name(id), rb_class2name(a), + rb_class2name(b)); + } + a = RCLASS(a)->super; + } +} + void rb_cvar_set(klass, id, val) VALUE klass; @@ -1386,10 +1402,14 @@ rb_cvar_set(klass, id, val) tmp = klass; while (tmp) { - if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) { + if (!RCLASS(tmp)->iv_tbl) continue; + if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) { if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify class variable"); st_insert(RCLASS(tmp)->iv_tbl,id,val); + if (ruby_verbose) { + cvar_override_check(id, tmp, klass); + } return; } tmp = RCLASS(tmp)->super; @@ -1416,6 +1436,9 @@ rb_cvar_declare(klass, id, val) rb_warning("already initialized class variable %s", rb_id2name(id)); } st_insert(RCLASS(tmp)->iv_tbl,id,val); + if (ruby_verbose) { + cvar_override_check(id, tmp, klass); + } return; } tmp = RCLASS(tmp)->super; @@ -1434,7 +1457,11 @@ rb_cvar_get(klass, id) tmp = klass; while (tmp) { - if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { + if (!RCLASS(tmp)->iv_tbl) continue; + if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { + if (ruby_verbose) { + cvar_override_check(id, tmp, klass); + } return value; } tmp = RCLASS(tmp)->super; @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.1" -#define RUBY_RELEASE_DATE "2001-08-16" +#define RUBY_RELEASE_DATE "2001-08-20" #define RUBY_VERSION_CODE 171 -#define RUBY_RELEASE_CODE 20010816 +#define RUBY_RELEASE_CODE 20010820 |