* lib/pp.rb (PP::PPMethods#object_address_group): adjust address format.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2005-11-28 11:26:39 +00:00
parent 3be312869d
commit 5a6ed851fe
2 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,7 @@
Mon Nov 28 20:24:22 2005 Tanaka Akira <akr@m17n.org>
* lib/pp.rb (PP::PPMethods#object_address_group): adjust address format.
Mon Nov 28 18:55:22 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (init_inetsock_internal): remove setting

View File

@ -150,8 +150,15 @@ class PP < PrettyPrint
group(1, '#<' + obj.class.name, '>', &block)
end
case Object.new.inspect
when /\A\#<Object:0x([0-9a-f]+)>\z/
PointerFormat = "%0#{$1.length}x"
else
PointerFormat = "%x"
end
def object_address_group(obj, &block)
id = "%x" % (obj.__id__ * 2)
id = PointerFormat % (obj.__id__ * 2)
id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '')
group(1, "\#<#{obj.class}:0x#{id}", '>', &block)
end