bin/review-check in review-5.0.0 vs bin/review-check in review-5.1.0

- old
+ new

@@ -7,15 +7,12 @@ # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # For details of the GNU LGPL, see the file "COPYING". # -require 'pathname' +$LOAD_PATH.unshift(File.realpath('../lib', __dir__)) -bindir = Pathname.new(__FILE__).realpath.dirname -$LOAD_PATH.unshift((bindir + '../lib').realpath) - require 'review' require 'optparse' include ReVIEW::TextUtils @@ -84,10 +81,11 @@ each_paragraph(f) do |para, lineno| s = para.join m = re.match(s) next if m.nil? || m[0] == @review_utils_word_ok next if neg && neg =~ s + str, offset = find_line(para, re) out = sprintf("%s:%d: %s\n", path, lineno + offset, str) print out end end @@ -105,10 +103,11 @@ # multiple lines? i = 0 while i < lines.size - 1 str = lines[i] + lines[i + 1] return str.gsub(re, '<<<\&>>>'), i if re =~ str + i += 1 end raise 'must not happen' end @@ -116,10 +115,11 @@ def words_re(rc) words = [] nega = [] File.foreach(rc) do |line| next if line[0, 1] == '#' + if / !/ =~ line line, n = *line.split('!', 2) nega.push(n.strip) end words.push(line.strip) @@ -132,30 +132,28 @@ @review_utils_word_ok = nil while line = f.gets case line when /\A\#@ok\((.*)\)/ @review_utils_word_ok = $1 - when /\A\#@/ + when /\A\#@/, /\A\s*\z/ # do nothing next when %r{\A//caption\{(.*?)//\}} yield [$1], f.filename, f.lineno when %r<\A//\w.*\{\s*\z> while line = f.gets break if %r{//\}} === line end when /\A=/ yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno - when /\A\s*\z/ - # skip - next else buf = [line.strip] lineno = f.lineno while line = f.gets break if line.strip.empty? break if %r{\A(?:=|//[\w\}])} =~ line next if /\A\#@/ =~ line + buf.push(line.strip) end yield buf, lineno @review_utils_word_ok = nil end