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$G$7$g$&$+!#e(B
e$B<+J,$K$O$A$g$C$HJ,$+$j$^$;$s$G$7$?!#e(B

e$B$H$j$"$($:e(B

  • freedtoa()e$B$re(B statice$B$Ke(B
  • dtoa()e$B$re(B ruby_dtoa()e$B$Ke(B
    e$B$9$k%Q%C%A$,0J2<$G$9!#8!F$$$$?$@$1$k$H$"$j$,$?$/;W$$$^$9!#e(B

Index: sprintf.c

— sprintf.c (revision 19921)
+++ sprintf.c (working copy)
@@ -1083,7 +1083,7 @@
#undef vsnprintf
#undef snprintf
#define FLOATING_POINT 1
-#define BSD__dtoa dtoa
+#define BSD__dtoa ruby_dtoa
#include “missing/vsnprintf.c”

static int
Index: util.c

— util.c (revision 19921)
+++ util.c (working copy)
@@ -3092,7 +3092,7 @@

  • when MULTIPLE_THREADS is not defined.
    */

-void
+static void
freedtoa(char *s)
{
Bigint *b = (Bigint *)((int *)s - 1);
@@ -3139,7 +3139,7 @@
*/

char *
-dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char
**rve)
+ruby_dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char
*rve)
{
/
Arguments ndigits, decpt, sign are similar to those
of ecvt and fcvt; trailing zeros are suppressed from


#2

e$B$J$+$@$G$9!#e(B

At Sat, 25 Oct 2008 02:31:20 +0900,
Tadashi S. wrote in [ruby-dev:36913]:

dtoa()e$B$,;H$o$l$k$N$O$I$&$be(Bmissing/vsnprintf.ce$B$NCf!"$D$^$je(Bvsnprintf()
(e$B$He(Bsnprintf()) e$B$,;H$($J$$4D6-$N$$N$h$&$G$9!#e(B
e$B$7$+$7e(Bvsnprintf()e$B$,B8:
$9$k$h$&$J<+J,$N4D6-$G$b!";H$o$l$J$$e(Bdtoa()e$B$,Dj5A$5$l$Fe(B
e$B$$$^$9!#$3$l$OK\Mh!"I,MW$J$$;v$G$O$J$$$G$7$g$&$+!#e(B

e$B;W$&$K!“e(Bsprintf.ce$B$Ge(BHAVE_*e$B$r%A%’%C%/$;$:$Ke(B
#include “missing/vsnprintf.c”
e$B$7$F$$$k$N$,LdBj$@$H;W$&$N$G$9$,!”$3$l$K$O$I$s$JM}M3$,$"$k$N$G$7$g$&$+!#e(B
e$B<+J,$K$O$A$g$C$HJ,$+$j$^$;$s$G$7$?!#e(B

e$B%7%9%F%I8=$Ne(Bvsnprintf()e$B$Oe(Blocalee$B$K0MB8$7$F$$$k>l9g$,$"$j$^$9!#e(B
1.9e$B$G$O$=$l$rHr$1$k$?$a$K>o$Ke(Bmissing/vsnprintf.ce$B$r;H$$$^$9!#e(B

e$B$H$j$"$($:e(B

  • freedtoa()e$B$re(B statice$B$Ke(B
  • dtoa()e$B$re(B ruby_dtoa()e$B$Ke(B
    e$B$9$k%Q%C%A$,0J2<$G$9!#8!F$$$$?$@$1$k$H$"$j$,$?$/;W$$$^$9!#e(B

[ruby-dev:36915]e$B!"e(B[ruby-dev:36916]e$B$H$H$b$K%3%_%C%H$7$^$7$?!#e(B


#3

e$B:XF#$G$9!#e(B

On Sat, 25 Oct 2008 04:02:52 +0900
Nobuyoshi N. removed_email_address@domain.invalid wrote:

e$B%7%9%F%I8=$Ne(Bvsnprintf()e$B$Oe(Blocalee$B$K0MB8$7$F$$$k>l9g$,$"$j$^$9!#e(B
1.9e$B$G$O$=$l$rHr$1$k$?$a$K>o$Ke(Bmissing/vsnprintf.ce$B$r;H$$$^$9!#e(B

e$B$"$l!"<j85$N4D6-e(B(Debian
lenny)e$B$G$O!"%7%9%F%`$Ne(Bvsnprintf()e$B$r;H$C$F$$$^$9$h!#e(B

$ nm libruby-trunk.so|grep vsnprintf
U vsnprintf@@GLIBC_2.0

e$B$H$J$j$^$9$7!"e(Bmissing/vsnprintf.ce$B$N%3!<%I$be(B

#ifndef HAVE_VSNPRINTF
int
vsnprintf(str, n, fmt, ap)
:

e$B$H$"$j$^$9!#$3$l$G$O!"e(Blocalee$B0MB8@-$K4X$o$i$:%7%9%F%`$NJ}$r;H$&$h$&$K8+$($k$Ne(B
e$B$G$9$,!"30$7$F$$$?$i$9$_$^$;$s!#e(B

e$B$H$j$"$($:e(B

  • freedtoa()e$B$re(B statice$B$Ke(B
  • dtoa()e$B$re(B ruby_dtoa()e$B$Ke(B
    e$B$9$k%Q%C%A$,0J2<$G$9!#8!F$$$$?$@$1$k$H$"$j$,$?$/;W$$$^$9!#e(B

[ruby-dev:36915]e$B!"e(B[ruby-dev:36916]e$B$H$H$b$K%3%_%C%H$7$^$7$?!#e(B

e$B$3$A$i$O!"$"$j$,$H$&$4$6$$$^$7$?!#e(B