- 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().
This commit is contained in:
David Schultz 2004-05-02 10:55:06 +00:00
parent 38d17374b2
commit 8de9e89719
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128819
2 changed files with 21 additions and 31 deletions

View File

@ -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 @@ reswitch: switch (ch) {
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 @@ reswitch: switch (ch) {
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 */

View File

@ -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 @@ again: c = *fmt++;
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 @@ again: c = *fmt++;
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 @@ again: c = *fmt++;
nread += width;
nconversions++;
break;
#endif /* FLOATING_POINT */
#endif /* !NO_FLOATING_POINT */
}
}
input_failure:
@ -915,7 +913,7 @@ __sccl(tab, fmt)
/* NOTREACHED */
}
#ifdef FLOATING_POINT
#ifndef NO_FLOATING_POINT
static int
parsefloat(FILE *fp, char *buf, char *end)
{