Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/irb
File: magic-file.rb
# frozen_string_literal: false
[0] Fix | Delete
module IRB
[1] Fix | Delete
class << (MagicFile = Object.new)
[2] Fix | Delete
# see parser_magic_comment in parse.y
[3] Fix | Delete
ENCODING_SPEC_RE = %r"coding\s*[=:]\s*([[:alnum:]\-_]+)"
[4] Fix | Delete
[5] Fix | Delete
def open(path)
[6] Fix | Delete
io = File.open(path, 'rb')
[7] Fix | Delete
line = io.gets
[8] Fix | Delete
line = io.gets if line[0,2] == "#!"
[9] Fix | Delete
encoding = detect_encoding(line)
[10] Fix | Delete
internal_encoding = encoding
[11] Fix | Delete
encoding ||= IRB.default_src_encoding
[12] Fix | Delete
io.rewind
[13] Fix | Delete
io.set_encoding(encoding, internal_encoding)
[14] Fix | Delete
[15] Fix | Delete
if block_given?
[16] Fix | Delete
begin
[17] Fix | Delete
return (yield io)
[18] Fix | Delete
ensure
[19] Fix | Delete
io.close
[20] Fix | Delete
end
[21] Fix | Delete
else
[22] Fix | Delete
return io
[23] Fix | Delete
end
[24] Fix | Delete
end
[25] Fix | Delete
[26] Fix | Delete
private
[27] Fix | Delete
def detect_encoding(line)
[28] Fix | Delete
return unless line[0] == ?#
[29] Fix | Delete
line = line[1..-1]
[30] Fix | Delete
line = $1 if line[/-\*-\s*(.*?)\s*-*-$/]
[31] Fix | Delete
return nil unless ENCODING_SPEC_RE =~ line
[32] Fix | Delete
encoding = $1
[33] Fix | Delete
return encoding.sub(/-(?:mac|dos|unix)/i, '')
[34] Fix | Delete
end
[35] Fix | Delete
end
[36] Fix | Delete
end
[37] Fix | Delete
[38] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function