diff options
author | das <das@FreeBSD.org> | 2004-05-02 10:55:06 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2004-05-02 10:55:06 +0000 |
commit | 94b1a9eeafc91dad3468622023ee59123c1e0ccb (patch) | |
tree | 10ba84744b0f6df24d98a0ed187eb15a7e1fab0b /lib/libc | |
parent | 3640d9db93a1482436b84fbf47446b6e4d4b260d (diff) | |
download | FreeBSD-src-94b1a9eeafc91dad3468622023ee59123c1e0ccb.zip FreeBSD-src-94b1a9eeafc91dad3468622023ee59123c1e0ccb.tar.gz |
- To make it easier to compile *printf() and *scanf() without
floating-point support, remove default definition of FLOATING_POINT
from the source, and change the compile-time option to
NO_FLOATING_POINT.
- Remove the HEXFLOAT option. It saves an insignificant amount of
space (<0.1% of the size of libc on i386) and complicates vfprintf()
and checkfmt().
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 40 | ||||
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 12 |
2 files changed, 21 insertions, 31 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index cd147b8..0d78df9 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -66,10 +66,6 @@ __FBSDID("$FreeBSD$"); #include "local.h" #include "fvwrite.h" -/* Define FLOATING_POINT to get floating point, HEXFLOAT to get %a. */ -#define FLOATING_POINT -#define HEXFLOAT - union arg { int intarg; u_int uintarg; @@ -91,7 +87,7 @@ union arg { ptrdiff_t *pptrdiffarg; size_t *psizearg; intmax_t *pintmaxarg; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT double doublearg; long double longdoublearg; #endif @@ -411,7 +407,7 @@ vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap) return (ret); } -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT #define dtoa __dtoa #define freedtoa __freedtoa @@ -425,7 +421,7 @@ vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap) static int exponent(char *, int, int); -#endif /* FLOATING_POINT */ +#endif /* !NO_FLOATING_POINT */ /* * The size of the buffer we use as scratch space for integer @@ -474,7 +470,7 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap) char sign; /* sign prefix (' ', '+', '-', or \0) */ char thousands_sep; /* locale specific thousands separator */ const char *grouping; /* locale specific numeric grouping rules */ -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT /* * We can decompose the printed representation of floating * point numbers into several parts, some of which may be empty: @@ -641,7 +637,7 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap) thousands_sep = '\0'; grouping = NULL; convbuf = NULL; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT dtoaresult = NULL; decimal_point = localeconv()->decimal_point; #endif @@ -762,7 +758,7 @@ reswitch: switch (ch) { } width = n; goto reswitch; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT case 'L': flags |= LONGDBL; goto rflag; @@ -836,8 +832,7 @@ reswitch: switch (ch) { } base = 10; goto number; -#ifdef FLOATING_POINT -#ifdef HEXFLOAT +#ifndef NO_FLOATING_POINT case 'a': case 'A': if (ch == 'a') { @@ -869,7 +864,6 @@ reswitch: switch (ch) { if (expt == INT_MAX) ox[1] = '\0'; goto fp_common; -#endif /* HEXFLOAT */ case 'e': case 'E': expchar = ch; @@ -971,7 +965,7 @@ fp_common: lead = expt; } break; -#endif /* FLOATING_POINT */ +#endif /* !NO_FLOATING_POINT */ case 'n': /* * Assignment-like behavior is specified if the @@ -1176,7 +1170,7 @@ number: if ((dprec = prec) >= 0) PAD(dprec - size, zeroes); /* the string or number proper */ -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT if ((flags & FPT) == 0) { PRINT(cp, size); } else { /* glue together f_p fragments */ @@ -1239,7 +1233,7 @@ number: if ((dprec = prec) >= 0) done: FLUSH(); error: -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT if (dtoaresult != NULL) freedtoa(dtoaresult); #endif @@ -1373,7 +1367,7 @@ reswitch: switch (ch) { } width = n; goto reswitch; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT case 'L': flags |= LONGDBL; goto rflag; @@ -1420,11 +1414,9 @@ reswitch: switch (ch) { case 'i': ADDSARG(); break; -#ifdef FLOATING_POINT -#ifdef HEXFLOAT +#ifndef NO_FLOATING_POINT case 'a': case 'A': -#endif case 'e': case 'E': case 'f': @@ -1435,7 +1427,7 @@ reswitch: switch (ch) { else ADDTYPE(T_DOUBLE); break; -#endif /* FLOATING_POINT */ +#endif /* !NO_FLOATING_POINT */ case 'n': if (flags & INTMAXT) ADDTYPE(TP_INTMAXT); @@ -1555,7 +1547,7 @@ done: case TP_INTMAXT: (*argtable) [n].pintmaxarg = va_arg (ap, intmax_t *); break; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT case T_DOUBLE: (*argtable) [n].doublearg = va_arg (ap, double); break; @@ -1612,7 +1604,7 @@ __grow_type_table (int nextarg, enum typeid **typetable, int *tablesize) } -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT static int exponent(char *p0, int exp, int fmtch) @@ -1649,4 +1641,4 @@ exponent(char *p0, int exp, int fmtch) } return (p - p0); } -#endif /* FLOATING_POINT */ +#endif /* !NO_FLOATING_POINT */ diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 6a05343..118323f 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -56,9 +56,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" #include "local.h" -#define FLOATING_POINT - -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT #include <locale.h> #endif @@ -254,7 +252,7 @@ literal: base = 16; break; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT case 'A': case 'E': case 'F': case 'G': case 'a': case 'e': case 'f': case 'g': c = CT_FLOAT; @@ -768,7 +766,7 @@ literal: nconversions++; break; -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT case CT_FLOAT: /* scan a floating point number as if by strtod */ if (width == 0 || width > sizeof(buf) - 1) @@ -793,7 +791,7 @@ literal: nread += width; nconversions++; break; -#endif /* FLOATING_POINT */ +#endif /* !NO_FLOATING_POINT */ } } input_failure: @@ -915,7 +913,7 @@ doswitch: /* NOTREACHED */ } -#ifdef FLOATING_POINT +#ifndef NO_FLOATING_POINT static int parsefloat(FILE *fp, char *buf, char *end) { |