Skip to content

Commit a237dba

Browse files
committed
Handle multiple matches in extract_host_inlining.rb
1 parent 9bd160a commit a237dba

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tool/extract_host_inlining.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
raise unless ARGV.size == 2
77
method, file = ARGV
88

9-
lines = File.readlines(file)
10-
9+
all_lines = File.readlines(file)
1110

1211
method = "Root[#{method}]" unless method.start_with?('Root[')
1312
method = " #{method.strip}\n"
1413
blank_line = " \n"
1514

16-
i = lines.index(method)
17-
raise "not found" unless i
18-
start = i - 1
15+
lines = []
16+
while i = all_lines.index(method)
17+
start = i - 1
1918

20-
# i += 1 until lines[i].strip.empty?
21-
i += 1 until lines[i] == blank_line
19+
# i += 1 until lines[i].strip.empty?
20+
i += 1 until all_lines[i] == blank_line
2221

23-
lines = lines[start...i]
22+
lines.concat all_lines[start...i]
23+
lines << "\n"
24+
all_lines = all_lines[i..-1]
25+
end
26+
raise "not found" if lines.empty?
27+
lines.pop # Remove last \n
2428

2529
indent = lines.first[/^ +/]
2630
lines = lines.map { |line| line.sub(indent, '') }

0 commit comments

Comments
 (0)