def parse_files(options)
files = options.files
files = ["."] if files.empty?
file_list = normalized_file_list(options, files, true)
return [] if file_list.empty?
file_info = []
width = file_list.map { |name| name.length }.max + 1
file_list.each do |fn|
$stderr.printf("\n%*s: ", width, fn) unless options.quiet
content = if RUBY_VERSION >= '1.9' then
File.open(fn, "r:ascii-8bit") { |f| f.read }
else
File.read fn
end
if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
if enc = Encoding.find($1)
content.force_encoding(enc)
end
end
top_level = TopLevel.new(fn)
parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
file_info << parser.scan
@stats.num_files += 1
end
file_info
end