summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-27 04:50:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-27 04:50:30 +0000
commitbf95c21de1a5a91a969b2677504da262c8cb1c21 (patch)
tree9c8fcdf87cfc279f6dd3348de22d1bc74f26f48a
parenta08335cc90e1e6d559b0ead207c42babe424ec57 (diff)
* eval.c (rb_f_missing): NoMethod error messages for true, false,
nil must respond visibility like for other objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--eval.c47
-rw-r--r--intern.h18
-rw-r--r--marshal.c115
-rw-r--r--node.h4
-rw-r--r--process.c1
-rw-r--r--ruby.h32
-rw-r--r--rubysig.h2
8 files changed, 131 insertions, 97 deletions
diff --git a/ChangeLog b/ChangeLog
index cc45f255e1..6bb3ca56f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 27 13:49:24 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.6.6 released.
+
Wed Feb 27 13:18:49 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* io.c (READ_DATA_PENDING): uClibc support.
@@ -19,6 +23,11 @@ Tue Feb 26 21:36:01 2002 Usaku Nakamura <usa@ruby-lang.org>
* bignum.c (rb_big_2comp): void function cannot return any value.
+Tue Feb 26 16:52:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_missing): NoMethod error messages for true, false,
+ nil must respond visibility like for other objects.
+
Tue Feb 26 11:25:50 2002 akira yamada <akira@arika.org>
* lib/uri/generic.rb: merge0 shuld return [oth, oth] if oth is
diff --git a/eval.c b/eval.c
index a165b25cf1..5f10499de1 100644
--- a/eval.c
+++ b/eval.c
@@ -4082,7 +4082,7 @@ rb_f_missing(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- ID id;
+ ID id, noclass;
volatile VALUE d = 0;
char *format = 0;
char *desc = "";
@@ -4096,17 +4096,16 @@ rb_f_missing(argc, argv, obj)
rb_stack_check();
id = SYM2ID(argv[0]);
- argc--; argv++;
switch (TYPE(obj)) {
case T_NIL:
- format = "undefined method `%s' for nil";
+ desc = "nil";
break;
case T_TRUE:
- format = "undefined method `%s' for true";
+ desc = "true";
break;
case T_FALSE:
- format = "undefined method `%s' for false";
+ desc = "false";
break;
case T_OBJECT:
d = rb_any_to_s(obj);
@@ -4116,36 +4115,38 @@ rb_f_missing(argc, argv, obj)
break;
}
if (d) {
- if (last_call_status & CSTAT_PRIV) {
- format = "private method `%s' called for %s%s%s";
- }
- if (last_call_status & CSTAT_PROT) {
- format = "protected method `%s' called for %s%s%s";
- }
- else if (last_call_status & CSTAT_VCALL) {
- const char *mname = rb_id2name(id);
-
- if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
- format = "undefined local variable or method `%s' for %s%s%s";
- }
- }
- if (!format) {
- format = "undefined method `%s' for %s%s%s";
- }
if (RSTRING(d)->len > 65) {
d = rb_any_to_s(obj);
}
desc = RSTRING(d)->ptr;
}
+ if (last_call_status & CSTAT_PRIV) {
+ format = "private method `%s' called for %s%s%s";
+ }
+ if (last_call_status & CSTAT_PROT) {
+ format = "protected method `%s' called for %s%s%s";
+ }
+ else if (last_call_status & CSTAT_VCALL) {
+ const char *mname = rb_id2name(id);
+
+ if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
+ format = "undefined local variable or method `%s' for %s%s%s";
+ }
+ }
+ if (!format) {
+ format = "undefined method `%s' for %s%s%s";
+ }
+
ruby_sourcefile = file;
ruby_sourceline = line;
PUSH_FRAME(); /* fake frame */
*ruby_frame = *_frame.prev->prev;
+ noclass = (!d || desc[0]=='#');
rb_raise(rb_eNameError, format, rb_id2name(id),
- desc, desc[0]=='#'?"":":",
- desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
+ desc, noclass ? "" : ":",
+ noclass ? "" : rb_class2name(CLASS_OF(obj)));
POP_FRAME();
return Qnil; /* not reached */
diff --git a/intern.h b/intern.h
index 7bcaaf7a08..4ed572e7a5 100644
--- a/intern.h
+++ b/intern.h
@@ -95,13 +95,13 @@ VALUE rb_class_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
VALUE rb_obj_singleton_methods _((VALUE));
-void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
+void rb_define_method_id _((VALUE, ID, VALUE (*)(ANYARGS), int));
void rb_frozen_class_p _((VALUE));
void rb_undef _((VALUE, ID));
-void rb_define_protected_method _((VALUE, const char*, VALUE (*)(), int));
-void rb_define_private_method _((VALUE, const char*, VALUE (*)(), int));
-void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(),int));
-void rb_define_private_method _((VALUE,const char*,VALUE(*)(),int));
+void rb_define_protected_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_private_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
+void rb_define_private_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
VALUE rb_singleton_class _((VALUE));
/* enum.c */
VALUE rb_enum_length _((VALUE));
@@ -167,13 +167,13 @@ void rb_thread_sleep_forever _((void));
VALUE rb_thread_stop _((void));
VALUE rb_thread_wakeup _((VALUE));
VALUE rb_thread_run _((VALUE));
-VALUE rb_thread_create _((VALUE (*)(), void*));
+VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
int rb_thread_scope_shared_p _((void));
void rb_thread_interrupt _((void));
void rb_thread_trap_eval _((VALUE, int));
void rb_thread_signal_raise _((char*));
-int rb_thread_select();
-void rb_thread_wait_for();
+int rb_thread_select(ANYARGS);
+void rb_thread_wait_for(ANYARGS);
VALUE rb_thread_current _((void));
VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
@@ -351,7 +351,7 @@ VALUE rb_struct_aref _((VALUE, VALUE));
VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
VALUE rb_struct_getmember _((VALUE, ID));
/* time.c */
-VALUE rb_time_new();
+VALUE rb_time_new(ANYARGS);
/* variable.c */
VALUE rb_mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
diff --git a/marshal.c b/marshal.c
index 6e22bcc0b2..618e98f459 100644
--- a/marshal.c
+++ b/marshal.c
@@ -750,9 +750,6 @@ r_regist(v, arg)
VALUE v;
struct load_arg *arg;
{
- if (arg->proc) {
- rb_funcall(arg->proc, rb_intern("call"), 1, v);
- }
rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v);
if (arg->taint) OBJ_TAINT(v);
return v;
@@ -779,7 +776,7 @@ static VALUE
r_object(arg)
struct load_arg *arg;
{
- VALUE v;
+ VALUE v = Qnil;
int type = r_byte(arg);
long id;
@@ -791,7 +788,6 @@ r_object(arg)
rb_raise(rb_eArgError, "dump format error (unlinked)");
}
return v;
- break;
case TYPE_IVAR:
v = r_object(arg);
@@ -801,47 +797,62 @@ r_object(arg)
case TYPE_UCLASS:
{
VALUE c = rb_path2class(r_unique(arg));
- VALUE tmp;
v = r_object(arg);
- if (rb_special_const_p(v) ||
- TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS || TYPE(v) == T_MODULE ||
- !RTEST(rb_funcall(c, '<', 1, RBASIC(v)->klass))) {
+ if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) {
+ format_error:
rb_raise(rb_eArgError, "dump format error (user class)");
}
-#if 0
- tmp = rb_obj_alloc(c);
- if (TYPE(v) != TYPE(tmp)) {
- rb_raise(rb_eArgError, "dump format error (user class)");
+ if (TYPE(v) == T_MODULE || !RTEST(rb_funcall(c, '<', 1, RBASIC(v)->klass))) {
+ VALUE tmp = rb_obj_alloc(c);
+
+ if (TYPE(v) != TYPE(tmp)) goto format_error;
}
-#endif
RBASIC(v)->klass = c;
return v;
}
case TYPE_NIL:
- return Qnil;
+ v = Qnil;
+ break;
case TYPE_TRUE:
- return Qtrue;
+ v = Qtrue;
+ break;
case TYPE_FALSE:
- return Qfalse;
+ v = Qfalse;
case TYPE_FIXNUM:
{
long i = r_long(arg);
- return INT2FIX(i);
+ v = INT2FIX(i);
}
+ break;
case TYPE_FLOAT:
{
char *buf;
+ double d, t = 0.0;
r_bytes(buf, arg);
- v = rb_float_new(strtod(buf, 0));
- return r_regist(v, arg);
+ if (strcmp(buf, "nan") == 0) {
+ d = t / t;
+ }
+ else if (strcmp(buf, "inf") == 0) {
+ d = 1.0 / t;
+ }
+ else if (strcmp(buf, "-inf") == 0) {
+ d = -1.0 / t;
+ }
+ else {
+ /* xxx: should not use system's strtod(3) */
+ d = strtod(buf, 0);
+ }
+ v = rb_float_new(d);
+ r_regist(v, arg);
}
+ break;
case TYPE_BIGNUM:
{
@@ -876,15 +887,16 @@ r_object(arg)
len--;
#endif
}
- big = RBIGNUM(rb_big_norm((VALUE)big));
- if (TYPE(big) == T_BIGNUM) {
- r_regist((VALUE)big, arg);
+ v = rb_big_norm((VALUE)big);
+ if (TYPE(v) == T_BIGNUM) {
+ r_regist(v, arg);
}
- return (VALUE)big;
}
+ break;
case TYPE_STRING:
- return r_regist(r_string(arg), arg);
+ v = r_regist(r_string(arg), arg);
+ break;
case TYPE_REGEXP:
{
@@ -894,19 +906,21 @@ r_object(arg)
r_bytes2(buf, len, arg);
options = r_byte(arg);
- return r_regist(rb_reg_new(buf, len, options), arg);
+ v = r_regist(rb_reg_new(buf, len, options), arg);
}
+ break;
case TYPE_ARRAY:
{
volatile long len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */
v = rb_ary_new2(len);
+ r_regist(v, arg);
while (len--) {
rb_ary_push(v, r_object(arg));
}
- return r_regist(v, arg);;
}
+ break;
case TYPE_HASH:
case TYPE_HASH_DEF:
@@ -914,6 +928,7 @@ r_object(arg)
long len = r_long(arg);
v = rb_hash_new();
+ r_regist(v, arg);
while (len--) {
VALUE key = r_object(arg);
VALUE value = r_object(arg);
@@ -922,8 +937,8 @@ r_object(arg)
if (type == TYPE_HASH_DEF) {
RHASH(v)->ifnone = r_object(arg);
}
- return r_regist(v, arg);
}
+ break;
case TYPE_STRUCT:
{
@@ -944,6 +959,7 @@ r_object(arg)
rb_ary_push(values, Qnil);
}
v = rb_struct_alloc(klass, values);
+ r_regist(v, arg);
for (i=0; i<len; i++) {
slot = r_symbol(arg);
@@ -955,8 +971,6 @@ r_object(arg)
}
rb_struct_aset(v, INT2FIX(i), r_object(arg));
}
- r_regist(v, arg);
- return v;
}
break;
@@ -965,12 +979,12 @@ r_object(arg)
VALUE klass;
klass = rb_path2class(r_unique(arg));
- if (rb_respond_to(klass, s_load)) {
- v = rb_funcall(klass, s_load, 1, r_string(arg));
- return r_regist(v, arg);
+ if (!rb_respond_to(klass, s_load)) {
+ rb_raise(rb_eTypeError, "class %s needs to have method `_load'",
+ rb_class2name(klass));
}
- rb_raise(rb_eTypeError, "class %s needs to have method `_load'",
- rb_class2name(klass));
+ v = rb_funcall(klass, s_load, 1, r_string(arg));
+ r_regist(v, arg);
}
break;
@@ -983,8 +997,8 @@ r_object(arg)
if (TYPE(v) != T_OBJECT) {
rb_raise(rb_eArgError, "dump format error");
}
+ r_regist(v, arg);
r_ivar(v, arg);
- return r_regist(v, arg);
}
break;
@@ -992,37 +1006,37 @@ r_object(arg)
{
char *buf;
r_bytes(buf, arg);
- return r_regist(rb_path2class(buf), arg);
+ v = r_regist(rb_path2class(buf), arg);
}
+ break;
case TYPE_CLASS:
{
- VALUE c;
-
char *buf;
r_bytes(buf, arg);
- c = rb_path2class(buf);
- if (TYPE(c) != T_CLASS) {
+ v = rb_path2class(buf);
+ if (TYPE(v) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", buf);
}
- return r_regist(c, arg);
+ r_regist(v, arg);
}
+ break;
case TYPE_MODULE:
{
- VALUE m;
-
char *buf;
r_bytes(buf, arg);
- m = rb_path2class(buf);
- if (TYPE(m) != T_MODULE) {
+ v = rb_path2class(buf);
+ if (TYPE(v) != T_MODULE) {
rb_raise(rb_eTypeError, "%s is not a module", buf);
}
- return r_regist(m, arg);
+ r_regist(v, arg);
}
+ break;
case TYPE_SYMBOL:
- return ID2SYM(r_symreal(arg));
+ v = ID2SYM(r_symreal(arg));
+ break;
case TYPE_SYMLINK:
return ID2SYM(r_symlink(arg));
@@ -1031,7 +1045,10 @@ r_object(arg)
rb_raise(rb_eArgError, "dump format error(0x%x)", type);
break;
}
- return Qnil; /* not reached */
+ if (arg->proc) {
+ rb_funcall(arg->proc, rb_intern("yield"), 1, v);
+ }
+ return v;
}
static VALUE
diff --git a/node.h b/node.h
index 4788f8bc95..62c1264aeb 100644
--- a/node.h
+++ b/node.h
@@ -131,7 +131,7 @@ typedef struct RNode {
struct RNode *node;
ID id;
VALUE value;
- VALUE (*cfunc)();
+ VALUE (*cfunc)(ANYARGS);
ID *tbl;
} u1;
union {
@@ -340,7 +340,7 @@ NODE *rb_compile_string _((const char*, VALUE, int));
NODE *rb_compile_file _((const char*, VALUE, int));
void rb_add_method _((VALUE, ID, NODE *, int));
-NODE *rb_node_newnode();
+NODE *rb_node_newnode(ANYARGS);
struct global_entry *rb_global_entry _((ID));
VALUE rb_gvar_get _((struct global_entry *));
diff --git a/process.c b/process.c
index 6b7eda6407..2fc62828d0 100644
--- a/process.c
+++ b/process.c
@@ -617,6 +617,7 @@ rb_syswait(pid)
signal(SIGQUIT, qfunc);
#endif
signal(SIGINT, ifunc);
+ overriding = Qfalse;
}
}
diff --git a/ruby.h b/ruby.h
index 2998636064..446c2e0f59 100644
--- a/ruby.h
+++ b/ruby.h
@@ -74,6 +74,12 @@ extern "C" {
# define __(args) ()
#endif
+#ifdef __cplusplus
+#define ANYARGS ...
+#else
+#define ANYARGS
+#endif
+
#ifdef HAVE_ATTR_NORETURN
# define NORETURN __attribute__ ((noreturn))
#else
@@ -408,8 +414,8 @@ void xfree _((void*));
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
-void rb_glob _((char*,void(*)(),VALUE));
-void rb_globi _((char*,void(*)(),VALUE));
+void rb_glob _((char*,void(*)(const char*,VALUE),VALUE));
+void rb_iglob _((char*,void(*)(const char*,VALUE),VALUE));
VALUE rb_define_class _((const char*,VALUE));
VALUE rb_define_module _((const char*));
@@ -420,16 +426,16 @@ void rb_include_module _((VALUE,VALUE));
void rb_extend_object _((VALUE,VALUE));
void rb_define_variable _((const char*,VALUE*));
-void rb_define_virtual_variable _((const char*,VALUE(*)(),void(*)()));
-void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(),void(*)()));
+void rb_define_virtual_variable _((const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
+void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
void rb_define_readonly_variable _((const char*,VALUE*));
void rb_define_const _((VALUE,const char*,VALUE));
void rb_define_global_const _((const char*,VALUE));
-#define RUBY_METHOD_FUNC(func) ((VALUE (*)__((...)))func)
-void rb_define_method _((VALUE,const char*,VALUE(*)(),int));
-void rb_define_module_function _((VALUE,const char*,VALUE(*)(),int));
-void rb_define_global_function _((const char*,VALUE(*)(),int));
+#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
+void rb_define_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
+void rb_define_module_function _((VALUE,const char*,VALUE(*)(ANYARGS),int));
+void rb_define_global_function _((const char*,VALUE(*)(ANYARGS),int));
void rb_undef_method _((VALUE,const char*));
void rb_define_alias _((VALUE,const char*,const char*));
@@ -479,11 +485,11 @@ void rb_warning __((const char*, ...)); /* reports if `-w' specified */
VALUE rb_each _((VALUE));
VALUE rb_yield _((VALUE));
int rb_block_given_p _((void));
-VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
-VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
-VALUE rb_rescue2 __((VALUE(*)(),VALUE,VALUE(*)(),VALUE,...));
-VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
-VALUE rb_catch _((const char*,VALUE(*)(),VALUE));
+VALUE rb_iterate _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
+VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_catch _((const char*,VALUE(*)(ANYARGS),VALUE));
void rb_throw _((const char*,VALUE)) NORETURN;
VALUE rb_require _((const char*));
diff --git a/rubysig.h b/rubysig.h
index 1975215ef0..e3c0e1b0ec 100644
--- a/rubysig.h
+++ b/rubysig.h
@@ -57,7 +57,7 @@ EXTERN int rb_prohibit_interrupt;
#define ALLOW_INTS {rb_prohibit_interrupt--; CHECK_INTS;}
#define ENABLE_INTS {rb_prohibit_interrupt--;}
-VALUE rb_with_disable_interrupt _((VALUE(*)(),VALUE));
+VALUE rb_with_disable_interrupt _((VALUE(*)(ANYARGS),VALUE));
EXTERN rb_atomic_t rb_trap_pending;
void rb_trap_restore_mask _((void));