diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-07 05:13:54 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-07 05:13:54 +0000 |
commit | 9f19f36ed5be8025ea4a900bb93b03aa30e4a03b (patch) | |
tree | 02e182d8f6604b094b9c93743ea0633deacb57d9 /ext/openssl/lib | |
parent | 6645b928266cf7f8139f58b6b260e82f291d8446 (diff) | |
download | ruby-9f19f36ed5be8025ea4a900bb93b03aa30e4a03b.tar.gz |
* 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
Diffstat (limited to 'ext/openssl/lib')
-rw-r--r-- | ext/openssl/lib/openssl/buffering.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb index 39c442bfd1..27bf62bda7 100644 --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -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? |