mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* random.c (random_ulong_limited): avoid left shift count >= width of
type on 32bit environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9ca303b923
commit
454f028632
2 changed files with 5 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Jul 4 13:08:48 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* random.c (random_ulong_limited): avoid left shift count >= width of
|
||||||
|
type on 32bit environment.
|
||||||
|
|
||||||
Sun Jul 3 18:51:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
Sun Jul 3 18:51:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* test/ruby/enc/test_case_comprehensive.rb, test_regex_casefold.rb,
|
* test/ruby/enc/test_case_comprehensive.rb, test_regex_casefold.rb,
|
||||||
|
|
2
random.c
2
random.c
|
@ -992,9 +992,7 @@ random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit)
|
||||||
const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
|
const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
|
||||||
const unsigned long mask = ~(~0UL << w);
|
const unsigned long mask = ~(~0UL << w);
|
||||||
const unsigned long full =
|
const unsigned long full =
|
||||||
#if SIZEOF_LONG == 4
|
|
||||||
(size_t)n >= sizeof(unsigned long) ? ~0UL :
|
(size_t)n >= sizeof(unsigned long) ? ~0UL :
|
||||||
#endif
|
|
||||||
~(~0UL << n * CHAR_BIT);
|
~(~0UL << n * CHAR_BIT);
|
||||||
unsigned long val, bits = 0, rest = 0;
|
unsigned long val, bits = 0, rest = 0;
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in a new issue