Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a8ececbb7850
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f4bd9c763f6d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 2, 2015

  1. Copy the full SHA
    31b3df9 View commit details
  2. Copy the full SHA
    f4bd9c7 View commit details
Showing with 9 additions and 6 deletions.
  1. +7 −6 kernel/common/io.rb
  2. +2 −0 spec/ruby/core/io/reopen_spec.rb
13 changes: 7 additions & 6 deletions kernel/common/io.rb
Original file line number Diff line number Diff line change
@@ -384,11 +384,10 @@ def reopen(other_fd)

if FFI.call_failed?(FFI::Platform::POSIX.dup2(other_fd, current_fd))
Errno.handle("reopen")
return nil
end

#set_mode
#reset_positioning
set_mode
reset_positioning

return true
end
@@ -411,8 +410,8 @@ def reopen_path(path, mode)
FFI::Platform::POSIX.close(other_fd)
end

#set_mode
#reset_positioning
set_mode
reset_positioning

return true
end
@@ -433,7 +432,7 @@ def seek_positioning

def set_mode
if IO::F_GETFL
if FFI.called_failed?(acc_mode = FFI::Platform::POSIX.fcntl(@descriptor, IO::F_GETFL, 0))
if FFI.call_failed?(acc_mode = FFI::Platform::POSIX.fcntl(@descriptor, IO::F_GETFL, 0))
Errno.handle("failed")
end
else
@@ -2815,6 +2814,8 @@ def reopen(other, mode=undefined)
if io.respond_to?(:path)
@path = io.path
end

seek(other.pos, SEEK_SET)
else
flush unless closed?

2 changes: 2 additions & 0 deletions spec/ruby/core/io/reopen_spec.rb
Original file line number Diff line number Diff line change
@@ -21,12 +21,14 @@
it "calls #to_io to convert an object" do
obj = mock("io")
obj.should_receive(:to_io).and_return(@other_io)
obj.stub!(:pos).and_return(0)
@io.reopen obj
end

it "changes the class of the instance to the class of the object returned by #to_io" do
obj = mock("io")
obj.should_receive(:to_io).and_return(@other_io)
obj.stub!(:pos).and_return(0)
@io.reopen(obj).should be_an_instance_of(File)
end