Commit 35da84bf authored by Joshua Haberman's avatar Joshua Haberman

Ported names fix for Ruby to the release branch.

parent 6d4e7fd7
...@@ -56,15 +56,19 @@ else ...@@ -56,15 +56,19 @@ else
module Internal module Internal
def self.infer_package(names) def self.infer_package(names)
# Package is longest common prefix ending in '.', if any. # Package is longest common prefix ending in '.', if any.
min, max = names.minmax if not names.empty?
last_common_dot = nil min, max = names.minmax
min.size.times { |i| last_common_dot = nil
if min[i] != max[i] then break end min.size.times { |i|
if min[i] == ?. then last_common_dot = i end if min[i] != max[i] then break end
} if min[i] == ?. then last_common_dot = i end
if last_common_dot }
return min.slice(0, last_common_dot) if last_common_dot
return min.slice(0, last_common_dot)
end
end end
nil
end end
class NestingBuilder class NestingBuilder
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment