diff --git a/ChangeLog b/ChangeLog index 73650af2d4..8a73844365 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Oct 10 03:11:47 2001 Yukihiro Matsumoto + + * file.c (rb_stat_clone): should copy internal data too. + + * numeric.c (num_clone): Numeric should not be copied by clone. + + * object.c (rb_obj_clone): should check immediate values. + + * parse.y (command): `yield' should take command_args. + + * parse.y (parse_quotedwords): %w(...) is not a string. + Tue Oct 9 18:40:35 2001 WATANABE Hirofumi * process.c (Init_process): activate the case NT. diff --git a/eval.c b/eval.c index 6fe1124cbb..628758a93a 100644 --- a/eval.c +++ b/eval.c @@ -5232,7 +5232,7 @@ rb_obj_instance_eval(argc, argv, self) return specific_eval(argc, argv, klass, self); } -static VALUE +VALUE rb_mod_module_eval(argc, argv, mod) int argc; VALUE *argv; diff --git a/file.c b/file.c index e9c4edcaa0..c5d41d2f66 100644 --- a/file.c +++ b/file.c @@ -395,7 +395,11 @@ group_member(gid) # ifdef HAVE_GETGROUPS # ifndef NGROUPS +# ifdef NGROUPS_MAX +# define NGROUPS NGROUPS_MAX +# else # define NGROUPS 32 +# endif # endif { GETGROUPS_T gary[NGROUPS]; @@ -1908,6 +1912,25 @@ rb_stat_init(obj, fname) return Qnil; } +static VALUE +rb_stat_clone(obj) + VALUE obj; +{ + struct stat st, *nst; + + VALUE clone; + + clone = rb_obj_alloc(RBASIC(obj)->klass); + CLONESETUP(clone,obj); + if (DATA_PTR(obj)) { + nst = ALLOC(struct stat); + *nst = *(struct stat*)DATA_PTR(obj); + DATA_PTR(clone) = nst; + } + + return clone; +} + static VALUE rb_stat_ftype(obj) VALUE obj; @@ -2509,6 +2532,7 @@ Init_File() rb_cStat = rb_define_class_under(rb_cFile, "Stat", rb_cObject); rb_define_singleton_method(rb_cStat, "allocate", rb_stat_s_alloc, 0); rb_define_method(rb_cStat, "initialize", rb_stat_init, 1); + rb_define_method(rb_cStat, "clone", rb_stat_clone, 0); rb_include_module(rb_cStat, rb_mComparable); diff --git a/intern.h b/intern.h index 4ea537c951..eedbab3da4 100644 --- a/intern.h +++ b/intern.h @@ -141,6 +141,7 @@ VALUE rb_apply _((VALUE, ID, VALUE)); void rb_backtrace _((void)); ID rb_frame_last_func _((void)); VALUE rb_obj_instance_eval _((int, VALUE*, VALUE)); +VALUE rb_mod_module_eval _((int, VALUE*, VALUE)); void rb_load _((VALUE, int)); void rb_load_protect _((VALUE, int, int*)); NORETURN(void rb_jump_tag _((int))); diff --git a/numeric.c b/numeric.c index 9c0f6f31d6..4f11fceec3 100644 --- a/numeric.c +++ b/numeric.c @@ -91,8 +91,9 @@ static VALUE num_clone(x) VALUE x; { - /* Numerics are immutable values, which need not to copy */ - return x; + /* Numerics are immutable values, which should not be copied */ + rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(x))); + return Qnil; /* not reached */ } static VALUE diff --git a/object.c b/object.c index e2bc29b065..b2580d9904 100644 --- a/object.c +++ b/object.c @@ -94,6 +94,9 @@ rb_obj_clone(obj) { VALUE clone; + if (rb_special_const_p(obj)) { + rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(obj))); + } clone = rb_obj_alloc(RBASIC(obj)->klass); CLONESETUP(clone,obj); if (TYPE(clone) == T_OBJECT && ROBJECT(obj)->iv_tbl) { @@ -587,10 +590,12 @@ rb_mod_cmp(mod, arg) } static VALUE -rb_mod_initialize(argc, argv) +rb_mod_initialize(argc, argv, module) int argc; VALUE *argv; + VALUE module; { + rb_mod_module_eval(0, 0, module); return Qnil; } diff --git a/parse.y b/parse.y index e3d0eb8140..d7ed5b5f58 100644 --- a/parse.y +++ b/parse.y @@ -208,7 +208,7 @@ static void top_local_setup(); %token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR %token tINTEGER tFLOAT tSTRING tXSTRING tREGEXP -%token tDSTRING tDXSTRING tDREGEXP tNTH_REF tBACK_REF +%token tDSTRING tDXSTRING tDREGEXP tNTH_REF tBACK_REF tQWORDS %type singleton string %type literal numeric @@ -510,7 +510,7 @@ command : operation command_args $$ = new_super($2); fixpos($$, $2); } - | kYIELD call_args + | kYIELD command_args { $$ = NEW_YIELD(ret_args($2)); fixpos($$, $2); @@ -1163,6 +1163,7 @@ primary : literal { $$ = NEW_XSTR($1); } + | tQWORDS | tDXSTRING | tDREGEXP | var_ref @@ -2742,7 +2743,7 @@ parse_quotedwords(term, paren) if (!qwords) qwords = NEW_ZARRAY(); yylval.node = qwords; lex_state = EXPR_END; - return tDSTRING; + return tQWORDS; } static int