msvcrt: Don't use additional buffer in pf_integer_conv.
This commit is contained in:
parent
35cc03d54c
commit
0f9f0a1613
|
@ -254,12 +254,9 @@ static inline void FUNC_NAME(pf_integer_conv)(char *buf, int buf_len,
|
||||||
{
|
{
|
||||||
unsigned int base;
|
unsigned int base;
|
||||||
const char *digits;
|
const char *digits;
|
||||||
|
char tmp;
|
||||||
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
char number[40], *tmp = number;
|
|
||||||
|
|
||||||
if(buf_len > sizeof number)
|
|
||||||
tmp = HeapAlloc(GetProcessHeap(), 0, buf_len);
|
|
||||||
|
|
||||||
if(flags->Format == 'o')
|
if(flags->Format == 'o')
|
||||||
base = 8;
|
base = 8;
|
||||||
|
@ -280,35 +277,36 @@ static inline void FUNC_NAME(pf_integer_conv)(char *buf, int buf_len,
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if(x==0 && flags->Precision)
|
if(x==0 && flags->Precision)
|
||||||
tmp[i++] = '0';
|
buf[i++] = '0';
|
||||||
else {
|
else {
|
||||||
while(x != 0) {
|
while(x != 0) {
|
||||||
j = (ULONGLONG)x%base;
|
j = (ULONGLONG)x%base;
|
||||||
x = (ULONGLONG)x/base;
|
x = (ULONGLONG)x/base;
|
||||||
tmp[i++] = digits[j];
|
buf[i++] = digits[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k = flags->Precision-i;
|
k = flags->Precision-i;
|
||||||
while(k-- > 0)
|
while(k-- > 0)
|
||||||
tmp[i++] = '0';
|
buf[i++] = '0';
|
||||||
if(flags->Alternate) {
|
if(flags->Alternate) {
|
||||||
if(base == 16) {
|
if(base == 16) {
|
||||||
tmp[i++] = digits[16];
|
buf[i++] = digits[16];
|
||||||
tmp[i++] = '0';
|
buf[i++] = '0';
|
||||||
} else if(base==8 && tmp[i-1]!='0')
|
} else if(base==8 && buf[i-1]!='0')
|
||||||
tmp[i++] = '0';
|
buf[i++] = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf[i] = '\0';
|
||||||
j = 0;
|
j = 0;
|
||||||
while(i-- > 0)
|
while(i-- > j) {
|
||||||
buf[j++] = tmp[i];
|
tmp = buf[j];
|
||||||
buf[j] = '\0';
|
buf[j] = buf[i];
|
||||||
|
buf[i] = tmp;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
/* Adjust precision so pf_fill won't truncate the number later */
|
/* Adjust precision so pf_fill won't truncate the number later */
|
||||||
flags->Precision = strlen(buf);
|
flags->Precision = strlen(buf);
|
||||||
|
|
||||||
if(tmp != number)
|
|
||||||
HeapFree(GetProcessHeap(), 0, tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void FUNC_NAME(pf_fixup_exponent)(char *buf)
|
static inline void FUNC_NAME(pf_fixup_exponent)(char *buf)
|
||||||
|
|
Loading…
Reference in New Issue