From a36197bd5817a6b0611d9f1e7f6b5bf4725ab480 Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 10 Sep 2006 22:41:52 +0000 Subject: [PATCH] * string.c (sym_equal): "sym == str" should compare them as strings. [ruby-dev:29554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67623aa8e0..0ce7d50223 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 11 07:39:44 2006 Yukihiro Matsumoto + + * string.c (sym_equal): "sym == str" should compare them as + strings. [ruby-dev:29554] + Sun Sep 10 22:59:43 2006 Nobuyoshi Nakada * instruby.rb (parse_args): remove splat. diff --git a/string.c b/string.c index dc389b16fb..094907fe54 100644 --- a/string.c +++ b/string.c @@ -120,6 +120,7 @@ str_alloc(VALUE klass) OBJSETUP(str, klass, T_STRING); if (klass == rb_cSymbol) { + /* need to be registered in table */ RBASIC(str)->klass = rb_cString; } str->as.heap.ptr = 0; @@ -4429,15 +4430,16 @@ rb_sym_s_intern(VALUE s) * sym == obj => true or false * * Equality---If sym and obj are exactly the same - * symbol, returns true. Otherwise, returns - * false. + * symbol, returns true. Otherwise, compares them + * as strings. */ static VALUE sym_equal(VALUE sym1, VALUE sym2) { if (sym1 == sym2) return Qtrue; - return Qfalse; + if (SYMBOL_P(sym2)) return Qfalse; + return rb_str_equal(sym1, sym2); } /*