X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fmware%2Fformatwr.c;h=0f3c00d18ee5f2dd354fef5d5ce43b22d2c0d7dd;hb=e8b0472be10fba4ca6baa62d8d483db90e28c06e;hp=afc4976e269af94db0ec05c25d731364fa8e0101;hpb=34b2a78c7c59a3357d05dfff157908d5d9b98501;p=bertos.git diff --git a/bertos/mware/formatwr.c b/bertos/mware/formatwr.c index afc4976e..0f3c00d1 100644 --- a/bertos/mware/formatwr.c +++ b/bertos/mware/formatwr.c @@ -30,7 +30,6 @@ * * --> * - * \version $Id$ * * \brief Basic "printf", "sprintf" and "fprintf" formatter. * @@ -106,14 +105,14 @@ /* Maximum precision for floating point values */ typedef long double max_float_t; - #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) + * Use a high value to avoid unexpected buffer overflows. */ - #define FRMWRI_BUFSIZE 50 + #define FRMWRI_BUFSIZE 134 #endif #else #if CONFIG_FRMWRI_BUFSIZE @@ -505,14 +504,21 @@ NEXT_FLAG: { case 'l': case 'L': + #if SIZEOF_SIZE_T == SIZEOF_LONG case 'z': flags.l_L_modifier = true; + #elif SIZEOF_SIZE_T == SIZEOF_INT + flags.l_L_modifier = true; + case 'z': + #endif format++; break; + case 'h': flags.h_modifier = true; format++; break; + } /* @@ -598,7 +604,7 @@ NEXT_FLAG: case 'p': case 'X': if (format_flag == 'p') -#if defined(__AVR__) || defined(__I196__) /* 16bit pointers */ +#if defined(__AVR__) || defined(__I196__) || defined(__MSP430__) /* 16bit pointers */ ulong = (unsigned long)(unsigned short)va_arg(ap, char *); #else /* 32bit pointers */ ulong = (unsigned long)va_arg(ap, char *); @@ -853,10 +859,13 @@ FLOATING_CONVERSION: switch (PGM_READ_CHAR(format)) { case 'l': + #if SIZEOF_SIZE_T == SIZEOF_LONG case 'z': - /* for the 'z' modifier, we make this assumption */ - STATIC_ASSERT(sizeof(size_t) == sizeof(long)); l_modifier = true; + #elif SIZEOF_SIZE_T == SIZEOF_INT + l_modifier = true; + case 'z': + #endif format++; break;