mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[DOC] Use unpack1
instead of unpack(template)[0]
[ci skip]
This commit is contained in:
parent
fb976df81f
commit
e0c6e8c64a
3 changed files with 4 additions and 4 deletions
|
@ -306,7 +306,7 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock)
|
|||
* 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
|
||||
|
|
2
io.c
2
io.c
|
@ -3324,7 +3324,7 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex)
|
|||
* # 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
|
||||
|
|
4
string.c
4
string.c
|
@ -10831,7 +10831,7 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
|
|||
*
|
||||
* "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)
|
|||
*
|
||||
* "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)
|
||||
|
|
Loading…
Reference in a new issue