naruse
25eebc3ad5
* random.c (rand_init): This checks the value is in 32bit or not,
...
so use int32_t, not int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-04 01:24:01 +00:00
naruse
b259e449d1
* random.c (rand_init): remove useless assignment.
...
* re.c (update_char_offset): remove unused variable.
* re.c (read_escaped_byte): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-04 01:23:58 +00:00
naruse
493f721854
* random.c (rb_genrand_ulong_limited): renamed from
...
rb_rand_internal and now this is public API.
* include/ruby/ruby.h (rb_genrand_ulong_limited): added.
* bignum.c (big_sparse_p): use rb_genrand_ulong_limited.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-10 05:44:54 +00:00
nobu
0eb31be681
* random.c (rb_random_int32): suppress warning on LP64 platforms.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-26 07:41:55 +00:00
nobu
8554e16355
* array.c (rb_ary_{shuffle_bang,sample}): use Random class object.
...
* random.c (try_get_rnd): use default_rand for Random as same as
singleton methods.
* random.c (rb_random_real): check the range of result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 22:30:03 +00:00
shyouhei
2531892cbc
reverted to r29091; r29092 breaks test-all
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 12:14:38 +00:00
nobu
00dcf07ebc
* random.c (rb_random_int32): fixed typo.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 11:22:55 +00:00
nobu
fd1022c065
* random.c (rb_random_real): check the range of result.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 09:31:46 +00:00
nobu
ae6a9009dc
* array.c (rb_ary_{shuffle_bang,sample}): use Random class object.
...
* random.c (try_get_rnd): use default_rand for Random as same as
singleton methods.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 09:00:17 +00:00
nobu
2f6c0e3be3
* array.c (rb_ary_shuffle_bang, rb_ary_sample): add optional
...
argument random. [ruby-dev:41923] [EXPERIMENTAL]
* random.c (rb_random_{int32,real,bytes}): fallback to normal
method invocation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-23 22:07:39 +00:00
nobu
a4c0f7dfae
* random.c (Init_Random): add Random::DEFAULT.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-03 12:16:06 +00:00
naruse
7175a9073e
* class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:
...
clean unused-value warnings.
* cont.c, process.c, vm_exec.h: clean cast warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 07:13:43 +00:00
nobu
79dfc605ff
* random.c (DEFAULT_SEED_LEN): suppress a warning.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-19 05:45:14 +00:00
nobu
25b9eb5e57
* include/ruby/ruby.h (rb_data_type_t): restructured. [ruby-dev:41862]
...
add parent member.
* error.c (rb_typeddata_inherited_p): new function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-18 07:31:54 +00:00
nobu
52aa6ab21d
* process.c (rb_fork_err): suppress gcc 4.4 warnings.
...
* random.c (fill_random_seed): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-13 12:28:37 +00:00
nobu
a43852a3a4
* random.c (random_rand): add the result of random to the
...
beginning of range, not the opposite. [ruby-dev:41415]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-26 11:19:30 +00:00
nobu
93bbd7869c
* random.c (random_rand): subtraction method of non-numeric can
...
return Float, and add the result of random to the beginning of
range, not the opposite. [ruby-dev:41410]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-26 03:08:07 +00:00
marcandre
7729de4d91
* array.c: Documentation: change => in call-seq to ->.
...
Harmonize "#=>" in examples. [ruby-core:30206]
* bignum.c: ditto
* class.c: ditto
* compar.c: ditto
* cont.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enum.c: ditto
* enumerator.c: ditto
* error.c: ditto
* eval.c: ditto
* file.c: ditto
* gc.c: ditto
* io.c: ditto
* load.c: ditto
* marshal.c: ditto
* math.c: ditto
* numeric.c: ditto
* object.c: ditto
* pack.c: ditto
* proc.c: ditto
* process.c: ditto
* random.c: ditto
* range.c: ditto
* re.c: ditto
* ruby.c: ditto
* signal.c: ditto
* sprintf.c: ditto
* string.c: ditto
* struct.c: ditto
* thread.c: ditto
* time.c: ditto
* transcode.c: ditto
* variable.c: ditto
* vm_eval.c: ditto
* vm_method.c: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
nobu
5d8c8b46bb
* random.c (make_seed_value): fix leading-zero-guard condition on
...
bdigit is smaller than 32bit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-13 06:00:49 +00:00
akr
19afeacb88
* random.c (rand_init): use the absolute value of seed to
...
make srand(-2**40) portable with 32bit and 64bit.
[ruby-core:29292](2)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-12 15:16:45 +00:00
nobu
f571492922
* random.c (rand_init): ignore higher bits if all they are same as
...
the lower sign bit. [ruby-core:29292](2)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-07 22:22:36 +00:00
kazu
88a4bf912d
fix rdoc. see r26808
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-03 14:57:20 +00:00
nobu
6decf411c6
* random.c (random_rand): raise ArgumentError on nil, as the
...
documentation implies. [ruby-core:29075]
* random.c (rb_f_rand): mentioned the case of when max is nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-03 01:51:26 +00:00
naruse
46a4000a68
* random.c: change include order; ruby.h should be at first.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-29 00:21:20 +00:00
nobu
21c7d36573
* random.c (default_rand): removed initial buffer.
...
* random.c (Init_RandomSeed): initialize seed of default random.
* random.c (Init_RandomSeed2): turn the seed to Bignum object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-15 09:33:39 +00:00
nobu
d188e1a852
* random.c (next_state): no initialization here.
...
* random.c (default_mt): always return initialized MT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-15 05:06:11 +00:00
naruse
1bf3ca494f
* random.c (rb_reset_random_seed): set seed in this. [ruby-core:28655]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-15 03:26:29 +00:00
akr
373ed885c6
fix rdoc.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-03 15:14:21 +00:00
akr
19b2909ee8
* random.c (fill_random_seed): don't use O_NOFOLLOW because
...
/dev/urandom is a symlink in OpenSolaris.
* lib/securerandom.rb (SecureRandom.random_bytes: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-05 15:04:38 +00:00
nobu
f41eaf8431
* random.c (rb_hash_start): moved from string.c.
...
* random.c (Init_RandomSeed2): register global address before set.
* random.c (Init_RandomSeed): initialize hashseed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 23:50:51 +00:00
akr
b9e0294eda
fix typos.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
nobu
b46cd0e400
* include/ruby/ruby.h (rb_data_type_struct): constified dsize.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:11:35 +00:00
nobu
299d8fb1b7
* random.c (random_rand): fixed rdoc. [ruby-core:25332]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-03 19:49:43 +00:00
nobu
9460fd0ee0
* random.c (random_rand): random integer can be a fixnum for
...
bignum range. [ruby-dev:39173]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-27 04:51:19 +00:00
nobu
2981448f33
* random.c (random_rand): refined error message.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26 15:00:00 +00:00
nobu
31875e97b4
* random.c (random_rand): fixed for edge cases of ranges.
...
[ruby-dev:39166]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26 14:58:44 +00:00
nobu
9676023607
* random.c (random_rand): unified random_int and random_float.
...
[ruby-dev:39158]. and fixes [ruby-core:24655], [ruby-core:24677],
[ruby-core:24679].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26 10:20:30 +00:00
nobu
ebbe19e1ad
* random.c (rand_init, random_load): use already defined macro.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-25 09:21:39 +00:00
nobu
a194550e5c
* random.c (rb_random_int): arguments have to be converted to
...
integer. [ruby-core:24679]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-02 15:32:04 +00:00
nobu
e626e0bdec
* random.c (rand_int): prevent from GC.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-02 05:20:51 +00:00
nobu
51d1c5e73b
* random.c (random_float): rejects Infinity and NaN.
...
[ruby-core:24651]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-01 09:51:05 +00:00
mame
fe22f83ecf
* random.c (init_genrand): ensure invariant of mt->next and mt->left.
...
mt->next should always equal mt->state + N + 1 - mt->left.
In fact, 'r = Random.new(0); r == r.dup' has returned false.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-30 12:55:04 +00:00
mame
6937a3e26f
* random.c (random_bytes): use NUM2LONG instead of FIX2LONG because
...
Random#bytes may receive bignum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-30 12:45:51 +00:00
nobu
f8faa5e8fe
* random.c (random_{state,left}): internal/debug use.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-22 23:52:20 +00:00
mame
4516f623b8
* random.c (rand_init): array length of random seed was broken, which
...
causes memory error with srand(2**1000000-1).
* test/ruby/test_rand.c: test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-21 14:51:17 +00:00
usa
4c7c46b6af
* random.c: workaround for VC++ 6.0.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 02:40:31 +00:00
nobu
f3d022543e
* random.c (rb_random_{int32,real,bytes,int}): added functions for
...
extension libraries.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 00:16:25 +00:00
nobu
8195282dfc
* random.c (fill_random_seed): needs wincrypt.h.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 00:10:46 +00:00
nobu
b12c5a85b4
* random.c (fill_random_seed): use cryptographic service on Windows.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 00:07:07 +00:00
nobu
003fa83e0c
* random.c (DIGSPERINT): fix for LP64.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 06:21:14 +00:00