ruby-changes:45253
From: nobu <ko1@a...>
Date: Sat, 14 Jan 2017 11:26:53 +0900 (JST)
Subject: [ruby-changes:45253] nobu:r57326 (trunk): resolv.rb: byte buffer
nobu 2017-01-14 11:26:49 +0900 (Sat, 14 Jan 2017) New Revision: 57326 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57326 Log: resolv.rb: byte buffer * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): treat the data as a byte buffer. Modified files: trunk/lib/resolv.rb Index: lib/resolv.rb =================================================================== --- lib/resolv.rb (revision 57325) +++ lib/resolv.rb (revision 57326) @@ -1521,12 +1521,12 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1521 def initialize(data) @data = data @index = 0 - @limit = data.length + @limit = data.bytesize yield self end def inspect - "\#<#{self.class}: #{@data[0, @index].inspect} #{@data[@index..-1].inspect}>" + "\#<#{self.class}: #{@data.byteslice(0, @index).inspect} #{@data.byteslice(@index..-1).inspect}>" end def get_length16 @@ -1545,7 +1545,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1545 def get_bytes(len = @limit - @index) raise DecodeError.new("limit exceeded") if @limit < @index + len - d = @data[@index, len] + d = @data.byteslice(@index, len) @index += len return d end @@ -1573,9 +1573,9 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1573 def get_string raise DecodeError.new("limit exceeded") if @limit <= @index - len = @data[@index].ord + len = @data.getbyte(@index) raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len - d = @data[@index + 1, len] + d = @data.byteslice(@index + 1, len) @index += 1 + len return d end @@ -1598,7 +1598,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1598 d = [] while true raise DecodeError.new("limit exceeded") if @limit <= @index - case @data[@index].ord + case @data.getbyte(@index) when 0 @index += 1 if save_index -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/