Граф коммитов

102 Коммитов

Автор SHA1 Сообщение Дата
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
nobu ed52949e79 * random.c (fill_random_seed): /dev/urandom is not available on
DOSISH systems.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 04:58:38 +00:00
nobu 115c220b4d * random.c (random_equal): new method Random#==.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 04:56:12 +00:00
nobu bc0ea18dbd * random.c (dump_mt): removed debug function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 04:52:22 +00:00
nobu 3622071601 * random.c (fill_random_seed): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-16 09:43:01 +00:00
nobu eb9bc2d265 * random.c (rb_random_t): objectified. [EXPERIMENTAL]
[ruby-dev:30954]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-16 06:00:35 +00:00
nobu 17c1e45405 * random.c (rand_init): use fixed buffer for small numbers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-11 17:24:46 +00:00
nobu a88589c7d1 * random.c (limited_rand): expands to long before shift so that
the result does not overflow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 17:37:52 +00:00
nobu 1dabc36b8f * random.c (rand_init): got rid of buffer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 15:16:32 +00:00
nobu 234485dc7d * random.c (struct MT): ruby already assumes int has 32bit at
least, so no needs to use long.

* random.c (rand_init):


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 05:44:08 +00:00
nobu 383b905f5e * random.c (fill_random_seed): enclosed conditionally used
variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-11 20:14:51 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
nobu 3229c32008 * io.c (rb_write_error2, argf_next_argv), process.c (rb_fork_err),
random.c (fill_random_seed): suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-18 06:21:04 +00:00
matz 3c66767bda * random.c (rb_f_srand): update RDoc. [ruby-core:21113]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-04 23:00:39 +00:00
matz 6bbd76a732 * random.c (rb_f_rand): type check simplified. strings are no
longer allowed for argument.  [ruby-dev:37655]

* test/ruby/test_rand.rb (TestRand::o.to_int): need override
  to_int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-29 13:29:12 +00:00
mame 19f45f853c * bignum.c (rb_big_mul): faster multiplication by Karatsuba method and
twice faster square than normal multiplication.

* random.c (rb_rand_internal): used by Bignum#*.

* test/ruby/test_bignum.rb: add some tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-14 03:59:02 +00:00
matz 31b6ea65bb * include/ruby/ruby.h (DBL2NUM): renamed from DOUBLE2NUM.
a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp>
  in [ruby-dev:36102].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 18:24:21 +00:00
nobu 21b00e0222 * random.c (struct MT): packed Mersenne Twister staffs.
* random.c (struct RandSeed): packed random seed staffs.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 02:43:20 +00:00
nobu 79bb49b61b * random.c (Init_RandomSeed2): should be void.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 03:29:19 +00:00
akr 04739ba617 * string.c (rb_memhash): randomize hash to avoid algorithmic
complexity attacks.
  (rb_str_hash): use rb_memhash.

* include/ruby/intern.h (rb_reset_random_seed): declared.

* thread.c (rb_thread_atfork): call rb_reset_random_seed.

* inits.c (rb_call_inits): call Init_RandomSeed at first.

* random.c (seed_initialized): defined.
  (fill_random_seed): extracted from random_seed.
  (make_seed_value): extracted from random_seed.
  (rb_f_rand): initialize random seed at first.
  (initial_seed): defined.
  (Init_RandomSeed): defined.
  (Init_RandomSeed2): defined.
  (rb_reset_random_seed): defined.
  (Init_Random): call Init_RandomSeed2.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 02:46:17 +00:00
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
matz 39787ea14d * numeric.c (fix_to_s): avoid rb_scan_args() when no argument
given. 
* bignum.c (rb_big_to_s): ditto.
* enum.c (enum_first): ditto.
* eval_jump.c (rb_f_catch): ditto.
* io.c (rb_obj_display): ditto.
* class.c (rb_obj_singleton_methods): ditto.
* object.c (rb_class_initialize): ditto.
* random.c (rb_f_srand): ditto.
* range.c (range_step): ditto.
* re.c (rb_reg_s_last_match): ditto.
* string.c (rb_str_to_i): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_chomp_bang): ditto.
* string.c (rb_str_sum): ditto.

* string.c (str_modifiable): declare inline.
* string.c (str_independent): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 05:22:17 +00:00