Skip to content

Commit c1f479d

Browse files
committed
Merge branch 'master' into 2.2
* master: Fixes to assist building Rubinius under Alpine Linux (with musl). Changed "of the issue" to "if the issue" Contributing notes on version managers/releases Expand $PID in Metrics filename. Clean up log output of serial_debug/ic_debug Specify `superclass` in respect to `prepend` Fix correction to documentation for OnStack class. Fixed typ in the OnStack class Log class names for invalid ivars_ references Add a C-API "rb_hash_clear" Fix Range#bsearch for matching end value in find-minimum mode Fix String#split with 0 limit. Fixes #3474 Add a String#split spec with 0 limit
2 parents f56eacf + 2920c9e commit c1f479d

18 files changed

Lines changed: 115 additions & 38 deletions

File tree

CONTRIBUTING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ Gist:
2727
These two files contain the output of the compilation process and the various
2828
configuration options used (e.g. compiler options).
2929

30+
### Version Managers
31+
32+
We can *not* help you with any issues that might be caused by a Ruby version
33+
manager. In the event of any issues please try building from source instead to
34+
see if the issue is caused by Rubinius itself or your version manager of choice.
35+
36+
Issues involving version managers will be closed if they can either not be
37+
reproduced when building from source, or when the original report makes no
38+
mention about the author having tried building from source.
39+
40+
Note that this only applies to the installation procedure. Problems with the
41+
runtime can of course still be reported, even when using a version manager.
42+
43+
### Rubinius Versions
44+
45+
Rubinius releases quite often, at least more often than most other
46+
implementations. As such we ask users to try out the latest version prior to
47+
reporting an issue. This ensures we don't have to start digging through the
48+
code, only to find out the problem has already been resolved in a more recent
49+
release.
50+
3051
### Running Specs
3152

3253
MSpec provides several different scripts to run the specs under different

kernel/common/range.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,47 +51,47 @@ def bsearch
5151

5252
last_true = nil
5353

54-
if max < 0 and min < 0
55-
value = min + (max - min) / 2
56-
elsif min < -max
57-
value = -((-1 - min - max) / 2 + 1)
58-
else
59-
value = (min + max) / 2
60-
end
61-
62-
while min < max
63-
x = yield value
54+
seeker = Proc.new do |current|
55+
x = yield current
6456

65-
return value if x == 0
57+
return current if x == 0
6658

6759
case x
6860
when Numeric
6961
if x > 0
70-
min = value + 1
62+
min = current + 1
7163
else
72-
max = value
64+
max = current
7365
end
7466
when true
75-
last_true = value
76-
max = value
67+
last_true = current
68+
max = current
7769
when false, nil
78-
min = value + 1
70+
min = current + 1
7971
else
8072
raise TypeError, "Range#bsearch block must return Numeric or boolean"
8173
end
74+
end
8275

76+
while min < max
8377
if max < 0 and min < 0
84-
value = min + (max - min) / 2
78+
mid = min + (max - min) / 2
8579
elsif min < -max
86-
value = -((-1 - min - max) / 2 + 1)
80+
mid = -((-1 - min - max) / 2 + 1)
8781
else
88-
value = (min + max) / 2
89-
end
82+
mid = (min + max) / 2
83+
end
84+
85+
seeker.call mid
86+
end
87+
88+
if min == max
89+
seeker.call min
9090
end
9191

9292
if min < max
93-
return @begin if value == start
94-
return @begin.kind_of?(Float) ? value.to_f : value
93+
return @begin if mid == start
94+
return @begin.kind_of?(Float) ? mid.to_f : mid
9595
end
9696

9797
if last_true

kernel/common/splitter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def self.split(string, pattern, limit)
3232
return [string.dup] if limit == 1
3333
limited = true
3434
else
35-
tail_empty = true
35+
if limit < 0
36+
tail_empty = true
37+
end
3638
limited = false
3739
end
3840
end

rakelib/platform.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ file 'runtime/platform.conf' => deps do |task|
752752

753753
Rubinius::FFI::Generators::Constants.new 'rbx.platform.signal' do |cg|
754754
cg.include 'signal.h'
755-
unless BUILD_CONFIG[:windows]
755+
unless BUILD_CONFIG[:windows] or RUBY_PLATFORM.match(/linux-musl$/)
756756
cg.include 'sys/signal.h'
757757
end
758758

spec/ruby/core/module/prepend_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
Module.should have_public_instance_method(:prepend, true)
77
end
88

9+
it "does not affect the superclass" do
10+
Class.new { prepend Module.new }.superclass.should == Object
11+
end
12+
913
it "calls #prepend_features(self) in reversed order on each module" do
1014
ScratchPad.record []
1115

spec/ruby/core/string/split_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
"a\x00a b".split(' ').should == ["a\x00a", "b"]
104104
end
105105

106+
describe "when limit is zero" do
107+
it "ignores leading and continuous whitespace when string is a single space" do
108+
" now's the time ".split(' ', 0).should == ["now's", "the", "time"]
109+
end
110+
end
111+
106112
it "splits between characters when its argument is an empty string" do
107113
"hi!".split("").should == ["h", "i", "!"]
108114
"hi!".split("", -1).should == ["h", "i", "!", ""]

spec/ruby/optional/capi/ext/hash_spec.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ VALUE hash_spec_rb_hash_aset(VALUE self, VALUE hash, VALUE key, VALUE val) {
4040
}
4141
#endif
4242

43+
#ifdef HAVE_RB_HASH_CLEAR
44+
VALUE hash_spec_rb_hash_clear(VALUE self, VALUE hash) {
45+
return rb_hash_clear(hash);
46+
}
47+
#endif
48+
4349
#ifdef HAVE_RB_HASH_DELETE
4450
VALUE hash_spec_rb_hash_delete(VALUE self, VALUE hash, VALUE key) {
4551
return rb_hash_delete(hash, key);
@@ -148,6 +154,10 @@ void Init_hash_spec() {
148154
rb_define_method(cls, "rb_hash_aset", hash_spec_rb_hash_aset, 3);
149155
#endif
150156

157+
#ifdef HAVE_RB_HASH_CLEAR
158+
rb_define_method(cls, "rb_hash_clear", hash_spec_rb_hash_clear, 1);
159+
#endif
160+
151161
#ifdef HAVE_RB_HASH_DELETE
152162
rb_define_method(cls, "rb_hash_delete", hash_spec_rb_hash_delete, 2);
153163
#endif

spec/ruby/optional/capi/ext/rubyspec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
#define HAVE_RB_HASH_FREEZE 1
323323
#define HAVE_RB_HASH_AREF 1
324324
#define HAVE_RB_HASH_ASET 1
325+
#define HAVE_RB_HASH_CLEAR 1
325326
#define HAVE_RB_HASH_DELETE 1
326327
#define HAVE_RB_HASH_DELETE_IF 1
327328
#define HAVE_RB_HASH_FOREACH 1

spec/ruby/optional/capi/hash_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@
9191
end
9292
end
9393

94+
describe "rb_hash_clear" do
95+
it "returns self that cleared keys and values" do
96+
hsh = { :key => 'value' }
97+
@s.rb_hash_clear(hsh).should equal(hsh)
98+
hsh.should == {}
99+
end
100+
end
101+
94102
describe "rb_hash_delete" do
95103
it "removes the key and returns the value" do
96104
hsh = {:chunky => 'bacon'}

spec/tags/ruby/core/range/bsearch_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)