summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-27 04:52:21 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-27 04:52:21 +0000
commit3fc04d9361549d5bb15f869c22d7ce9591a0ac8c (patch)
treeb160a4f2ed1605c1a4ef62d6c568ff807fda24c5 /eval.c
parent2fcd221fecabe3e6acaa21c54ae6d1ccbe8c0204 (diff)
* ext/dbm/dbm.c (fdbm_select): 1.7 behavior.
* ext/gdbm/gdbm.c (fgdbm_select): ditto. * ext/sdbm/sdbm.c (fsdbm_select): ditto. * ext/dbm/dbm.c (fdbm_delete): adopt Hash#delete behavior. * ext/sdbm/sdbm.c (fsdbm_delete): ditto. * ext/gdbm/gdbm.c: need not to dup key to the block. * ext/sdbm/sdbm.c : replace RuntimeError with SDBMError. * 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/trunk@2145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/eval.c b/eval.c
index 26962c2e17..14eae43ea6 100644
--- a/eval.c
+++ b/eval.c
@@ -4232,13 +4232,13 @@ rb_f_missing(argc, argv, obj)
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);
@@ -4248,40 +4248,41 @@ 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";
- exc = rb_eNameError;
- }
- }
- 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";
+ exc = rb_eNameError;
+ }
+ }
+ 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;
-
{
char buf[BUFSIZ];
+ int noclass = (!d || desc[0]=='#');
snprintf(buf, BUFSIZ, format, rb_id2name(id),
- desc, desc[0]=='#' ? "" : ":",
- desc[0]=='#' ? "" : rb_class2name(CLASS_OF(obj)));
+ desc, noclass ? "" : ":",
+ noclass ? "" : rb_class2name(CLASS_OF(obj)));
exc = rb_exc_new2(exc, buf);
rb_iv_set(exc, "name", argv[0]);
rb_iv_set(exc, "args", rb_ary_new4(argc-1, argv+1));