Commit 5f2b9d59 authored by Carlo Bramini's avatar Carlo Bramini Committed by Alexandre Julliard

msvcrt: Use return value of *printf() instead of calling strlen() and simplify code.

parent 2fe91725
......@@ -1580,7 +1580,7 @@ char * CDECL MSVCRT__fcvt( double number, int ndigits, int *decpt, int *sign )
number = -number;
} else *sign = 0;
snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
stop = snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
ptr1 = buf;
ptr2 = data->efcvt_buffer;
first = NULL;
......@@ -1597,9 +1597,7 @@ char * CDECL MSVCRT__fcvt( double number, int ndigits, int *decpt, int *sign )
/* If requested digits is zero or less, we will need to truncate
* the returned string */
if (ndigits < 1) {
stop = strlen(buf) + ndigits;
} else {
stop = strlen(buf);
stop += ndigits;
}
while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
......@@ -1665,7 +1663,7 @@ int CDECL MSVCRT__fcvt_s(char* outbuffer, MSVCRT_size_t size, double number, int
number = -number;
} else *sign = 0;
snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
stop = snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
ptr1 = buf;
ptr2 = outbuffer;
first = NULL;
......@@ -1682,9 +1680,7 @@ int CDECL MSVCRT__fcvt_s(char* outbuffer, MSVCRT_size_t size, double number, int
/* If requested digits is zero or less, we will need to truncate
* the returned string */
if (ndigits < 1) {
stop = strlen(buf) + ndigits;
} else {
stop = strlen(buf);
stop += ndigits;
}
while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
......
......@@ -242,8 +242,7 @@ static inline void FUNC_NAME(pf_rebuild_format_string)(char *p, FUNC_NAME(pf_fla
if(flags->Alternate)
*p++ = flags->Alternate;
if(flags->Precision >= 0) {
sprintf(p, ".%d", flags->Precision);
p += strlen(p);
p += sprintf(p, ".%d", flags->Precision);
}
*p++ = flags->Format;
*p++ = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment