[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...
Issue #14357 has been reported by vo.x (Vit Ondruch).
11 messages
2018/01/15
[#85364] Re: [Ruby trunk Bug#14357] thread_safe tests suite segfaults
— Eric Wong <normalperson@...>
2018/02/03
v.ondruch@tiscali.cz wrote:
[#85368] Re: [Ruby trunk Bug#14357] thread_safe tests suite segfaults
— Eric Wong <normalperson@...>
2018/02/03
Eric Wong wrote:
[#85442] Re: [Ruby trunk Bug#14357] thread_safe tests suite segfaults
— Eric Wong <normalperson@...>
2018/02/06
Eric Wong <normalperson@yhbt.net> wrote:
[#85451] Re: [Ruby trunk Bug#14357] thread_safe tests suite segfaults
— Vladimir Makarov <vmakarov@...>
2018/02/06
On 02/06/2018 05:00 AM, Eric Wong wrote:
[#84874] [Ruby trunk Bug#14360] Regression CSV#open method for writing from Ruby 2.4.3 to 2.5.0 — shevegen@...
Issue #14360 has been updated by shevegen (Robert A. Heiler).
3 messages
2018/01/15
[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...
Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).
10 messages
2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2018/01/23
hsbt@ruby-lang.org wrote:
[#85081] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2018/01/24
Eric Wong <normalperson@yhbt.net> wrote:
[#85082] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2018/01/24
> Thinking about this even more; I don't think it's possible to
[#85088] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — danieldasilvaferreira@...
Issue #13618 has been updated by dsferreira (Daniel Ferreira).
3 messages
2018/01/25
[#85107] [Ruby trunk Misc#14222] Mutex.lock is not safe inside signal handler: what is? — eregontp@...
Issue #14222 has been updated by Eregon (Benoit Daloze).
3 messages
2018/01/25
[#85136] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...>
samuel@oriontransfer.org wrote:
3 messages
2018/01/26
[ruby-core:85126] [Ruby trunk Feature#4938] Add Random.bytes [patch]
From:
nobu@...
Date:
2018-01-26 04:03:27 UTC
List:
ruby-core #85126
Issue #4938 has been updated by nobu (Nobuyoshi Nakada).
Updated.
```diff
diff --git i/random.c w/random.c
index 43a3d2ffee..b800f1d9a1 100644
--- i/random.c
+++ w/random.c
@@ -1134,6 +1134,19 @@ rb_random_bytes(VALUE obj, long n)
return genrand_bytes(rnd, n);
}
+/*
+ * call-seq: Random.bytes(size) -> a_string
+ *
+ * Returns a random binary string. The argument size specified the length of
+ * the result string.
+ */
+static VALUE
+random_s_bytes(VALUE obj, VALUE len)
+{
+ rb_random_t *rnd = rand_start(&default_rand);
+ return genrand_bytes(rnd, NUM2LONG(rb_to_int(len)));
+}
+
static VALUE
range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp)
{
@@ -1636,6 +1649,7 @@ InitVM_Random(void)
rb_define_singleton_method(rb_cRandom, "srand", rb_f_srand, -1);
rb_define_singleton_method(rb_cRandom, "rand", random_s_rand, -1);
+ rb_define_singleton_method(rb_cRandom, "bytes", random_s_bytes, 1);
rb_define_singleton_method(rb_cRandom, "new_seed", random_seed, 0);
rb_define_singleton_method(rb_cRandom, "urandom", random_raw_seed, 1);
rb_define_private_method(CLASS_OF(rb_cRandom), "state", random_s_state, 0);
diff --git i/test/ruby/test_rand.rb w/test/ruby/test_rand.rb
index 882d33fb40..136ee4f912 100644
--- i/test/ruby/test_rand.rb
+++ w/test/ruby/test_rand.rb
@@ -347,10 +347,15 @@
end
def assert_random_bytes(r)
+ srand(0)
assert_equal("", r.bytes(0))
- assert_equal("\xAC".force_encoding("ASCII-8BIT"), r.bytes(1))
- assert_equal("/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT"),
- r.bytes(10))
+ assert_equal("", Random.bytes(0))
+ x = "\xAC".force_encoding("ASCII-8BIT")
+ assert_equal(x, r.bytes(1))
+ assert_equal(x, Random.bytes(1))
+ x = "/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT")
+ assert_equal(x, r.bytes(10))
+ assert_equal(x, Random.bytes(10))
end
def test_random_range
```
----------------------------------------
Feature #4938: Add Random.bytes [patch]
https://bugs.ruby-lang.org/issues/4938#change-69852
* Author: marcandre (Marc-Andre Lafortune)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
It could be useful to add a `Random.bytes` method (equivalent to `Random::DEFAULT.bytes`), as per the simple patch attached.
---Files--------------------------------
randombytes.diff (2.19 KB)
randombytes-ruby22.diff (2.38 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>