summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-10-10 08:21:13 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-10-10 08:21:13 +0000
commit8098dd6c802db53a0e879efb7e48e75981f043d3 (patch)
tree96377ab531ba1336b6b63a5e2eb6382456312bcb
parent14129c8fa30055b25036e490c0b8d87ffcfa34b2 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--eval.c2
-rw-r--r--file.c24
-rw-r--r--intern.h1
-rw-r--r--numeric.c5
-rw-r--r--object.c7
-rw-r--r--parse.y7
7 files changed, 51 insertions, 7 deletions
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 <matz@ruby-lang.org>
+
+ * 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 <eban@ruby-lang.org>
* 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];
@@ -1909,6 +1913,25 @@ rb_stat_init(obj, fname)
}
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 <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR
%token <val> tINTEGER tFLOAT tSTRING tXSTRING tREGEXP
-%token <node> tDSTRING tDXSTRING tDREGEXP tNTH_REF tBACK_REF
+%token <node> tDSTRING tDXSTRING tDREGEXP tNTH_REF tBACK_REF tQWORDS
%type <node> singleton string
%type <val> 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