mkiiskila closed pull request #893: libc: Conditionally compile float support in printf URL: https://github.com/apache/mynewt-core/pull/893
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/libc/baselibc/src/tinyprintf.c b/libc/baselibc/src/tinyprintf.c index 1fc262394..9ab3358da 100644 --- a/libc/baselibc/src/tinyprintf.c +++ b/libc/baselibc/src/tinyprintf.c @@ -65,6 +65,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdio.h> #include <inttypes.h> +#include "syscfg/syscfg.h" + struct param { unsigned char width; /**< field width */ char lz; /**< Leading zeros */ @@ -238,8 +240,10 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va) char ch; char lng; void *v; +#if MYNEWT_VAL(FLOAT_USER) double d; int n; +#endif p.bf = bf; @@ -339,11 +343,12 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va) written += putchw(putp, &p); p.bf = bf; break; +#if MYNEWT_VAL(FLOAT_USER) case 'f': p.base = 10; d = va_arg(va, double); /* Cast to an int to get the integer part of the number */ - n = (int)d; + n = d; /* Convert to ascii */ i2a(n, &p); /* Ignore left align for integer part */ @@ -358,7 +363,7 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va) written += putchw(putp, &p); /* Take the decimal part and multiply by 1000 */ n = (d-n)*1000; - /* Convert to asii */ + /* Convert to ascii */ i2a(n, &p); /* Set the leading zeros for the next integer output to 3 */ p.lz = 3; @@ -371,6 +376,7 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va) /* Output the decimal part. */ written += putchw(putp, &p); break; +#endif case '%': written += putf(putp, ch); break; ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services