ruby-changes:68083
From: Kazuhiro <ko1@a...>
Date: Thu, 23 Sep 2021 09:21:02 +0900 (JST)
Subject: [ruby-changes:68083] e0c6e8c64a (master): [DOC] Use `unpack1` instead of `unpack(template)[0]` [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=e0c6e8c64a From e0c6e8c64ac3d7cf05a40acacb36dc60924af897 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Thu, 23 Sep 2021 09:20:00 +0900 Subject: [DOC] Use `unpack1` instead of `unpack(template)[0]` [ci skip] --- ext/socket/basicsocket.c | 2 +- io.c | 2 +- string.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c index 8477a37..44fb7a4 100644 --- a/ext/socket/basicsocket.c +++ b/ext/socket/basicsocket.c @@ -306,7 +306,7 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock) https://github.com/ruby/ruby/blob/trunk/ext/socket/basicsocket.c#L306 * ipttl = sock.getsockopt(:IP, :TTL).int * * optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) - * ipttl = optval.unpack("i")[0] + * ipttl = optval.unpack1("i") * * Option values may be structs. Decoding them can be complex as it involves * examining your system headers to determine the correct definition. An diff --git a/io.c b/io.c index e2f6875..0e11b8a 100644 --- a/io.c +++ b/io.c @@ -3324,7 +3324,7 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex) https://github.com/ruby/ruby/blob/trunk/io.c#L3324 * # each record is prefixed by its 32-bit length * open("variable-record-file") do |f| * while len = f.read(4) - * len = len.unpack("N")[0] # 32-bit length + * len = len.unpack1("N") # 32-bit length * record = f.read(len) # This returns a string even if len is 0. * end * end diff --git a/string.c b/string.c index 7f9559c..299d506 100644 --- a/string.c +++ b/string.c @@ -10831,7 +10831,7 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr) https://github.com/ruby/ruby/blob/trunk/string.c#L10831 * * "abc\u3042\x81".scrub #=> "abc\u3042\uFFFD" * "abc\u3042\x81".scrub("*") #=> "abc\u3042*" - * "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042<e380>" + * "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack1('H*')+'>' } #=> "abc\u3042<e380>" */ static VALUE str_scrub(int argc, VALUE *argv, VALUE str) @@ -10853,7 +10853,7 @@ str_scrub(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L10853 * * "abc\u3042\x81".scrub! #=> "abc\u3042\uFFFD" * "abc\u3042\x81".scrub!("*") #=> "abc\u3042*" - * "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042<e380>" + * "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack1('H*')+'>' } #=> "abc\u3042<e380>" */ static VALUE str_scrub_bang(int argc, VALUE *argv, VALUE str) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/