libs/libc/stdio/lib_libvsprintf.c: No precision specifier resulted in precision 0 but should be precision 6.

This commit is contained in:
Johannes
2019-02-15 08:42:07 -06:00
committed by Gregory Nutt
parent 8ca1225001
commit 7b9d02d496
2 changed files with 12 additions and 9 deletions
+11
View File
@@ -118,6 +118,10 @@
# define FMT_PREV src-- /* Backup to the previous character */
#endif
/* Default precision to use with %f format if no precision is specified. */
#define FLOAT_PRECISION_DEFAULT 6
/****************************************************************************
* Private Type Declarations
****************************************************************************/
@@ -1555,6 +1559,13 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const IPTR char *src,
double dblval = va_arg(ap, double);
int dblsize;
/* Set to default precision if none specified */
if (!IS_HASDOT(flags) && trunc == 0)
{
trunc = FLOAT_PRECISION_DEFAULT;
}
/* Get the width of the output */
dblsize = getdblsize(FMT_CHAR, trunc, flags, dblval);