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

ruby-changes:39000

From: nobu <ko1@a...>
Date: Wed, 1 Jul 2015 09:28:55 +0900 (JST)
Subject: [ruby-changes:39000] nobu:r51081 (trunk): struct.c: fix implicit conversions

nobu	2015-07-01 09:28:49 +0900 (Wed, 01 Jul 2015)

  New Revision: 51081

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

  Log:
    struct.c: fix implicit conversions
    
    * struct.c (struct_member_pos): revert r51080 to fix other
      implicit conversions but cast the return value to fix the
      previous implicit conversion.

  Modified files:
    trunk/ChangeLog
    trunk/struct.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51080)
+++ ChangeLog	(revision 51081)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul  1 09:28:47 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* struct.c (struct_member_pos): revert r51080 to fix other
+	  implicit conversions but cast the return value to fix the
+	  previous implicit conversion.
+
 Wed Jul  1 08:47:24 2015  NARUSE, Yui  <naruse@r...>
 
 	* struct.c (struct_member_pos): avoid implicit conversion loses
Index: struct.c
===================================================================
--- struct.c	(revision 51080)
+++ struct.c	(revision 51081)
@@ -131,7 +131,7 @@ struct_member_pos(VALUE s, VALUE name) https://github.com/ruby/ruby/blob/trunk/struct.c#L131
 {
     VALUE back = struct_ivar_get(rb_obj_class(s), id_back_members);
     VALUE const * p;
-    int j, mask;
+    long j, mask;
 
     if (UNLIKELY(NIL_P(back))) {
 	rb_raise(rb_eTypeError, "uninitialized struct");
@@ -141,17 +141,17 @@ struct_member_pos(VALUE s, VALUE name) https://github.com/ruby/ruby/blob/trunk/struct.c#L141
     }
 
     p = RARRAY_CONST_PTR(back);
-    mask = RARRAY_LENINT(back);
+    mask = RARRAY_LEN(back);
 
     if (mask <= AREF_HASH_THRESHOLD) {
 	if (UNLIKELY(RSTRUCT_LEN(s) != RARRAY_LEN(back))) {
 	    rb_raise(rb_eTypeError,
-		     "struct size differs (%d required %ld given)",
+		     "struct size differs (%ld required %ld given)",
 		     mask, RSTRUCT_LEN(s));
 	}
 	for (j = 0; j < mask; j++) {
 	    if (p[j] == name)
-		return j;
+		return (int)j;
 	}
 	return -1;
     }

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

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