diff --git a/ChangeLog b/ChangeLog index fa1855a8ee..74668f42e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Mon Aug 20 13:24:08 2001 Yukihiro Matsumoto + + * range.c (range_step): 'iter' here should be an array. + +Mon Aug 20 12:43:08 2001 Yukihiro Matsumoto + + * marshal.c (w_object): should retrieve __member__ data from + non-singleton class. + +Sat Aug 18 23:11:14 2001 Yukihiro Matsumoto + + * 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 * lib/net/protocol.rb: Protocol.new requires at least one arg. @@ -8,6 +25,10 @@ Fri Aug 17 12:13:48 2001 Minero Aoki * lib/net/http.rb: ditto. +Fri Aug 17 00:49:51 2001 Yukihiro Matsumoto + + * parse.y (parse_regx): handle backslash escaping of delimiter here. + Thu Aug 16 13:54:04 2001 Usaku Nakamura * ext/socket/socket.c (s_recvfrom): fix typo. diff --git a/ToDo b/ToDo index 7eb823c370..3bd014f892 100644 --- a/ToDo +++ b/ToDo @@ -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 diff --git a/array.c b/array.c index 9bfd24041e..918dd12056 100644 --- a/array.c +++ b/array.c @@ -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); diff --git a/intern.h b/intern.h index 32970ddd81..f427791267 100644 --- a/intern.h +++ b/intern.h @@ -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)); diff --git a/keywords b/keywords index 7bf0d696ac..6ba1be49fd 100644 --- a/keywords +++ b/keywords @@ -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 diff --git a/lex.c b/lex.c index a5fb82ebc9..67f1337987 100644 --- a/lex.c +++ b/lex.c @@ -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 TimeoutErrorlen; - 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"); } diff --git a/object.c b/object.c index f60234411a..6f4a29354b 100644 --- a/object.c +++ b/object.c @@ -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); diff --git a/parse.y b/parse.y index bebfc3a5ac..c9337bce3a 100644 --- a/parse.y +++ b/parse.y @@ -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; diff --git a/range.c b/range.c index 063da06bca..4ea1df2442 100644 --- a/range.c +++ b/range.c @@ -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); diff --git a/regex.c b/regex.c index 206e99a0ca..9a38c00581 100644 --- a/regex.c +++ b/regex.c @@ -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; diff --git a/string.c b/string.c index c80f356b37..45f768c53d 100644 --- a/string.c +++ b/string.c @@ -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)) { diff --git a/struct.c b/struct.c index f8e6b6f3e0..d489026b3f 100644 --- a/struct.c +++ b/struct.c @@ -16,16 +16,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; @@ -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; diff --git a/version.h b/version.h index 0ad553e1e0..dcecd4ae91 100644 --- a/version.h +++ b/version.h @@ -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