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 | a72425ba3d7a8cadd2575941235d99765c6839e7 (patch) | |
tree | 1a65b8a88a292a5edd93f74290ec201b041c27cc /eval.c | |
parent | 7cf03ebe4c86b65cce178974ae25637b0448952c (diff) | |
download | ruby-a72425ba3d7a8cadd2575941235d99765c6839e7.tar.gz ruby-a72425ba3d7a8cadd2575941235d99765c6839e7.tar.xz ruby-a72425ba3d7a8cadd2575941235d99765c6839e7.zip |
* eval.c (rb_attr): attribute name check added.
* numeric.c (flo_plus): small typo fix.
git-svn-id: http://svn.ruby-lang.org/repos/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); } } |