diff --git a/ChangeLog b/ChangeLog index 7939e28b07..340b74624a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Wed Sep 4 15:23:23 2002 Yukihiro Matsumoto + + * class.c (rb_make_metaclass): obj.meta.super.meta should be equal + to obj.meta.meta.super (ruby-bugs-ja:PR#324). + +Wed Sep 04 05:10:16 2002 Koji Arai + + * parse.y (yylex): the warning message "invalid + character syntax" was never issued. + +Wed Sep 4 01:08:45 2002 Yukihiro Matsumoto + + * marshal.c (r_bytes): do not use alloca (ruby-bugs:PR#382). + Tue Sep 3 17:12:59 2002 WATANABE Hirofumi * extmk.rb: require mkmf.rb. remove duplicate methods. diff --git a/class.c b/class.c index 1930a2da67..65187f50d0 100644 --- a/class.c +++ b/class.c @@ -149,6 +149,9 @@ rb_make_metaclass(obj, super) rb_singleton_class_attached(klass, obj); if (BUILTIN_TYPE(obj) == T_CLASS) { RBASIC(klass)->klass = klass; + if (FL_TEST(obj, FL_SINGLETON)) { + RCLASS(klass)->super = RBASIC(RCLASS(obj)->super)->klass; + } } return klass; diff --git a/ext/digest/digest.c b/ext/digest/digest.c index f4f5729f32..49991dd97d 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -149,7 +149,6 @@ rb_digest_base_become(copy, obj) void *pctx1, *pctx2; VALUE klass; - printf("Digest::Base::bacome\n"); if (copy = obj) return copy; rb_check_frozen(copy); algo = get_digest_base_metadata(CLASS_OF(klass)); @@ -302,7 +301,6 @@ Init_digest() cDigest_Base = rb_define_class_under(mDigest, "Base", rb_cObject); - printf("Init_digest\n"); rb_define_singleton_method(cDigest_Base, "allocate", rb_digest_base_alloc, 0); rb_define_singleton_method(cDigest_Base, "digest", rb_digest_base_s_digest, 1); rb_define_singleton_method(cDigest_Base, "hexdigest", rb_digest_base_s_hexdigest, 1); diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c index 69b15c5b39..7f6a6e9794 100644 --- a/ext/digest/md5/md5init.c +++ b/ext/digest/md5/md5init.c @@ -26,6 +26,6 @@ Init_md5() cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base); - rb_cvar_declare(cDigest_MD5, rb_intern("metadata"), - Data_Wrap_Struct(rb_cObject, 0, 0, &md5)); + rb_cvar_set(cDigest_MD5, rb_intern("metadata"), + Data_Wrap_Struct(rb_cObject, 0, 0, &md5), Qtrue); } diff --git a/marshal.c b/marshal.c index 78d801bbb2..6a337d208f 100644 --- a/marshal.c +++ b/marshal.c @@ -702,25 +702,18 @@ r_long(arg) return x; } -#define r_bytes2(s, len, arg) do { \ - (len) = r_long(arg); \ - (s) = ALLOCA_N(char,(len)+1); \ - r_bytes0((s),(len),(arg)); \ -} while (0) +#define r_bytes(arg) r_bytes0(r_long(arg), (arg)) -#define r_bytes(s, arg) do { \ - long r_bytes_len; \ - r_bytes2((s), r_bytes_len, (arg)); \ -} while (0) - -static void -r_bytes0(s, len, arg) - char *s; +static VALUE +r_bytes0(len, arg) long len; struct load_arg *arg; { + VALUE str; + if (arg->fp) { - if (rb_io_fread(s, len, arg->fp) != len) { + str = rb_str_new(0, len); + if (rb_io_fread(RSTRING(str)->ptr, len, arg->fp) != len) { too_short: rb_raise(rb_eArgError, "marshal data too short"); } @@ -729,10 +722,10 @@ r_bytes0(s, len, arg) if (arg->ptr + len > arg->end) { goto too_short; } - memcpy(s, arg->ptr, len); + str = rb_str_new(arg->ptr, len); arg->ptr += len; } - s[len] = '\0'; + return str; } static ID @@ -752,11 +745,9 @@ static ID r_symreal(arg) struct load_arg *arg; { - char *buf; ID id; - r_bytes(buf, arg); - id = rb_intern(buf); + id = rb_intern(RSTRING(r_bytes(arg))->ptr); st_insert(arg->symbol, arg->symbol->num_entries, id); return id; @@ -783,11 +774,7 @@ static VALUE r_string(arg) struct load_arg *arg; { - char *buf; - long len; - - r_bytes2(buf, len, arg); - return rb_str_new(buf, len); + return r_bytes(arg); } static VALUE @@ -879,21 +866,20 @@ r_object0(arg, proc) case TYPE_FLOAT: { - char *buf; double d, t = 0.0; + VALUE str = r_bytes(arg); - r_bytes(buf, arg); - if (strcmp(buf, "nan") == 0) { + if (strcmp(RSTRING(str)->ptr, "nan") == 0) { d = t / t; } - else if (strcmp(buf, "inf") == 0) { + else if (strcmp(RSTRING(str)->ptr, "inf") == 0) { d = 1.0 / t; } - else if (strcmp(buf, "-inf") == 0) { + else if (strcmp(RSTRING(str)->ptr, "-inf") == 0) { d = -1.0 / t; } else { - d = strtod(buf, 0); + d = strtod(RSTRING(str)->ptr, 0); } v = rb_float_new(d); r_regist(v, arg); @@ -944,13 +930,9 @@ r_object0(arg, proc) case TYPE_REGEXP: { - char *buf; - long len; - int options; - - r_bytes2(buf, len, arg); - options = r_byte(arg); - v = r_regist(rb_reg_new(buf, len, options), arg); + volatile VALUE str = r_bytes(arg); + int options = r_byte(arg); + v = r_regist(rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, options), arg); } break; @@ -1077,19 +1059,17 @@ r_object0(arg, proc) case TYPE_MODULE_OLD: { - char *buf; - r_bytes(buf, arg); - v = r_regist(rb_path2class(buf), arg); + volatile VALUE str = r_bytes(arg); + v = r_regist(rb_path2class(RSTRING(str)->ptr), arg); } break; case TYPE_CLASS: { - char *buf; - r_bytes(buf, arg); - v = rb_path2class(buf); + volatile VALUE str = r_bytes(arg); + v = rb_path2class(RSTRING(str)->ptr); if (TYPE(v) != T_CLASS) { - rb_raise(rb_eTypeError, "%s is not a class", buf); + rb_raise(rb_eTypeError, "%s is not a class", RSTRING(str)->ptr); } r_regist(v, arg); } @@ -1097,11 +1077,10 @@ r_object0(arg, proc) case TYPE_MODULE: { - char *buf; - r_bytes(buf, arg); - v = rb_path2class(buf); + volatile VALUE str = r_bytes(arg); + v = rb_path2class(RSTRING(str)->ptr); if (TYPE(v) != T_MODULE) { - rb_raise(rb_eTypeError, "%s is not a module", buf); + rb_raise(rb_eTypeError, "%s is not a module", RSTRING(str)->ptr); } r_regist(v, arg); } diff --git a/object.c b/object.c index d26efe1837..71f5e99bdc 100644 --- a/object.c +++ b/object.c @@ -94,8 +94,12 @@ static void copy_object(dest, obj) VALUE dest, obj; { - RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR|FL_TAINT); + if (OBJ_FROZEN(dest)) { + rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_class2name(CLASS_OF(dest))); + } + RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR); RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT); + rb_funcall(dest, become, 1, obj); if (FL_TEST(obj, FL_EXIVAR)) { rb_copy_generic_ivar(dest, obj); } @@ -123,10 +127,9 @@ rb_obj_clone(obj) rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(obj))); } clone = rb_obj_alloc(rb_obj_class(obj)); - RBASIC(clone)->klass = rb_singleton_class_clone(obj); copy_object(clone, obj); - rb_funcall(clone, become, 1, obj); - RBASIC(clone)->flags = RBASIC(obj)->flags; + RBASIC(clone)->klass = rb_singleton_class_clone(obj); + RBASIC(clone)->flags = RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT); return clone; } @@ -142,7 +145,6 @@ rb_obj_dup(obj) } dup = rb_obj_alloc(rb_obj_class(obj)); copy_object(dup, obj); - rb_funcall(dup, become, 1, obj); return dup; } diff --git a/parse.y b/parse.y index 661188e95d..702252acf0 100644 --- a/parse.y +++ b/parse.y @@ -3345,23 +3345,29 @@ yylex() } if (ISSPACE(c)){ if (!IS_ARG()){ - int c = 0; + int c2 = 0; switch (c) { case ' ': - c = 's'; + c2 = 's'; break; case '\n': - c = 'n'; + c2 = 'n'; break; case '\t': - c = 't'; + c2 = 't'; break; case '\v': - c = 'v'; + c2 = 'v'; + break; + case '\r': + c2 = 'r'; + break; + case '\f': + c2 = 'f'; break; } - if (c) { - rb_warn("invalid character syntax; use ?\\%c", c); + if (c2) { + rb_warn("invalid character syntax; use ?\\%c", c2); } } ternary: diff --git a/version.h b/version.h index c32cdd284e..a751a2adb8 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.3" -#define RUBY_RELEASE_DATE "2002-09-03" +#define RUBY_RELEASE_DATE "2002-09-04" #define RUBY_VERSION_CODE 173 -#define RUBY_RELEASE_CODE 20020903 +#define RUBY_RELEASE_CODE 20020904