summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-18 06:38:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-18 06:38:30 +0000
commitce3eb0b20417dd304f27618ed5db0693b2c9563a (patch)
tree1a65b8a88a292a5edd93f74290ec201b041c27cc
parent925cb98fe832a25734420c8bd5b6eabceb985180 (diff)
* 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
-rw-r--r--ChangeLog6
-rw-r--r--eval.c7
-rw-r--r--misc/ruby-mode.el2
-rw-r--r--numeric.c2
-rw-r--r--struct.c4
5 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b23734a3d9..08da24563e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Apr 18 15:37:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_attr): attribute name check added.
+
+ * numeric.c (flo_plus): small typo fix.
+
Mon Apr 18 11:25:14 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/zlib/zlib.c (zstream_run): fixed SEGV. [ruby-core:4712]
diff --git a/eval.c b/eval.c
index b0ea47f383..c38a49992b 100644
--- a/eval.c
+++ b/eval.c
@@ -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);
}
}
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index e2f64c8c34..2190a932bb 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -398,7 +398,7 @@ The variable ruby-indent-level controls the amount of indentation.
((and (not (eobp))
(ruby-expr-beg 'expr-qstr)
(not (looking-at "%="))
- (looking-at "%[QqrxWw]?\\(.\\)"))
+ (looking-at "%[QqrxWw]?\\([^a-zA-Z0-9 \t\n]\\)"))
(goto-char (match-beginning 1))
(setq expand (not (memq (char-before) '(?q ?w))))
(setq w (match-string 1))
diff --git a/numeric.c b/numeric.c
index bfa6b2602b..e3f29ea46e 100644
--- a/numeric.c
+++ b/numeric.c
@@ -593,7 +593,7 @@ flo_minus(x, y)
* call-seq:
* float * other => float
*
- * Returns a new float with is the product of <code>float</code>
+ * Returns a new float which is the product of <code>float</code>
* and <code>other</code>.
*/
diff --git a/struct.c b/struct.c
index e94659d85d..f0458a3520 100644
--- a/struct.c
+++ b/struct.c
@@ -210,7 +210,7 @@ make_struct(name, members, klass)
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
for (i=0; i< RARRAY(members)->len; i++) {
ID id = SYM2ID(RARRAY(members)->ptr[i]);
- if (rb_is_local_id(id)) {
+ if (rb_is_local_id(id) || rb_is_const_id(id)) {
if (i<sizeof(ref_func)) {
rb_define_method_id(nstr, id, ref_func[i], 0);
}
@@ -496,7 +496,7 @@ inspect_struct(s, dummy, recur)
}
slot = RARRAY(members)->ptr[i];
id = SYM2ID(slot);
- if (rb_is_local_id(id)) {
+ if (rb_is_local_id(id) || rb_is_const_id(id)) {
p = rb_id2name(id);
rb_str_cat2(str, p);
}