[ruby/openssl] Refactor buffer usage to only use append_as_bytes

https://github.com/ruby/openssl/commit/28f2901c48
This commit is contained in:
Jean Boussier 2025-01-07 11:34:20 +01:00 committed by git
parent 2f5d31d38a
commit 4f79485889
2 changed files with 7 additions and 7 deletions

View File

@ -37,8 +37,8 @@ module OpenSSL::Buffering
end end
end end
alias_method :concat, :append_as_bytes undef_method :concat
alias_method :<<, :append_as_bytes undef_method :<<
end end
## ##
@ -73,7 +73,7 @@ module OpenSSL::Buffering
def fill_rbuff def fill_rbuff
begin begin
@rbuffer << self.sysread(BLOCK_SIZE) @rbuffer.append_as_bytes(self.sysread(BLOCK_SIZE))
rescue Errno::EAGAIN rescue Errno::EAGAIN
retry retry
rescue EOFError rescue EOFError
@ -450,10 +450,10 @@ module OpenSSL::Buffering
def puts(*args) def puts(*args)
s = Buffer.new s = Buffer.new
if args.empty? if args.empty?
s << "\n" s.append_as_bytes("\n")
end end
args.each{|arg| args.each{|arg|
s << arg.to_s s.append_as_bytes(arg.to_s)
s.sub!(/(?<!\n)\z/, "\n") s.sub!(/(?<!\n)\z/, "\n")
} }
do_write(s) do_write(s)
@ -467,7 +467,7 @@ module OpenSSL::Buffering
def print(*args) def print(*args)
s = Buffer.new s = Buffer.new
args.each{ |arg| s << arg.to_s } args.each{ |arg| s.append_as_bytes(arg.to_s) }
do_write(s) do_write(s)
nil nil
end end

View File

@ -31,7 +31,7 @@ class OpenSSL::TestBuffering < OpenSSL::TestCase
end end
def syswrite(str) def syswrite(str)
@io << str @io.append_as_bytes(str)
str.size str.size
end end
end end