DL::PtrData#inspect

e$B$3$s$P$s$O!"e(Bsheepman e$B$G$9!#e(B

DL::PtrData e$B$He(B DL::Symbol e$B$Ne(B inspect e$B$,e(B

$ ruby-1.8.5 -rdl -e ‘p DL::Symbol.new(0, “a”, “I”)’
#<DL::Symbol:0x0x811d210 func=0x(nil) ‘void ((null))()’>

e$B$H$$$&$U$&$K!Ve(B0xe$B!W$r=E$M$F=PNO$7$F$7$^$$$^$9!#e(B
e$B0J2<$O%Q%C%A$G$9!#e(B

$ svn diff ptr.c sym.c L -S
Index: ptr.c

— ptr.c (revision 12023)
+++ ptr.c (working copy)
@@ -466,7 +466,7 @@
char str[1024];

Data_Get_Struct(self, struct ptr_data, data);

  • snprintf(str, 1023, “#<%s:0x%p ptr=0x%p size=%ld free=0x%p>”,
  • snprintf(str, 1023, “#<%s:0x%x ptr=0x%x size=%ld free=0x%x>”,
    rb_class2name(CLASS_OF(self)), data, data->ptr, data->size,
    data->free);
    return rb_str_new2(str);
    }
    Index: sym.c
    ===================================================================
    — sym.c (revision 12023)
    +++ sym.c (working copy)
    @@ -268,7 +268,7 @@
    str_size = RSTRING(proto)->len + 100;
    str = dlmalloc(str_size);
    snprintf(str, str_size - 1,
  •      "#<DL::Symbol:0x%p func=0x%p '%s'>",
    
  •      "#<DL::Symbol:0x%x func=0x%x '%s'>",
         sym, sym->func, RSTRING(proto)->ptr);
    
    val = rb_tainted_str_new2(str);
    dlfree(str);

At Mon, 12 Mar 2007 00:21:57 +0900,
sheepman wrote:

DL::PtrData と DL::Symbol の inspect が

$ ruby-1.8.5 -rdl -e ‘p DL::Symbol.new(0, “a”, “I”)’
#<DL::Symbol:0x0x811d210 func=0x(nil) ‘void ((null))()’>

というふうに「0x」を重ねて出力してしまいます。
以下はパッチです。

 ポインタを 0x%x で表示されてもうれしくない環境はそこそこありそう
ですが、ほかの箇所でも %p でなく 0x%x になっているので、取り込む
ことにしました。ありがとうございます。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

e$BKNIt$G$9!#e(B

Akinori MUSHA wrote:

e$B!!%]%$%s%?$re(B 0x%x e$B$GI=<($5$l$F$b$&$l$7$/$J$$4D6-$O$=$3$=$3$"$j$=$&e(B
e$B$G$9$,!"$[$+$N2U=j$G$be(B %p e$B$G$J$/e(B 0x%x e$B$K$J$C$F$$$k$N$G!"<h$j9~$`e(B
e$B$3$H$K$7$^$7$?!#$"$j$,$H$&$4$6$$$^$9!#e(B

e$B<ALd$G$9!#e(B%#xe$B$G$O$J$/e(B0x%xe$B$H$9$k$N$K$O$J$s$+$N0U?^$,$"$k$N$G$9$+e(B?

0x%Xe$B$H$+$J$i$^$@M}2r$G$-$ke(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30541] Re: DL::PtrData#inspect”
on Mon, 12 Mar 2007 16:40:39 +0900, Urabe S.
[email protected] writes:

|e$B<ALd$G$9!#e(B%#xe$B$G$O$J$/e(B0x%xe$B$H$9$k$N$K$O$J$s$+$N0U?^$,$"$k$N$G$9$+e(B?

e$B!Ve(B%#xe$B!W$,$I$3$G$b;H$($k3N?.$,L5$+$C$?$+$i$G$9!#$H$j$"$($:e(B
e$B!Ve(B0x%xe$B!W$J$i$I$3$G$b;H$($=$&$@$C$?$7!#e(B

|# 0x%Xe$B$H$+$J$i$^$@M}2r$G$-$ke(B

e$B$I$&$7$F!)e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30544] Re: DL::PtrData#inspect”
on Mon, 12 Mar 2007 18:15:19 +0900, Urabe S.
[email protected] writes:

|Yukihiro M. wrote:
|> e$B!Ve(B%#xe$B!W$,$I$3$G$b;H$($k3N?.$,L5$+$C$?$+$i$G$9!#$H$j$“$($:e(B
|> e$B!Ve(B0x%xe$B!W$J$i$I$3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