Skip to content

Commit 3f6e30e

Browse files
noburhenium
authored andcommitted
openssl/buffering.rb: no RS when output
* ext/openssl/lib/openssl/buffering.rb (do_write, puts): output methods should not be affected by the input record separator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Sync-with-trunk: r62038
1 parent 7929b53 commit 3f6e30e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/openssl/buffering.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ def do_write(s)
316316
@wbuffer << s
317317
@wbuffer.force_encoding(Encoding::BINARY)
318318
@sync ||= false
319-
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
320-
remain = idx ? idx + $/.size : @wbuffer.length
319+
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex("\n")
320+
remain = idx ? idx + 1 : @wbuffer.size
321321
nwritten = 0
322322
while remain > 0
323323
str = @wbuffer[nwritten,remain]
@@ -409,9 +409,7 @@ def puts(*args)
409409
end
410410
args.each{|arg|
411411
s << arg.to_s
412-
if $/ && /\n\z/ !~ s
413-
s << "\n"
414-
end
412+
s.sub!(/(?<!\n)\z/, "\n")
415413
}
416414
do_write(s)
417415
nil

0 commit comments

Comments
 (0)