mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mkmf.rb: fix merge_libs
* lib/mkmf.rb (MakeMakefile#merge_libs): insert following reversal ordered elements just after the duplicated element, not overwriting successive elements. [ruby-core:50314] [Bug #7467] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fd0c338df7
commit
13b11810e2
3 changed files with 29 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Feb 7 15:33:17 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (MakeMakefile#merge_libs): insert following reversal
|
||||
ordered elements just after the duplicated element, not overwriting
|
||||
successive elements. [ruby-core:50314] [Bug #7467]
|
||||
|
||||
Thu Feb 7 14:56:15 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rubygems/package.rb: Ensure digests are generated for signing.
|
||||
|
|
14
lib/mkmf.rb
14
lib/mkmf.rb
|
@ -269,17 +269,15 @@ module MakeMakefile
|
|||
|
||||
def merge_libs(*libs)
|
||||
libs.inject([]) do |x, y|
|
||||
xy = x & y
|
||||
xn = yn = 0
|
||||
y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
|
||||
y.each_with_index do |v, yi|
|
||||
if xy.include?(v)
|
||||
xi = [x.index(v), xn].max()
|
||||
x[xi, 1] = y[yn..yi]
|
||||
xn, yn = xi + (yi - yn + 1), yi + 1
|
||||
if xi = x.rindex(v)
|
||||
x[(xi+1)..-1] = merge_libs(y[(yi+1)..-1], x[(xi+1)..-1])
|
||||
x[xi, 0] = y[0...yi]
|
||||
break
|
||||
end
|
||||
end
|
||||
x.concat(y[yn..-1] || [])
|
||||
end and x.concat(y)
|
||||
x
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -65,5 +65,22 @@ class TestMkmf
|
|||
assert_in_order(array, "c", "d" , bug)
|
||||
## assume that a and c have no dependency
|
||||
end
|
||||
|
||||
def test_merge_reversal_followed
|
||||
bug7467 = '[ruby-core:50314] [Bug #7467]'
|
||||
array = nil
|
||||
assert_nothing_raised(bug7467) {
|
||||
array = merge_libs(%w[a b c d e f g h], %w[d c d e], [])
|
||||
}
|
||||
assert_in_order(array, "a", "b", bug7467)
|
||||
assert_in_order(array, "b", "c", bug7467)
|
||||
assert_in_order(array, "c", "d", bug7467)
|
||||
assert_in_order(array, "d", "e", bug7467)
|
||||
assert_in_order(array, "e", "f", bug7467)
|
||||
assert_in_order(array, "f", "g", bug7467)
|
||||
assert_in_order(array, "g", "h", bug7467)
|
||||
assert_in_order(array, "d", "c", bug7467)
|
||||
assert_in_order(array, "c", "e", bug7467)
|
||||
end
|
||||
end
|
||||
end if RUBY_ENGINE == "ruby"
|
||||
|
|
Loading…
Reference in a new issue