diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-18 06:38:30 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-18 06:38:30 +0000 |
commit | ce3eb0b20417dd304f27618ed5db0693b2c9563a (patch) | |
tree | 1a65b8a88a292a5edd93f74290ec201b041c27cc /eval.c | |
parent | 925cb98fe832a25734420c8bd5b6eabceb985180 (diff) | |
download | ruby-ce3eb0b20417dd304f27618ed5db0693b2c9563a.tar.gz |
* eval.c (rb_attr): attribute name check added.
* numeric.c (flo_plus): small typo fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -624,6 +624,9 @@ rb_attr(klass, id, read, write, ex) } } + if (!rb_is_local_id(id) && !rb_is_const_id(id)) { + rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id)); + } name = rb_id2name(id); if (!name) { rb_raise(rb_eArgError, "argument needs to be symbol or string"); @@ -635,9 +638,7 @@ rb_attr(klass, id, read, write, ex) rb_add_method(klass, id, NEW_IVAR(attriv), noex); } if (write) { - sprintf(buf, "%s=", name); - id = rb_intern(buf); - rb_add_method(klass, id, NEW_ATTRSET(attriv), noex); + rb_add_method(klass, rb_id_attrset(id), NEW_ATTRSET(attriv), noex); } } |