mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
couldn't free the returned pointer from ruby_dtoa(). * missing/vsnprintf.c (cvt): receive buffer and use/return it instead of returning the pointer returned from BSD__dtoa(). * missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer. [ruby-core:22184] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
09396dcf21
commit
8563b285fb
3 changed files with 21 additions and 17 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Fri Feb 20 23:28:11 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
|
||||
couldn't free the returned pointer from ruby_dtoa().
|
||||
|
||||
* missing/vsnprintf.c (cvt): receive buffer and use/return it instead
|
||||
of returning the pointer returned from BSD__dtoa().
|
||||
|
||||
* missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer.
|
||||
[ruby-core:22184]
|
||||
|
||||
Thu Feb 19 22:59:09 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/ancdata.c (make_io_for_unix_rights): cmsg_len may be
|
||||
|
|
|
@ -494,7 +494,7 @@ BSD__ultoa(register u_long val, char *endp, int base, int octzero, const char *x
|
|||
#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
|
||||
#define DEFPREC 6
|
||||
|
||||
static char *cvt __P((double, int, int, char *, int *, int, int *));
|
||||
static char *cvt __P((double, int, int, char *, int *, int, int *, char *));
|
||||
static int exponent __P((char *, int, int));
|
||||
|
||||
#else /* no FLOATING_POINT */
|
||||
|
@ -783,7 +783,7 @@ fp_begin: _double = va_arg(ap, double);
|
|||
}
|
||||
flags |= FPT;
|
||||
cp = cvt(_double, prec, flags, &softsign,
|
||||
&expt, ch, &ndig);
|
||||
&expt, ch, &ndig, buf);
|
||||
if (ch == 'g' || ch == 'G') {
|
||||
if (expt <= -4 || (expt > prec && expt > 1))
|
||||
ch = (ch == 'g') ? 'e' : 'E';
|
||||
|
@ -1076,10 +1076,10 @@ error:
|
|||
extern char *BSD__dtoa __P((double, int, int, int *, int *, char **));
|
||||
|
||||
static char *
|
||||
cvt(value, ndigits, flags, sign, decpt, ch, length)
|
||||
cvt(value, ndigits, flags, sign, decpt, ch, length, buf)
|
||||
double value;
|
||||
int ndigits, flags, *decpt, ch, *length;
|
||||
char *sign;
|
||||
char *sign, *buf;
|
||||
{
|
||||
int mode, dsgn;
|
||||
char *digits, *bp, *rve;
|
||||
|
@ -1098,6 +1098,10 @@ cvt(value, ndigits, flags, sign, decpt, ch, length)
|
|||
*sign = '\000';
|
||||
}
|
||||
digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
|
||||
memcpy(buf, digits, rve - digits);
|
||||
xfree(digits);
|
||||
rve = buf + (rve - digits);
|
||||
digits = buf;
|
||||
if (flags & ALT) { /* Print trailing zeros */
|
||||
bp = digits + ndigits;
|
||||
if (ch == 'f') {
|
||||
|
|
15
util.c
15
util.c
|
@ -3058,20 +3058,11 @@ static char *dtoa_result;
|
|||
static char *
|
||||
rv_alloc(int i)
|
||||
{
|
||||
int j, k, *r;
|
||||
|
||||
j = sizeof(ULong);
|
||||
for (k = 0;
|
||||
sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
|
||||
j <<= 1)
|
||||
k++;
|
||||
r = (int*)Balloc(k);
|
||||
*r = k;
|
||||
return
|
||||
#ifndef MULTIPLE_THREADS
|
||||
dtoa_result =
|
||||
#endif
|
||||
(char *)(r+1);
|
||||
xmalloc(i);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -3096,9 +3087,7 @@ nrv_alloc(const char *s, char **rve, int n)
|
|||
static void
|
||||
freedtoa(char *s)
|
||||
{
|
||||
Bigint *b = (Bigint *)((int *)s - 1);
|
||||
b->maxwds = 1 << (b->k = *(int*)b);
|
||||
Bfree(b);
|
||||
xfree(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue