aboutsummaryrefslogtreecommitdiffstats
path: root/random.c
Commit message (Collapse)AuthorAgeFilesLines
...
* random.c: refine error messagenobu2012-07-201-1/+4
| | | | | | | * random.c (rb_random_real): refine error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* random.c: check initialize and loadnobu2012-06-221-0/+3
| | | | | | | * random.c (random_init, random_load): cannot initialize frozen object again, nor with tainted/untrusted object. [Bug #6540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_int32): get rid of "warning: constant 0x100000000kosaki2012-06-191-1/+1
| | | | | | is so big it is long" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* obj_init_copynobu2012-06-051-3/+8
| | | | | | * object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_init): Clarify that the default seed isdrbrain2012-04-191-3/+2
| | | | | | | | | Random.new_seed, not zero. Based on patch by Roger Pack. [ruby-trunk - Bug #6313] * random.c (rb_f_srand): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]marcandre2012-03-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * array.c: Use rb_check_arity / rb_error_arity * class.c: ditto * enumerator.c: ditto * eval.c: ditto * file.c: ditto * hash.c: ditto * numeric.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * re.c: ditto * signal.c: ditto * string.c: ditto * struct.c: ditto * transcode.c: ditto * vm_eval.c: ditto * vm_insnhelper.c: ditto & implementation of rb_error_arity * test/ruby/test_arity.rb: tests for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (Init_Random): removed rb_Random_DEFAULT and register asnobu2012-03-111-7/+14
| | | | | | mark-object instead of global variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_s_rand): ensure default PRNG is re-initializednobu2012-03-111-0/+1
| | | | | | after fork. patched by Eric Wong. [ruby-core:41209][Bug #5661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: remove a duplicated comment.mrkn2012-02-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * process.c (ruby_setsid): use rb_cloexec_open.akr2011-10-291-3/+3
| | | | | | | | | | | | | | | | | | | | (rb_daemon): ditto. * ruby.c (load_file_internal): ditto. * file.c (rb_file_s_truncate): ditto. (file_load_ok): ditto. * random.c (fill_random_seed): ditto. * ext/pty/pty.c (chfunc): ditto. (get_device_once): ditto. * ext/io/console/console.c (console_dev): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_fd_set_cloexec): declared.akr2011-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io.c (rb_fd_set_cloexec): new function. (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag. (rb_sysopen_internal): ditto. (rb_pipe): ditto. (io_reopen): ditto. (io_cntl): ditto. * process.c (rb_f_exec): change the default :close_others option to true. (rb_f_system): ditto. (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set close-on-exec flag. (ruby_setsid): ditto. (rb_daemon): ditto. * thread_pthread.c (rb_thread_create_timer_thread): call rb_fd_set_cloexec to set close-on-exec flag. * ruby.c (load_file_internal): ditto. * file.c (rb_file_s_truncate): ditto. (file_load_ok): ditto. * random.c (fill_random_seed): ditto. * ext/pty/pty.c (chfunc): ditto. (get_device_once): ditto. * ext/openssl/ossl_bio.c (ossl_obj2bio): ditto. * ext/socket/init.c (rsock_socket): ditto. (rsock_s_accept_nonblock): ditto. (rsock_s_accept): ditto. * ext/socket/socket.c (rsock_sock_s_socketpair): ditto. * ext/socket/ancdata.c (discard_cmsg): ditto. (make_io_for_unix_rights): ditto. * ext/socket/unixsocket.c (unix_recv_io): ditto. * ext/io/console/console.c (console_dev): ditto. [ruby-core:38140] [Feature #5041] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: Improve documentation of Random. Patch by Gregorydrbrain2011-10-051-72/+129
| | | | | | | Parkhurst. [Ruby 1.9 - Bug #5410] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (Init_Random): Add a top-level comment for Random. Patchdrbrain2011-10-041-0/+7
| | | | | | | by Brett Bim. [Ruby 1.9 - Bug #5403] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * use RB_TYPE_P which is optimized for constant types, instead ofnobu2011-09-291-2/+2
| | | | | | comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_update_max_fd): declaration moved fromakr2011-07-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | internal.h. * file.c: ditto. * io.c: call rb_update_max_fd for each new fds. * process.c: ditto. * random.c: ditto. * ruby.c: ditto. * ext/io/console/console.c: ditto. * ext/openssl/ossl_bio.c: ditto. * ext/pty/pty.c: ditto. * ext/socket/init.c: ditto. * ext/socket/socket.c: ditto. * ext/socket/ancdata.c: ditto. * ext/socket/unixsocket.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: Documentation fix for Random#bytesmarcandre2011-06-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2011-05-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): remove unused variables.naruse2011-04-251-2/+1
| | | | | | | | | | | | | | * struct.c (rb_struct_define_without_accessor): ditto. * strftime.c (rb_strftime_with_timespec): ditto. * sprintf.c: ditto. * time.c (time_asctime): remove useless GetTimeval(). * thread_pthread.c: cast to (void *) for %p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_f_rand, random_s_rand): RDocs for them.sorah2011-04-241-8/+25
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_s_rand, Init_Random): Random.rand should behave asmrkn2011-04-241-74/+102
| | | | | | | | | | Random::DEFAULT.rand rather than Kernel#rand. * random.c (rand_range, random_rand): rand_range function extracted from random_rand function. * random.c (rb_f_rand): accept a Range argument as Random#rand [ruby-dev:43427] #4605 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_f_srand): fix rdoc: srand(0)'s 0 is a seed.naruse2011-04-201-2/+2
| | | | | | [ruby-core:35833] fixes #4590 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): suppress a warning.nobu2011-01-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: parenthesize macro arguments.akr2010-12-251-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): get rid of overflow.nobu2010-11-201-4/+19
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): This checks the value is in 32bit or not,naruse2010-10-041-1/+1
| | | | | | so use int32_t, not int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): remove useless assignment.naruse2010-10-041-2/+2
| | | | | | | | * 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
* * random.c (rb_genrand_ulong_limited): renamed fromnaruse2010-09-101-3/+8
| | | | | | | | | | 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
* * random.c (rb_random_int32): suppress warning on LP64 platforms.nobu2010-08-261-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_{shuffle_bang,sample}): use Random class object.nobu2010-08-251-6/+24
| | | | | | | | | * 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
* reverted to r29091; r29092 breaks test-allshyouhei2010-08-251-24/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_int32): fixed typo.nobu2010-08-251-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_real): check the range of result.nobu2010-08-251-2/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_{shuffle_bang,sample}): use Random class object.nobu2010-08-251-4/+12
| | | | | | | * 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
* * array.c (rb_ary_shuffle_bang, rb_ary_sample): add optionalnobu2010-08-231-5/+30
| | | | | | | | | 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
* * random.c (Init_Random): add Random::DEFAULT.nobu2010-08-031-1/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:naruse2010-07-271-1/+1
| | | | | | | | 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
* * random.c (DEFAULT_SEED_LEN): suppress a warning.nobu2010-07-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (rb_data_type_t): restructured. [ruby-dev:41862]nobu2010-07-181-3/+5
| | | | | | | | 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
* * process.c (rb_fork_err): suppress gcc 4.4 warnings.nobu2010-07-131-1/+3
| | | | | | | * random.c (fill_random_seed): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): add the result of random to thenobu2010-05-261-1/+1
| | | | | | | 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
* * random.c (random_rand): subtraction method of non-numeric cannobu2010-05-261-3/+7
| | | | | | | | 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
* * array.c: Documentation: change => in call-seq to ->.marcandre2010-05-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * random.c (make_seed_value): fix leading-zero-guard condition onnobu2010-04-131-2/+9
| | | | | | bdigit is smaller than 32bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): use the absolute value of seed toakr2010-04-121-0/+2
| | | | | | | | 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
* * random.c (rand_init): ignore higher bits if all they are same asnobu2010-04-071-2/+6
| | | | | | 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
* fix rdoc. see r26808kazu2010-04-031-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): raise ArgumentError on nil, as thenobu2010-04-031-3/+2
| | | | | | | | | 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
* * random.c: change include order; ruby.h should be at first.naruse2010-03-291-22/+23
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (default_rand): removed initial buffer.nobu2010-03-151-25/+34
| | | | | | | | | * 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
* * random.c (next_state): no initialization here.nobu2010-03-151-23/+17
| | | | | | | * 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