Bug #8864 » vsnprintf.patch
vsnprintf.c → vsnprintf.c.new | ||
---|---|---|
{
|
||
int mode, dsgn;
|
||
char *digits, *bp, *rve;
|
||
static char *buffer = NULL;
|
||
if (ch == 'f')
|
||
mode = 3;
|
||
... | ... | |
else {
|
||
digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
|
||
}
|
||
buf[0] = 0; /* rve - digits may be 0 */
|
||
memcpy(buf, digits, rve - digits);
|
||
buffer = xrealloc(buffer,rve - digits + 1);
|
||
buffer[0] = 0; /* rve - digits may be 0 */
|
||
memcpy(buffer, digits, rve - digits);
|
||
rve = buffer + (rve - digits);
|
||
xfree(digits);
|
||
rve = buf + (rve - digits);
|
||
digits = buf;
|
||
digits = buffer;
|
||
if (flags & ALT) { /* Print trailing zeros */
|
||
bp = digits + ndigits;
|
||
if (ch == 'f') {
|
||
... | ... | |
*decpt = -ndigits + 1;
|
||
bp += *decpt;
|
||
}
|
||
if(rve < bp) {
|
||
buffer = xrealloc(buffer,bp - buffer + 1);
|
||
rve = buffer + (rve - digits);
|
||
bp = buffer + (bp - digits);
|
||
digits = buffer;
|
||
}
|
||
while (rve < bp)
|
||
*rve++ = '0';
|
||
}
|