summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-08 10:56:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-08 10:56:14 +0000
commitf47627e8a345860942490ca60cfb18f6820fa0f9 (patch)
tree4fa1b092f971cf48a10af796fcb443a82c89ca77
parentb500f3c9a5880b4ca0da3d358673d02e4952ce52 (diff)
downloadruby-f47627e8a345860942490ca60cfb18f6820fa0f9.tar.gz
ruby-f47627e8a345860942490ca60cfb18f6820fa0f9.tar.xz
ruby-f47627e8a345860942490ca60cfb18f6820fa0f9.zip
merges r24321 from trunk into ruby_1_9_1.
-- * insns.def (defineclass): preserve encoding of class/module names. [ruby-core:24600] * variable.c (rb_set_class_path_string): set class path with a string value. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--include/ruby/intern.h1
-rw-r--r--insns.def4
-rw-r--r--test/ruby/test_class.rb7
-rw-r--r--test/ruby/test_module.rb7
-rw-r--r--variable.c17
-rw-r--r--version.h2
7 files changed, 43 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f0580ad86..72c60ca89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Jul 30 16:45:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * insns.def (defineclass): preserve encoding of class/module
+ names. [ruby-core:24600]
+
+ * variable.c (rb_set_class_path_string): set class path with a
+ string value.
+
Sat Jul 25 17:49:03 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (argf_eof): should not have reached EOF before trying to
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 5d8eee36c..5474bb3f9 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -728,6 +728,7 @@ VALUE rb_time_nano_new(time_t, long);
VALUE rb_mod_name(VALUE);
VALUE rb_class_path(VALUE);
void rb_set_class_path(VALUE, VALUE, const char*);
+void rb_set_class_path_string(VALUE, VALUE, VALUE);
VALUE rb_path2class(const char*);
void rb_name_class(VALUE, ID);
VALUE rb_class_name(VALUE);
diff --git a/insns.def b/insns.def
index 72ed335e9..f7716bfe1 100644
--- a/insns.def
+++ b/insns.def
@@ -908,7 +908,7 @@ defineclass
else {
/* new class declaration */
klass = rb_define_class_id(id, super);
- rb_set_class_path(klass, cbase, rb_id2name(id));
+ rb_set_class_path_string(klass, cbase, rb_id2str(id));
rb_const_set(cbase, id, klass);
rb_class_inherited(super, klass);
}
@@ -935,7 +935,7 @@ defineclass
else {
/* new module declaration */
klass = rb_define_module_id(id);
- rb_set_class_path(klass, cbase, rb_id2name(id));
+ rb_set_class_path_string(klass, cbase, rb_id2str(id));
rb_const_set(cbase, id, klass);
}
break;
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 93a19e86e..bc0f79a68 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -144,4 +144,11 @@ class TestClass < Test::Unit::TestCase
assert_raise(TypeError) { Class.allocate.new }
assert_raise(TypeError) { Class.allocate.superclass }
end
+
+ def test_nonascii_name
+ c = eval("class ::C\u{df}; self; end")
+ assert_equal("C\u{df}", c.name, '[ruby-core:24600]')
+ c = eval("class C\u{df}; self; end")
+ assert_equal("TestClass::C\u{df}", c.name, '[ruby-core:24600]')
+ end
end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index e1f729963..ff74fc7f7 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -721,4 +721,11 @@ class TestModule < Test::Unit::TestCase
}.call
end
end
+
+ def test_nonascii_name
+ c = eval("class ::C\u{df}; self; end")
+ assert_equal("C\u{df}", c.name, '[ruby-core:24600]')
+ c = eval("class C\u{df}; self; end")
+ assert_equal("TestModule::C\u{df}", c.name, '[ruby-core:24600]')
+ end
end
diff --git a/variable.c b/variable.c
index 5d4a4ad2c..03efd1de1 100644
--- a/variable.c
+++ b/variable.c
@@ -212,6 +212,23 @@ rb_class_path(VALUE klass)
}
void
+rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
+{
+ VALUE str;
+
+ if (under == rb_cObject) {
+ str = rb_str_new_frozen(name);
+ }
+ else {
+ str = rb_str_dup(rb_class_path(under));
+ rb_str_cat2(str, "::");
+ rb_str_append(str, name);
+ OBJ_FREEZE(str);
+ }
+ rb_ivar_set(klass, classpath, str);
+}
+
+void
rb_set_class_path(VALUE klass, VALUE under, const char *name)
{
VALUE str;
diff --git a/version.h b/version.h
index 593339a4d..73d45fad8 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 255
+#define RUBY_PATCHLEVEL 256
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1