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

ruby-changes:27988

From: akr <ko1@a...>
Date: Mon, 1 Apr 2013 22:35:46 +0900 (JST)
Subject: [ruby-changes:27988] akr:r40040 (trunk): * ext/zlib/zlib.c (rb_gzfile_set_mtime): Use NUM2UINT.

akr	2013-04-01 22:34:52 +0900 (Mon, 01 Apr 2013)

  New Revision: 40040

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

  Log:
    * ext/zlib/zlib.c (rb_gzfile_set_mtime): Use NUM2UINT.
      The old logic doesn't work well on LP64 platforms as:
      .. -2**63-1 => error,
      -2**63 .. -2**62-1 => success,
      -2**62 .. -2**31-1 => error,
      -2**31 .. 2**31-1 => success,
      2**31 .. 2**62-1 => error,
      2**62 .. 2**64-1 => success,
      2**64 ..  => error.

  Modified files:
    trunk/ChangeLog
    trunk/ext/zlib/zlib.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40039)
+++ ChangeLog	(revision 40040)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Apr  1 22:26:17 2013  Tanaka Akira  <akr@f...>
+
+	* ext/zlib/zlib.c (rb_gzfile_set_mtime): Use NUM2UINT.
+	  The old logic doesn't work well on LP64 platforms as:
+	  .. -2**63-1 => error,
+	  -2**63 .. -2**62-1 => success,
+	  -2**62 .. -2**31-1 => error,
+	  -2**31 .. 2**31-1 => success,
+	  2**31 .. 2**62-1 => error,
+	  2**62 .. 2**64-1 => success,
+	  2**64 ..  => error.
+	
 Mon Apr  1 22:08:02 2013  Benoit Daloze  <eregontp@g...>
 
 	* ext/zlib/zlib.c (Zlib::Inflate.new):
Index: ext/zlib/zlib.c
===================================================================
--- ext/zlib/zlib.c	(revision 40039)
+++ ext/zlib/zlib.c	(revision 40040)
@@ -3188,13 +3188,9 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mti https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L3188
 	rb_raise(cGzError, "header is already written");
     }
 
-    if (FIXNUM_P(mtime)) {
-	gz->mtime = FIX2INT(mtime);
-    }
-    else {
-	val = rb_Integer(mtime);
-	gz->mtime = FIXNUM_P(val) ? FIX2UINT(val) : rb_big2ulong(val);
-    }
+    val = rb_Integer(mtime);
+    gz->mtime = NUM2UINT(val);
+
     return mtime;
 }
 

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

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