зеркало из https://github.com/github/ruby.git
Prefer to use File.foreach instead of IO.foreach
This commit is contained in:
Родитель
d063ed12af
Коммит
db0a4c8923
|
@ -23,7 +23,7 @@ until ARGV.empty?
|
|||
end
|
||||
end
|
||||
|
||||
IO.foreach("#{srcdir}/configure.ac") do |line|
|
||||
File.foreach("#{srcdir}/configure.ac") do |line|
|
||||
if /^AC_INIT\((.*)\)/ =~ line
|
||||
version = $1.split(/,\s*/)[1]
|
||||
version.gsub!(/\A\[|\]\z/, '')
|
||||
|
|
|
@ -4,7 +4,7 @@ require_relative '../http'
|
|||
|
||||
if $0 == __FILE__
|
||||
require 'open-uri'
|
||||
IO.foreach(__FILE__) do |line|
|
||||
File.foreach(__FILE__) do |line|
|
||||
puts line
|
||||
break if line.start_with?('end')
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ TestComprehensiveCaseMapping.data_files_available? and class TestComprehensiveC
|
|||
end
|
||||
|
||||
def self.read_data_file(filename)
|
||||
IO.foreach(expand_filename(filename), encoding: Encoding::ASCII_8BIT) do |line|
|
||||
File.foreach(expand_filename(filename), encoding: Encoding::ASCII_8BIT) do |line|
|
||||
if $. == 1
|
||||
if filename == 'UnicodeData'
|
||||
elsif line.start_with?("# #{filename}-#{UNICODE_VERSION}.txt")
|
||||
|
|
|
@ -75,7 +75,7 @@ class TestEmojiBreaks < Test::Unit::TestCase
|
|||
EMOJI_DATA_FILES.each do |file|
|
||||
version_mismatch = true
|
||||
file_tests = []
|
||||
IO.foreach(file.fullname, encoding: Encoding::UTF_8) do |line|
|
||||
File.foreach(file.fullname, encoding: Encoding::UTF_8) do |line|
|
||||
line.chomp!
|
||||
if $.==1
|
||||
if line=="# #{file.basename}-#{file.version}.txt"
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestGraphemeBreaksFromFile < Test::Unit::TestCase
|
|||
if file_available?
|
||||
def read_data
|
||||
tests = []
|
||||
IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line|
|
||||
File.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line|
|
||||
if $. == 1 and not line.start_with?("# GraphemeBreakTest-#{UNICODE_VERSION}.txt")
|
||||
raise "File Version Mismatch"
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ class CaseFolding
|
|||
@version = nil
|
||||
turkic = []
|
||||
|
||||
IO.foreach(filename, mode: "rb") do |line|
|
||||
File.foreach(filename, mode: "rb") do |line|
|
||||
@version ||= line[/-([0-9.]+).txt/, 1]
|
||||
next unless res = pattern.match(line)
|
||||
ch_from = res[1].to_i(16)
|
||||
|
@ -230,7 +230,7 @@ class CaseMapping
|
|||
@specials = []
|
||||
@specials_length = 0
|
||||
@version = nil
|
||||
IO.foreach(File.join(mapping_directory, 'UnicodeData.txt'), mode: "rb") do |line|
|
||||
File.foreach(File.join(mapping_directory, 'UnicodeData.txt'), mode: "rb") do |line|
|
||||
next if line =~ /^</
|
||||
code, _, _, _, _, _, _, _, _, _, _, _, upper, lower, title = line.chomp.split ';'
|
||||
unless upper and lower and title and (upper+lower+title)==''
|
||||
|
@ -239,7 +239,7 @@ class CaseMapping
|
|||
end
|
||||
|
||||
@filename = File.join(mapping_directory, 'SpecialCasing.txt')
|
||||
IO.foreach(@filename, mode: "rb") do |line|
|
||||
File.foreach(@filename, mode: "rb") do |line|
|
||||
@version ||= line[/-([0-9.]+).txt/, 1]
|
||||
line.chomp!
|
||||
line, comment = line.split(/ *#/)
|
||||
|
|
|
@ -59,7 +59,7 @@ def parse_unicode_data(file)
|
|||
data = {'Any' => (0x0000..0x10ffff).to_a, 'Assigned' => [],
|
||||
'ASCII' => (0..0x007F).to_a, 'NEWLINE' => [0x0a], 'Cn' => []}
|
||||
beg_cp = nil
|
||||
IO.foreach(file) do |line|
|
||||
File.foreach(file) do |line|
|
||||
fields = line.split(';')
|
||||
cp = fields[0].to_i(16)
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ class ExtLibs
|
|||
extracted = false
|
||||
dest = File.dirname(list)
|
||||
url = chksums = nil
|
||||
IO.foreach(list) do |line|
|
||||
File.foreach(list) do |line|
|
||||
line.sub!(/\s*#.*/, '')
|
||||
if /^(\w+)\s*=\s*(.*)/ =~ line
|
||||
vars[$1] = vars.expand($2)
|
||||
|
|
|
@ -12,7 +12,7 @@ module Memory
|
|||
PROC_FILE = procfile
|
||||
VM_PAT = pat
|
||||
def self.read_status
|
||||
IO.foreach(PROC_FILE, encoding: Encoding::ASCII_8BIT) do |l|
|
||||
File.foreach(PROC_FILE, encoding: Encoding::ASCII_8BIT) do |l|
|
||||
yield($1.downcase.intern, $2.to_i * 1024) if VM_PAT =~ l
|
||||
end
|
||||
end
|
||||
|
|
|
@ -205,7 +205,7 @@ print " CONFIG = {}\n"
|
|||
print " CONFIG[\"DESTDIR\"] = DESTDIR\n"
|
||||
|
||||
versions = {}
|
||||
IO.foreach(File.join(srcdir, "version.h")) do |l|
|
||||
File.foreach(File.join(srcdir, "version.h")) do |l|
|
||||
m = /^\s*#\s*define\s+RUBY_(PATCHLEVEL)\s+(-?\d+)/.match(l)
|
||||
if m
|
||||
versions[m[1]] = m[2]
|
||||
|
@ -226,7 +226,7 @@ IO.foreach(File.join(srcdir, "version.h")) do |l|
|
|||
end
|
||||
end
|
||||
if versions.size != 4
|
||||
IO.foreach(File.join(srcdir, "include/ruby/version.h")) do |l|
|
||||
File.foreach(File.join(srcdir, "include/ruby/version.h")) do |l|
|
||||
m = /^\s*#\s*define\s+RUBY_API_VERSION_(\w+)\s+(-?\d+)/.match(l)
|
||||
if m
|
||||
versions[m[1]] ||= m[2]
|
||||
|
|
|
@ -49,7 +49,7 @@ class Exports
|
|||
end
|
||||
|
||||
def read_substitution(header, syms, winapis)
|
||||
IO.foreach(header) do |line|
|
||||
File.foreach(header) do |line|
|
||||
if /^#define (\w+)\((.*?)\)\s+(?:\(void\))?(rb_w32_\w+)\((.*?)\)\s*$/ =~ line and
|
||||
$2.delete(" ") == $4.delete(" ")
|
||||
export, internal = $1, $3
|
||||
|
|
Загрузка…
Ссылка в новой задаче