Skip to content

Commit 1805aaa

Browse files
committedSep 29, 2015
converted until/end into begin/end until which fixed 4 specs
1 parent e6e1a08 commit 1805aaa

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed
 

Diff for: ‎kernel/common/io.rb

+18-12
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ def tty?
459459
ensure_open
460460
FFI::Platform::POSIX.isatty(@descriptor) == 1
461461
end
462+
463+
def inspect
464+
stat = Stat.fstat(@descriptor)
465+
"fd [#{descriptor}], mode [#{@mode}], total_size [#{@total_size}], offset [#{@offset}], eof [#{@eof}], stat.size [#{stat.size}], written? [#{@written}]"
466+
end
462467
end # class FileDescriptor
463468

464469
class BufferedFileDescriptor < FileDescriptor
@@ -700,6 +705,7 @@ def self.select(readables, writables, errorables, timeout)
700705

701706
attr_accessor :external
702707
attr_accessor :internal
708+
attr_accessor :fd # FIXME: just for debugging
703709

704710
def self.binread(file, length=nil, offset=0)
705711
raise ArgumentError, "Negative length #{length} given" if !length.nil? && length < 0
@@ -1718,7 +1724,7 @@ def read_to_separator
17181724
buffer = "".force_encoding(Encoding::ASCII_8BIT)
17191725
separator_size = @separator.bytesize
17201726

1721-
until buffer.size == 0 && @io.eof?
1727+
begin
17221728
if buffer.size == 0
17231729
buffer = @io.read(READ_SIZE)
17241730
end
@@ -1754,7 +1760,7 @@ def read_to_separator
17541760
str << buffer
17551761
buffer.clear
17561762
end
1757-
end
1763+
end until buffer.size == 0 && @io.eof?
17581764

17591765
str << buffer
17601766

@@ -1804,7 +1810,7 @@ def read_to_separator_with_limit
18041810
#TODO: implement ignoring encoding with negative limit
18051811
wanted = limit = @limit.abs
18061812

1807-
until buffer.size == 0 && @io.eof?
1813+
begin
18081814
if buffer.size == 0
18091815
buffer = @io.read(READ_SIZE)
18101816
end
@@ -1853,7 +1859,7 @@ def read_to_separator_with_limit
18531859
buffer.clear
18541860
end
18551861
end
1856-
end
1862+
end until buffer.size == 0 && @io.eof?
18571863

18581864
unless str.empty?
18591865
str = IO.read_encode(@io, str)
@@ -1867,9 +1873,9 @@ def read_to_separator_with_limit
18671873
def read_all
18681874
str = ""
18691875

1870-
until @io.eof?
1876+
begin
18711877
str << @io.read
1872-
end
1878+
end until @io.eof?
18731879

18741880
unless str.empty?
18751881
str = IO.read_encode(@io, str)
@@ -1884,7 +1890,7 @@ def read_to_limit
18841890
str = ""
18851891
wanted = limit = @limit.abs
18861892

1887-
until @io.eof?
1893+
begin
18881894
str << @io.read(wanted)
18891895

18901896
str = try_to_force_encoding(@io, str)
@@ -1894,7 +1900,7 @@ def read_to_limit
18941900
yield str
18951901

18961902
str = ""
1897-
end
1903+
end until @io.eof?
18981904

18991905
unless str.empty?
19001906
str = IO.read_encode(@io, str)
@@ -2175,15 +2181,15 @@ def getc
21752181
return if eof?
21762182

21772183
char = ""
2178-
until eof?
2184+
begin
21792185
char.force_encoding Encoding::ASCII_8BIT
21802186
char << read(1)
21812187

21822188
char.force_encoding(self.external_encoding || Encoding.default_external)
21832189
if char.chr_at(0)
21842190
return IO.read_encode self, char
21852191
end
2186-
end
2192+
end until eof?
21872193

21882194
return nil
21892195
end
@@ -2409,11 +2415,11 @@ def read(length=nil, buffer=nil)
24092415
# If the buffer is already exhausted, returns +""+.
24102416
def read_all
24112417
str = ""
2412-
until eof?
2418+
begin
24132419
buffer = ""
24142420
@fd.read(nil, buffer)
24152421
str << buffer
2416-
end
2422+
end until eof?
24172423

24182424
str
24192425
end

0 commit comments

Comments
 (0)