lib/review/preprocessor.rb in review-3.2.0 vs lib/review/preprocessor.rb in review-4.0.0
- old
+ new
@@ -49,14 +49,14 @@
@logger = ReVIEW.logger
@leave_content = nil
end
def process(inf, outf)
- init_errorutils inf
+ init_errorutils(inf)
@f = outf
begin
- preproc inf
+ preproc(inf)
rescue Errno::ENOENT => e
error e.message
end
end
@@ -78,11 +78,11 @@
when /\A\#@mapoutput/
direc = parse_directive(line, 1, 'stderr')
@f.print line
get_output(expand(direc.arg), direc['stderr']).each { |out| @f.print out.string }
- skip_list f
+ skip_list(f)
when /\A\#@mapfile/
direc = parse_directive(line, 1, 'eval')
path = expand(direc.arg)
@leave_content = File.extname(path) == '.re'
@@ -129,19 +129,19 @@
def replace_block(f, directive_line, newlines, with_lineno)
@f.print directive_line
newlines.each do |line|
if with_lineno
- print_number line.number
+ print_number(line.number)
end
@f.print line.string
end
- skip_list f
+ skip_list(f)
end
def print_number(num)
- @f.printf '%4s ', (num ? num.to_s : '')
+ @f.printf('%4s ', (num ? num.to_s : ''))
end
def skip_list(f)
begline = f.lineno
f.each_line do |line|
@@ -277,11 +277,11 @@
def get_output(cmd, use_stderr)
out = err = nil
Open3.popen3(cmd) do |_stdin, stdout, stderr|
out = stdout.readlines
if use_stderr
- out.concat stderr.readlines
+ out.concat(stderr.readlines)
else
err = stderr.readlines
end
end
if err and !err.empty?
@@ -359,11 +359,11 @@
return _parse_file(f)
end
end
def parse_file(fname)
- File.open(fname, 'r:BOM|utf-8') do |f|
+ File.open(fname, 'rt:BOM|utf-8') do |f|
init_errorutils f
return _parse_file(f)
end
end
@@ -401,18 +401,18 @@
key = "#{type}/#{spec}"
if curr[key]
error "begin x2: #{key}"
end
(repo[type] ||= {})[spec] = curr[key] = []
- opened.push [type, spec]
+ opened.push([type, spec])
when %r{(?:\A\#@|\#@@)([a-z]+)/(\w+)\}}
type = check_type($1)
spec = check_spec($2)
curr.delete("#{type}/#{spec}") or
error "end before begin: #{type}/#{spec}"
- opened.delete "#{type}/#{spec}"
+ opened.delete("#{type}/#{spec}")
when /(?:\A\#@|\#@@)\}/
type, spec = opened.last
curr.delete("#{type}/#{spec}") or
error "closed before open: #{type}/#{spec}"
@@ -421,20 +421,20 @@
when /(?:\A\#@|\#@@)yacchack/
yacchack = true
when /\A\#@-/ # does not increment line number.
line = canonical($')
- curr.each_value { |list| list.push Line.new(nil, line) }
+ curr.each_value { |list| list.push(Line.new(nil, line)) }
else
next if yacchack and line.strip == ';'
line = canonical(line)
- curr.each_value { |list| list.push Line.new(lineno, line) }
+ curr.each_value { |list| list.push(Line.new(lineno, line)) }
lineno += 1
end
end
if curr.size > 1
- curr.delete 'WHOLE'
+ curr.delete('WHOLE')
curr.each { |range, lines| @logger.warn "#{filename}: unclosed range: #{range} (begin @#{lines.first.number})" }
raise ApplicationError, 'ERROR'
end
repo