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

ruby-changes:4521

From: ko1@a...
Date: Mon, 14 Apr 2008 19:52:40 +0900 (JST)
Subject: [ruby-changes:4521] knu - Ruby:r16014 (ruby_1_8): * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.

knu	2008-04-14 19:52:17 +0900 (Mon, 14 Apr 2008)

  New Revision: 16014

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/intern.h
    branches/ruby_1_8/random.c
    branches/ruby_1_8/string.c

  Log:
    * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
    
    * string.c (rb_str_tmp_new), intern.h: New function.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/intern.h?r1=16014&r2=16013&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16014&r2=16013&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/random.c?r1=16014&r2=16013&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/string.c?r1=16014&r2=16013&diff_format=u

Index: ruby_1_8/intern.h
===================================================================
--- ruby_1_8/intern.h	(revision 16013)
+++ ruby_1_8/intern.h	(revision 16014)
@@ -369,6 +369,9 @@
 VALUE rb_range_new _((VALUE, VALUE, int));
 VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
 VALUE rb_length_by_each _((VALUE));
+/* random.c */
+unsigned long rb_genrand_int32(void);
+double rb_genrand_real(void);
 /* re.c */
 int rb_memcmp _((const void*,const void*,long));
 int rb_memcicmp _((const void*,const void*,long));
@@ -421,6 +424,7 @@
 VALUE rb_tainted_str_new2 _((const char*));
 VALUE rb_str_buf_new _((long));
 VALUE rb_str_buf_new2 _((const char*));
+VALUE rb_str_tmp_new _((long));
 VALUE rb_str_buf_append _((VALUE, VALUE));
 VALUE rb_str_buf_cat _((VALUE, const char*, long));
 VALUE rb_str_buf_cat2 _((VALUE, const char*));
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 16013)
+++ ruby_1_8/ChangeLog	(revision 16014)
@@ -1,3 +1,9 @@
+Mon Apr 14 19:49:35 2008  Akinori MUSHA  <knu@i...>
+
+	* random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
+
+	* string.c (rb_str_tmp_new), intern.h: New function.
+
 Mon Apr 14 19:18:55 2008  NAKAMURA Usaku  <usa@r...>
 
 	* enum.c (inject_i, inject_op_i): prototype.
Index: ruby_1_8/string.c
===================================================================
--- ruby_1_8/string.c	(revision 16013)
+++ ruby_1_8/string.c	(revision 16014)
@@ -251,6 +251,13 @@
 }
 
 VALUE
+rb_str_tmp_new(len)
+    long len;
+{
+    return str_new(0, 0, len);
+}
+
+VALUE
 rb_str_to_str(str)
     VALUE str;
 {
Index: ruby_1_8/random.c
===================================================================
--- ruby_1_8/random.c	(revision 16013)
+++ ruby_1_8/random.c	(revision 16014)
@@ -146,8 +146,8 @@
 }
 
 /* generates a random number on [0,0xffffffff]-interval */
-static unsigned long
-genrand_int32(void)
+unsigned long
+rb_genrand_int32(void)
 {
     unsigned long y;
 
@@ -164,10 +164,10 @@
 }
 
 /* generates a random number on [0,1) with 53-bit resolution*/
-static double
-genrand_real(void) 
+double
+rb_genrand_real(void) 
 { 
-    unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; 
+    unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6; 
     return(a*67108864.0+b)*(1.0/9007199254740992.0); 
 } 
 /* These real versions are due to Isaku Wada, 2002/01/09 added */
@@ -361,7 +361,7 @@
     val = 0;
     for (i = SIZEOF_LONG/4-1; 0 <= i; i--) {
         if (mask >> (i * 32)) {
-            val |= genrand_int32() << (i * 32);
+            val |= rb_genrand_int32() << (i * 32);
             val &= mask;
             if (limit < val)
                 goto retry;
@@ -399,7 +399,7 @@
         lim = BIG_GET32(limit, i);
         mask = mask ? 0xffffffff : make_mask(lim);
         if (mask) {
-            rnd = genrand_int32() & mask;
+            rnd = rb_genrand_int32() & mask;
             if (boundary) {
                 if (lim < rnd)
                     goto retry;
@@ -470,7 +470,7 @@
             limit = (struct RBignum *)rb_big_minus((VALUE)limit, INT2FIX(1));
             if (FIXNUM_P((VALUE)limit)) {
                 if (FIX2LONG((VALUE)limit) == -1)
-                    return rb_float_new(genrand_real());
+                    return rb_float_new(rb_genrand_real());
                 return LONG2NUM(limited_rand(FIX2LONG((VALUE)limit)));
             }
             return limited_big_rand(limit);
@@ -488,7 +488,7 @@
     }
 
     if (max == 0) {
-	return rb_float_new(genrand_real());
+	return rb_float_new(rb_genrand_real());
     }
     if (max < 0) max = -max;
     val = limited_rand(max-1);

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

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