mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/openssl/lib/openssl/buffering.rb (Buffering#initialize):
should set @eof and @rbuffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6645b92826
commit
9f19f36ed5
2 changed files with 11 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Mar 7 14:13:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/lib/openssl/buffering.rb (Buffering#initialize):
|
||||
should set @eof and @rbuffer.
|
||||
|
||||
Mon Mar 7 10:28:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (inspect_obj): unintended space removal.
|
||||
|
|
|
@ -20,6 +20,8 @@ module Buffering
|
|||
BLOCK_SIZE = 1024*16
|
||||
|
||||
def initialize(*args)
|
||||
@eof = false
|
||||
@rbuffer = ""
|
||||
@sync = @io.sync
|
||||
end
|
||||
|
||||
|
@ -29,7 +31,6 @@ module Buffering
|
|||
private
|
||||
|
||||
def fill_rbuff
|
||||
@rbuffer = "" unless defined? @rbuffer
|
||||
begin
|
||||
@rbuffer << self.sysread(BLOCK_SIZE)
|
||||
rescue Errno::EAGAIN
|
||||
|
@ -40,7 +41,7 @@ module Buffering
|
|||
end
|
||||
|
||||
def consume_rbuff(size=nil)
|
||||
if @rbuffer.size == 0
|
||||
if @rbuffer.empty?
|
||||
nil
|
||||
else
|
||||
size = @rbuffer.size unless size
|
||||
|
@ -61,8 +62,6 @@ module Buffering
|
|||
return ""
|
||||
end
|
||||
end
|
||||
fill_rbuff unless defined? @rbuffer
|
||||
@eof ||= nil
|
||||
until @eof
|
||||
break if size && size <= @rbuffer.size
|
||||
fill_rbuff
|
||||
|
@ -84,7 +83,7 @@ module Buffering
|
|||
return ""
|
||||
end
|
||||
end
|
||||
if !defined?(@rbuffer) || @rbuffer.size == 0
|
||||
if @rbuffer.empty?
|
||||
begin
|
||||
return sysread(maxlen, buf)
|
||||
rescue Errno::EAGAIN
|
||||
|
@ -101,9 +100,7 @@ module Buffering
|
|||
end
|
||||
|
||||
def gets(eol=$/)
|
||||
fill_rbuff unless defined? @rbuffer
|
||||
idx = @rbuffer.index(eol)
|
||||
@eof ||= nil
|
||||
until @eof
|
||||
break if idx
|
||||
fill_rbuff
|
||||
|
@ -158,9 +155,8 @@ module Buffering
|
|||
end
|
||||
|
||||
def eof?
|
||||
@eof ||= nil
|
||||
fill_rbuff if !@eof && (!defined?(@rbuffer) || @rbuffer.size == 0)
|
||||
@eof && @rbuffer.size == 0
|
||||
fill_rbuff if !@eof && @rbuffer.empty?
|
||||
@eof && @rbuffer.empty?
|
||||
end
|
||||
alias eof eof?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue