From 70105b0ad37ae24cf92719362e3ad51fdaf79380 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@cloudius-systems.com> Date: Mon, 21 Jan 2013 11:45:17 +0100 Subject: [PATCH] disable floating point support in *printf and *scanf This would require pulling in libm, for which we aren't ready yet. --- libc/build.mak | 2 +- libc/stdio/vfprintf.c | 4 ++++ libc/stdio/vfscanf.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libc/build.mak b/libc/build.mak index 325f08091..9277a1a87 100644 --- a/libc/build.mak +++ b/libc/build.mak @@ -1,6 +1,6 @@ libc := -libc += internal/floatscan.o +#libc += internal/floatscan.o libc += internal/intscan.o libc += internal/libc.o libc += internal/__lock.o diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c index 6a19c31db..31db27f65 100644 --- a/libc/stdio/vfprintf.c +++ b/libc/stdio/vfprintf.c @@ -200,6 +200,7 @@ static char *fmt_u(uintmax_t x, char *s) return s; } +#ifdef HAVE_FLOAT_SUPPORT static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) { uint32_t big[(LDBL_MAX_EXP+LDBL_MANT_DIG)/9+1]; @@ -430,6 +431,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) return MAX(w, pl+l); } +#endif /* HAVE_FLOAT_SUPPORT */ static int getint(char **s) { int i; @@ -618,10 +620,12 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, pad(f, ' ', w, p, fl^LEFT_ADJ); l = w>p ? w : p; continue; +#ifdef HAVE_FLOAT_SUPPORT case 'e': case 'f': case 'g': case 'a': case 'E': case 'F': case 'G': case 'A': l = fmt_fp(f, arg.f, w, p, fl, t); continue; +#endif } if (p < z-a) p = z-a; diff --git a/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c index 86f92f9f2..62f3dcbee 100644 --- a/libc/stdio/vfscanf.c +++ b/libc/stdio/vfscanf.c @@ -85,7 +85,9 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) int invert; int matches=0; unsigned long long x; +#ifdef HAVE_FLOAT_SUPPORT long double y; +#endif off_t pos = 0; FLOCK(f); @@ -284,6 +286,7 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) if (t=='p' && dest) *(void **)dest = (void *)(uintptr_t)x; else store_int(dest, size, x); break; +#ifdef HAVE_FLOAT_SUPPORT case 'a': case 'A': case 'e': case 'E': case 'f': case 'F': @@ -302,6 +305,7 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) break; } break; +#endif case 'S': wcs = dest; st = (mbstate_t){ 0 }; -- GitLab