Use configuration value for formatter bufsize.
[bertos.git] / bertos / mware / formatwr.c
index 133a1932852fea9213275ae4003a062cadc31a81..afc4976e269af94db0ec05c25d731364fa8e0101 100644 (file)
@@ -46,7 +46,7 @@
  *  -D CONFIG_PRINTF=PRINTF_FULL         Full ANSI printf formatter, with some C99 extensions
  *  -D CONFIG_PRINTF=PRINTF_NOFLOAT      Exclude support for floats
  *  -D CONFIG_PRINTF=PRINTF_REDUCED      Simplified formatter (see below)
- *  -D CONFIG_PRINTF=PRINTF_NOMODIFIERS  Exclude 'l', 'z' and 'h' modifiers in reduced version
+ *  -D CONFIG_PRINTF=PRINTF_NOMODIFIERS  Exclude "l", "z" and "h" modifiers in reduced version
  *  -D CONFIG_PRINTF=PRINTF_DISABLED     No formatter at all
  * \endcode
  *
        /* Maximum precision for floating point values */
        typedef long double max_float_t;
 
-       /*bernie: save some memory, who cares about floats with lots of decimals? */
-       #define FRMWRI_BUFSIZE 134
-       #if !(ARCH & ARCH_NIGHTTEST)
-               #warning 134 is too much, the code must be fixed to have a lower precision limit
+       #warning FIXME: be sure to fix buffer size below
+       #if CONFIG_FRMWRI_BUFSIZE
+               #define FRMWRI_BUFSIZE CONFIG_FRMWRI_BUFSIZE
+       #else
+               /* Conservative estimate. Max float is 3.40282e+038, so %f (but not %e or %g) must have
+                * space for: sign + all 38 digits + '.' + 6 decimal digits (default)
+                */
+               #define FRMWRI_BUFSIZE 50
        #endif
 #else
-       /*
-        * Conservative estimate. Should be (probably) 12 (which is the size necessary
-        * to represent (2^32-1) in octal plus the sign bit.
-        */
-       #define FRMWRI_BUFSIZE 16
+       #if CONFIG_FRMWRI_BUFSIZE
+               #define FRMWRI_BUFSIZE CONFIG_FRMWRI_BUFSIZE
+       #else
+               /*
+                * Conservative estimate. Should be (probably) 12 (which is the size necessary
+                * to represent (2^32-1) in octal plus the sign bit.
+                */
+               #define FRMWRI_BUFSIZE 16
+       #endif
 #endif
 
 /* Probably useful for fancy microcontrollers such as the PIC, nobody knows. */