From cad9ed8e13b1b5e7448f41a71837d0e52ca0ad42 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 13 Jan 2012 02:49:10 +0000 Subject: STM32 fixes for F4 32-bit timers git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4300 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/lib/stdio/lib_libvsprintf.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'nuttx/lib') diff --git a/nuttx/lib/stdio/lib_libvsprintf.c b/nuttx/lib/stdio/lib_libvsprintf.c index 3bc112e92..341c055c6 100644 --- a/nuttx/lib/stdio/lib_libvsprintf.c +++ b/nuttx/lib/stdio/lib_libvsprintf.c @@ -529,6 +529,21 @@ static int getusize(uint8_t fmt, uint8_t flags, unsigned int n) utoascii(&nulloutstream, fmt, flags, n); return nulloutstream.nput; } + +/**************************************************************************** + * Name: getdblsize + ****************************************************************************/ + +#ifdef CONFIG_LIBC_FLOATINGPOINT +static int getdblsize(uint8_t fmt, int trunc, uint8_t flags, double n) +{ + struct lib_outstream_s nulloutstream; + lib_nulloutstream(&nulloutstream); + + lib_dtoa(&nulloutstream, fmt, trunc, flags, n); + return nulloutstream.nput; +} +#endif #endif /* CONFIG_NOPRINTF_FIELDWIDTH */ #ifdef CONFIG_LONG_IS_NOT_INT @@ -1535,9 +1550,30 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a else if (strchr("eEfgG", FMT_CHAR)) { double dblval = va_arg(ap, double); + +#ifndef CONFIG_NOPRINTF_FIELDWIDTH + int dblsize; + + /* Get the width of the output */ + + dblsize = getdblsize(FMT_CHAR, trunc, flags, dblval); + + /* Perform left field justification actions */ + + prejustify(obj, fmt, flags, width, dblsize); +#endif + + /* Output the number */ + lib_dtoa(obj, FMT_CHAR, trunc, flags, dblval); + +#ifndef CONFIG_NOPRINTF_FIELDWIDTH + /* Perform right field justification actions */ + + postjustify(obj, fmt, flags, width, dblsize); } #endif +#endif /* CONFIG_LIBC_FLOATINGPOINT */ } return obj->nput; -- cgit v1.2.3