X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fmware%2Fformatwr.c;h=996f8df04c5e7562d100f5760a86765cb8c15eb5;hb=47dfe44ebab1698c1dee6757b6ce0f19b5e030a3;hp=bf2672e9c1a29b5642671cdb682a68c83312fc6e;hpb=d977e866d070ab7b3196777b57e7a5ff2e02bdd6;p=bertos.git diff --git a/bertos/mware/formatwr.c b/bertos/mware/formatwr.c index bf2672e9..996f8df0 100644 --- a/bertos/mware/formatwr.c +++ b/bertos/mware/formatwr.c @@ -106,16 +106,25 @@ /* Maximum precision for floating point values */ typedef long double max_float_t; - /*luca: FIXME: this should be enough to print floating point values, must be investigated - * further. - */ - #define FRMWRI_BUFSIZE 20 + #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) + * Use a high value to avoid unexpected buffer overflows. + */ + #define FRMWRI_BUFSIZE 134 + #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. */