[前][次][番号順一覧][スレッド一覧]

ruby-changes:36810

From: nobu <ko1@a...>
Date: Fri, 19 Dec 2014 15:36:20 +0900 (JST)
Subject: [ruby-changes:36810] nobu:r48891 (trunk): hash.c: fix return value

nobu	2014-12-19 15:36:05 +0900 (Fri, 19 Dec 2014)

  New Revision: 48891

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48891

  Log:
    hash.c: fix return value
    
    * hash.c (hash_equal): prefer true than the result of implicit
      conversion from int returned by rb_eql() to VALUE.  [Fix GH-789]

  Modified files:
    trunk/ChangeLog
    trunk/hash.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48890)
+++ ChangeLog	(revision 48891)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 19 15:36:02 2014  Simon Genier  <simon.genier@s...>
+
+	* hash.c (hash_equal): prefer true than the result of implicit
+	  conversion from int returned by rb_eql() to VALUE.  [Fix GH-789]
+
 Thu Dec 18 17:45:26 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (rb_cv_binary_elf): get rid of -e option of cat
Index: hash.c
===================================================================
--- hash.c	(revision 48890)
+++ hash.c	(revision 48891)
@@ -1944,10 +1944,17 @@ hash_equal(VALUE hash1, VALUE hash2, int https://github.com/ruby/ruby/blob/trunk/hash.c#L1944
 	if (!rb_respond_to(hash2, idTo_hash)) {
 	    return Qfalse;
 	}
-	if (eql)
-	    return rb_eql(hash2, hash1);
-	else
+	if (eql) {
+	    if (rb_eql(hash2, hash1)) {
+		return Qtrue;
+	    }
+	    else {
+		return Qfalse;
+	    }
+	}
+	else {
 	    return rb_equal(hash2, hash1);
+	}
     }
     if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2))
 	return Qfalse;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]