diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2024-01-01 22:50:32 +1300 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-01-13 00:28:26 +0000 |
commit | f7178045bb11fc3722a98082ed81e1ec39c4940f (patch) | |
tree | 5e3d5561a09637a857ca75c08594af83225c7f76 /ext | |
parent | 08d4e5ebef3d372ca52de95d8ed896d7def8de49 (diff) |
[ruby/openssl] Add support for `gets(chomp: true)`.
https://github.com/ruby/openssl/commit/8aa3849cff
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/lib/openssl/buffering.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb index 9570f14f37..68aa7bc970 100644 --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -229,7 +229,7 @@ module OpenSSL::Buffering # # Unlike IO#gets the separator must be provided if a limit is provided. - def gets(eol=$/, limit=nil) + def gets(eol=$/, limit=nil, chomp: false) idx = @rbuffer.index(eol) until @eof break if idx @@ -244,7 +244,11 @@ module OpenSSL::Buffering if size && limit && limit >= 0 size = [size, limit].min end - consume_rbuff(size) + line = consume_rbuff(size) + if chomp && line + line.chomp!(eol) + end + line end ## |