summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-24 04:42:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-24 04:42:07 +0000
commit3b0fec9a5f966fd7ae26bc7b84877fa7209d8605 (patch)
tree48fbc4b02d73ca0f173ed87e288ee406e0913b97 /eval.c
parent0d30af8fd2bcfea8cf5dbf87b623c57960ce81bc (diff)
1.1c1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index c17c91bfa2..776cb98f0c 100644
--- a/eval.c
+++ b/eval.c
@@ -326,7 +326,7 @@ rb_attr(klass, id, read, write, ex)
{
char *name;
char *buf;
- ID attr, attreq, attriv;
+ ID attr, attriv;
int noex;
if (!ex) noex = NOEX_PUBLIC;
@@ -344,17 +344,19 @@ rb_attr(klass, id, read, write, ex)
}
name = rb_id2name(id);
- attr = rb_intern(name);
+ if (!name) {
+ ArgError("argument needs to be symbol or string");
+ }
buf = ALLOCA_N(char,strlen(name)+2);
- sprintf(buf, "%s=", name);
- attreq = rb_intern(buf);
sprintf(buf, "@%s", name);
attriv = rb_intern(buf);
if (read) {
- rb_add_method(klass, attr, NEW_IVAR(attriv), noex);
+ rb_add_method(klass, id, NEW_IVAR(attriv), noex);
}
+ sprintf(buf, "%s=", name);
+ id = rb_intern(buf);
if (write) {
- rb_add_method(klass, attreq, NEW_ATTRSET(attriv), noex);
+ rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
}
}