summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-07 06:33:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-07 06:33:22 +0000
commit13b11810e289bc7b946e9c6eac7d1348107f0eda (patch)
treecab8d83ecc9d3b829531565d31b2f9d1febb5e5c /lib
parentfd0c338df7348b7a482f0fc135505aade7908933 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/mkmf.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index a33bb4c933..226bb301fb 100644
--- a/lib/mkmf.rb
+++ b/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