aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/intern.h1
-rw-r--r--numeric.c6
-rw-r--r--test/ruby/test_numeric.rb1
-rw-r--r--vm_method.c12
5 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index aa974df50e..2e70dc77bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Aug 27 18:31:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_method.c (rb_remove_method_id): exported.
+
+ * numeric.c (num_sadded): fix for non-ascii method name.
+
Thu Aug 27 14:32:31 2009 NARUSE, Yui <naruse@ruby-lang.org>
* re.c (rb_reg_preprocess_dregexp): set encoding as ASCII-8BIT
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 46d3aeae8a..9ebf5d6c5e 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -263,6 +263,7 @@ NORETURN(void rb_exc_fatal(VALUE));
VALUE rb_f_exit(int,VALUE*);
VALUE rb_f_abort(int,VALUE*);
void rb_remove_method(VALUE, const char*);
+void rb_remove_method_id(VALUE, ID);
#define rb_disable_super(klass, name) ((void)0)
#define rb_enable_super(klass, name) ((void)0)
#define HAVE_RB_DEFINE_ALLOC_FUNC 1
diff --git a/numeric.c b/numeric.c
index dedd8e2ee5..7f74cde562 100644
--- a/numeric.c
+++ b/numeric.c
@@ -203,13 +203,13 @@ rb_num_coerce_relop(VALUE x, VALUE y, ID func)
static VALUE
num_sadded(VALUE x, VALUE name)
{
- const char *nstr = rb_id2name(rb_to_id(name));
+ ID mid = rb_to_id(name);
/* ruby_frame = ruby_frame->prev; */ /* pop frame for "singleton_method_added" */
/* Numerics should be values; singleton_methods should not be added to them */
- rb_remove_method(rb_singleton_class(x), nstr);
+ rb_remove_method_id(rb_singleton_class(x), mid);
rb_raise(rb_eTypeError,
"can't define singleton method \"%s\" for %s",
- nstr,
+ rb_id2name(mid),
rb_obj_classname(x));
return Qnil; /* not reached */
}
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 43d53e7fcf..f4fbea4ce9 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -47,6 +47,7 @@ class TestNumeric < Test::Unit::TestCase
def test_numeric
a = Numeric.new
assert_raise(TypeError) { def a.foo; end }
+ assert_raise(TypeError) { eval("def a.\u3042; end") }
assert_raise(TypeError) { a.dup }
end
diff --git a/vm_method.c b/vm_method.c
index 4a94504ca5..d7111935b0 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -100,12 +100,14 @@ rb_clear_cache_by_class(VALUE klass)
}
}
-VALUE rb_f_notimplement(int argc, VALUE *argv, VALUE obj)
+VALUE
+rb_f_notimplement(int argc, VALUE *argv, VALUE obj)
{
rb_notimplement();
}
-static void rb_define_notimplement_method_id(VALUE mod, ID id, rb_method_flag_t noex)
+static void
+rb_define_notimplement_method_id(VALUE mod, ID id, rb_method_flag_t noex)
{
rb_add_method(mod, id, VM_METHOD_TYPE_NOTIMPLEMENTED, 0, noex);
}
@@ -324,8 +326,8 @@ rb_method_entry(VALUE klass, ID id)
return rb_get_method_entry(klass, id);
}
-static void
-remove_method(VALUE klass, ID mid)
+void
+rb_remove_method_id(VALUE klass, ID mid)
{
st_data_t data;
rb_method_entry_t *me = 0;
@@ -367,6 +369,8 @@ remove_method(VALUE klass, ID mid)
}
}
+#define remove_method(klass, mid) rb_remove_method_id(klass, mid)
+
void
rb_remove_method(VALUE klass, const char *name)
{