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

143 Коммитов

Автор SHA1 Сообщение Дата
drbrain 42a9234cc4 * random.c (random_init): Clarify that the default seed is
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
2012-04-19 00:35:32 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* 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
2012-03-14 21:10:34 +00:00
nobu 42437780d6 * random.c (Init_Random): removed rb_Random_DEFAULT and register as
mark-object instead of global variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-11 22:04:13 +00:00
nobu b87f2fe1e4 * random.c (random_s_rand): ensure default PRNG is re-initialized
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
2012-03-11 22:03:36 +00:00
mrkn 923bff74b1 * random.c: remove a duplicated comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-18 14:28:42 +00:00
akr da74bc7552 * process.c (ruby_setsid): use rb_cloexec_open.
(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
2011-10-29 04:01:54 +00:00
akr b574a4d4a1 * include/ruby/intern.h (rb_fd_set_cloexec): declared.
* 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
2011-10-22 09:58:15 +00:00
drbrain f365f19054 * random.c: Improve documentation of Random. Patch by Gregory
Parkhurst.  [Ruby 1.9 - Bug #5410]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05 23:54:33 +00:00
drbrain 9654a4c985 * random.c (Init_Random): Add a top-level comment for Random. Patch
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
2011-10-04 20:48:34 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
akr b41ccc4a9c * include/ruby/intern.h (rb_update_max_fd): declaration moved from
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
2011-07-20 13:26:10 +00:00
marcandre 3f5e567a47 * random.c: Documentation fix for Random#bytes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 15:42:37 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
naruse 63f39fcb40 * random.c (random_rand): remove unused variables.
* 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
2011-04-25 07:56:42 +00:00
sorah b5909efd13 * random.c (rb_f_rand, random_s_rand): RDocs for them.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-24 23:25:11 +00:00
mrkn 2aeb3b47ee * random.c (random_s_rand, Init_Random): Random.rand should behave as
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
2011-04-24 22:27:39 +00:00
naruse 0efb462a50 * random.c (rb_f_srand): fix rdoc: srand(0)'s 0 is a seed.
[ruby-core:35833] fixes #4590

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-20 16:31:25 +00:00
nobu be7e8ca772 * random.c (random_rand): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-05 20:17:36 +00:00
akr 0c232beb9c * random.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 04:08:22 +00:00
nobu 99aaee351e * random.c (random_rand): get rid of overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-20 03:04:59 +00:00
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