mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2025-01-12 20:03:28 +01:00
32 lines
534 B
Ruby
32 lines
534 B
Ruby
require_relative '../lib/lib_mktbl.rb'
|
|
|
|
file = ARGV[0]
|
|
old = File.readlines file
|
|
in_stat = false
|
|
new = []
|
|
changed = false
|
|
tmp = []
|
|
old.each do |line|
|
|
if in_stat
|
|
if line == "@@@\n"
|
|
in_stat = false
|
|
new += mktbl tmp
|
|
else
|
|
tmp << line
|
|
end
|
|
elsif line == "@@@table\n"
|
|
changed = true
|
|
in_stat = true
|
|
tmp = []
|
|
else
|
|
new << line
|
|
end
|
|
end
|
|
new.each do |line|
|
|
if line[-1] != "\n"
|
|
line.sub!(/\z/,"\n")
|
|
end
|
|
end
|
|
exit unless changed
|
|
File.write file+".bak", old.join
|
|
File.write file, new.join
|