I found that reading the whole file in one go and then parsing it is
twice as fast as reading it line by line.
Here's the patch:
--- rake/loaders/makefile.rb.orig 2008-07-22 19:01:11.000000000 +0300
+++ rake/loaders/makefile.rb 2008-07-22 19:27:03.000000000 +0300
@@ -9,16 +9,10 @@
def load(fn)
buffer = ''
open(fn) do |mf|
- mf.each do |line|
- next if line =~ /^\s*#/
- buffer << line
- if buffer =~ /\\$/
- buffer.sub!(/\\\n/, ' ')
- state = :append
- else
- process_line(buffer)
- buffer = ''
- end
+ lines = mf.read
+ lines.gsub!(/\\\n/, ' ')
+ lines.split("\n").each do |line|
+ process_line line
end
end
process_line(buffer) if buffer != ''
Ittay Dror wrote:
when parsing dependency files in the format of make (generated by unix
compilers), the file_task variable (actually, the file name) is not
stripped. so if it contains spaces, it means it represents a different
task than what you'd expect.
here's the patch to solve this:
--- rake/loaders/makefile.rb.orig 2008-07-22 19:01:11.000000000 +0300
+++ rake/loaders/makefile.rb 2008-07-22 18:55:59.000000000 +0300
@@ -29,6 +29,7 @@
# Process one logical line of makefile data.
def process_line(line)
file_task, args = line.split(':')
+ file_task.strip!
return if args.nil?
dependents = args.split
file file_task => dependents
--
--
Ittay Dror <[EMAIL PROTECTED]>
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel