Remove some always-on #ifdefery.
Bug: N/A
Test: ran tests
Change-Id: I02d3c0a639f48ae9c415fb59f37ade015e6f46a2
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index c728eec..5dc2029 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -233,9 +233,6 @@
#define FLOCKFILE(fp) if (!_EXT(fp)->_caller_handles_locking) flockfile(fp)
#define FUNLOCKFILE(fp) if (!_EXT(fp)->_caller_handles_locking) funlockfile(fp)
-#define FLOATING_POINT
-#define PRINTF_WIDE_CHAR
-#define SCANF_WIDE_CHAR
#define NO_PRINTF_PERCENT_N
/* OpenBSD exposes these in <stdio.h>, but we only want them exposed to the implementation. */
diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c
index 3d7d41e..da74735 100644
--- a/libc/stdio/vfprintf.c
+++ b/libc/stdio/vfprintf.c
@@ -77,14 +77,10 @@
ptrdiff_t *pptrdiffarg;
ssize_t *pssizearg;
intmax_t *pintmaxarg;
-#ifdef FLOATING_POINT
double doublearg;
long double longdoublearg;
-#endif
-#ifdef PRINTF_WIDE_CHAR
wint_t wintarg;
wchar_t *pwchararg;
-#endif
};
static int __find_arguments(const char *fmt0, va_list ap, union arg **argtable,
@@ -144,7 +140,6 @@
return (ret);
}
-#ifdef PRINTF_WIDE_CHAR
/*
* Convert a wide character string argument for the %ls format to a multibyte
* string representation. If not -1, prec specifies the maximum number of
@@ -204,9 +199,7 @@
convbuf[nbytes] = '\0';
return (convbuf);
}
-#endif
-#ifdef FLOATING_POINT
#include <float.h>
#include <locale.h>
#include <math.h>
@@ -216,7 +209,6 @@
#define DEFPREC 6
static int exponent(char *, int, int);
-#endif /* FLOATING_POINT */
/*
* The size of the buffer we use as scratch space for integer
@@ -280,7 +272,6 @@
char sign; /* sign prefix (' ', '+', '-', or \0) */
wchar_t wc;
mbstate_t ps;
-#ifdef FLOATING_POINT
/*
* We can decompose the printed representation of floating
* point numbers into several parts, some of which may be empty:
@@ -309,7 +300,6 @@
int ndig; /* actual number of digits returned by dtoa */
char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */
char *dtoaresult = NULL;
-#endif
uintmax_t _umax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */
@@ -327,9 +317,7 @@
size_t argtablesiz;
int nextarg; /* 1-based argument index */
va_list orgap; /* original argument pointer */
-#ifdef PRINTF_WIDE_CHAR
char *convbuf; /* buffer for wide to multi-byte conversion */
-#endif
/*
* Choose PADSIZE to trade efficiency vs. size. If larger printf
@@ -476,9 +464,7 @@
uio.uio_resid = 0;
uio.uio_iovcnt = 0;
ret = 0;
-#ifdef PRINTF_WIDE_CHAR
convbuf = NULL;
-#endif
memset(&ps, 0, sizeof(ps));
/*
@@ -606,11 +592,9 @@
}
width = n;
goto reswitch;
-#ifdef FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (*fmt == 'h') {
fmt++;
@@ -640,7 +624,6 @@
flags |= SIZEINT;
goto rflag;
case 'c':
-#ifdef PRINTF_WIDE_CHAR
if (flags & LONGINT) {
mbstate_t mbs;
size_t mbseqlen;
@@ -655,12 +638,9 @@
cp = buf;
size = (int)mbseqlen;
} else {
-#endif
*(cp = buf) = GETARG(int);
size = 1;
-#ifdef PRINTF_WIDE_CHAR
}
-#endif
sign = '\0';
break;
case 'D':
@@ -675,7 +655,6 @@
}
base = DEC;
goto number;
-#ifdef FLOATING_POINT
case 'a':
case 'A':
if (ch == 'a') {
@@ -808,7 +787,6 @@
lead = expt;
}
break;
-#endif /* FLOATING_POINT */
#ifndef NO_PRINTF_PERCENT_N
case 'n':
if (flags & LLONGINT)
@@ -850,7 +828,6 @@
ox[1] = 'x';
goto nosign;
case 's':
-#ifdef PRINTF_WIDE_CHAR
if (flags & LONGINT) {
wchar_t *wcp;
@@ -867,7 +844,6 @@
cp = convbuf;
}
} else
-#endif /* PRINTF_WIDE_CHAR */
if ((cp = GETARG(char *)) == NULL)
cp = "(null)";
if (prec >= 0) {
@@ -1017,7 +993,6 @@
PAD(dprec - size, zeroes);
/* the string or number proper */
-#ifdef FLOATING_POINT
if ((flags & FPT) == 0) {
PRINT(cp, size);
} else { /* glue together f_p fragments */
@@ -1051,9 +1026,6 @@
PRINT(expstr, expsize);
}
}
-#else
- PRINT(cp, size);
-#endif
/* left-adjusting padding (always blank) */
if (flags & LADJUST)
PAD(width - realsz, blanks);
@@ -1080,13 +1052,9 @@
ret = -1;
finish:
-#ifdef PRINTF_WIDE_CHAR
free(convbuf);
-#endif
-#ifdef FLOATING_POINT
if (dtoaresult)
__freedtoa(dtoaresult);
-#endif
if (argtable != NULL && argtable != statargtable) {
munmap(argtable, argtablesiz);
argtable = NULL;
@@ -1262,11 +1230,9 @@
goto rflag;
}
goto reswitch;
-#ifdef FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (*fmt == 'h') {
fmt++;
@@ -1296,11 +1262,9 @@
flags |= SIZEINT;
goto rflag;
case 'c':
-#ifdef PRINTF_WIDE_CHAR
if (flags & LONGINT)
ADDTYPE(T_WINT);
else
-#endif
ADDTYPE(T_INT);
break;
case 'D':
@@ -1310,7 +1274,6 @@
case 'i':
ADDSARG();
break;
-#ifdef FLOATING_POINT
case 'a':
case 'A':
case 'e':
@@ -1324,7 +1287,6 @@
else
ADDTYPE(T_DOUBLE);
break;
-#endif /* FLOATING_POINT */
#ifndef NO_PRINTF_PERCENT_N
case 'n':
if (flags & LLONGINT)
@@ -1353,11 +1315,9 @@
ADDTYPE(TP_VOID);
break;
case 's':
-#ifdef PRINTF_WIDE_CHAR
if (flags & LONGINT)
ADDTYPE(TP_WCHAR);
else
-#endif
ADDTYPE(TP_CHAR);
break;
case 'U':
@@ -1427,14 +1387,12 @@
case TP_LLONG:
(*argtable)[n].plonglongarg = va_arg(ap, long long *);
break;
-#ifdef FLOATING_POINT
case T_DOUBLE:
(*argtable)[n].doublearg = va_arg(ap, double);
break;
case T_LONG_DOUBLE:
(*argtable)[n].longdoublearg = va_arg(ap, long double);
break;
-#endif
case TP_CHAR:
(*argtable)[n].pchararg = va_arg(ap, char *);
break;
@@ -1465,14 +1423,12 @@
case TP_MAXINT:
(*argtable)[n].pintmaxarg = va_arg(ap, intmax_t *);
break;
-#ifdef PRINTF_WIDE_CHAR
case T_WINT:
(*argtable)[n].wintarg = va_arg(ap, wint_t);
break;
case TP_WCHAR:
(*argtable)[n].pwchararg = va_arg(ap, wchar_t *);
break;
-#endif
}
}
goto finish;
@@ -1523,7 +1479,6 @@
}
-#ifdef FLOATING_POINT
static int
exponent(char *p0, int exp, int fmtch)
{
@@ -1558,4 +1513,3 @@
}
return (p - p0);
}
-#endif /* FLOATING_POINT */
diff --git a/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c
index e47d0df..792d7ce 100644
--- a/libc/stdio/vfscanf.c
+++ b/libc/stdio/vfscanf.c
@@ -41,9 +41,7 @@
#include <string.h>
#include "local.h"
-#ifdef FLOATING_POINT
#include "floatio.h"
-#endif
#define BUF 513 /* Maximum length of numeric string. */
@@ -110,11 +108,9 @@
int base; /* base argument to strtoimax/strtouimax */
char ccltab[256]; /* character class table for %[...] */
char buf[BUF]; /* buffer for numeric conversions */
-#ifdef SCANF_WIDE_CHAR
wchar_t *wcp; /* handy wide character pointer */
size_t nconv; /* length of multibyte sequence converted */
mbstate_t mbs;
-#endif
/* `basefix' is used to avoid `if' tests in the integer scanner */
static short basefix[17] =
@@ -238,14 +234,12 @@
base = 16;
break;
-#ifdef FLOATING_POINT
case 'e': case 'E':
case 'f': case 'F':
case 'g': case 'G':
case 'a': case 'A':
c = CT_FLOAT;
break;
-#endif
case 's':
c = CT_STRING;
@@ -338,7 +332,6 @@
/* scan arbitrary characters (sets NOSKIP) */
if (width == 0)
width = 1;
-#ifdef SCANF_WIDE_CHAR
if (flags & LONG) {
if ((flags & SUPPRESS) == 0)
wcp = va_arg(ap, wchar_t *);
@@ -378,9 +371,7 @@
}
if (!(flags & SUPPRESS))
nassigned++;
- } else
-#endif /* SCANF_WIDE_CHAR */
- if (flags & SUPPRESS) {
+ } else if (flags & SUPPRESS) {
size_t sum = 0;
for (;;) {
if ((n = fp->_r) < (int)width) {
@@ -415,7 +406,6 @@
/* scan a (nonempty) character class (sets NOSKIP) */
if (width == 0)
width = (size_t)~0; /* `infinity' */
-#ifdef SCANF_WIDE_CHAR
/* take only those things in the class */
if (flags & LONG) {
wchar_t twc;
@@ -480,7 +470,6 @@
nassigned++;
}
} else
-#endif /* SCANF_WIDE_CHAR */
/* take only those things in the class */
if (flags & SUPPRESS) {
n = 0;
@@ -522,7 +511,6 @@
/* like CCL, but zero-length string OK, & no NOSKIP */
if (width == 0)
width = (size_t)~0;
-#ifdef SCANF_WIDE_CHAR
if (flags & LONG) {
wchar_t twc;
@@ -574,9 +562,7 @@
*wcp = L'\0';
nassigned++;
}
- } else
-#endif /* SCANF_WIDE_CHAR */
- if (flags & SUPPRESS) {
+ } else if (flags & SUPPRESS) {
n = 0;
while (!isspace(*fp->_p)) {
n++, fp->_r--, fp->_p++;
@@ -757,7 +743,6 @@
nread += p - buf;
break;
-#ifdef FLOATING_POINT
case CT_FLOAT:
/* scan a floating point number as if by strtod */
if (width == 0 || width > sizeof(buf) - 1)
@@ -780,7 +765,6 @@
}
nread += width;
break;
-#endif /* FLOATING_POINT */
}
}
input_failure:
diff --git a/libc/stdio/vfwprintf.c b/libc/stdio/vfwprintf.c
index 520c8bc..e0ad84f 100644
--- a/libc/stdio/vfwprintf.c
+++ b/libc/stdio/vfwprintf.c
@@ -76,10 +76,8 @@
ptrdiff_t *pptrdiffarg;
ssize_t *pssizearg;
intmax_t *pintmaxarg;
-#ifdef FLOATING_POINT
double doublearg;
long double longdoublearg;
-#endif
wint_t wintarg;
wchar_t *pwchararg;
};
@@ -228,7 +226,6 @@
return (convbuf);
}
-#ifdef FLOATING_POINT
#include <float.h>
#include <locale.h>
#include <math.h>
@@ -238,7 +235,6 @@
#define DEFPREC 6
static int exponent(wchar_t *, int, int);
-#endif /* FLOATING_POINT */
/*
* The size of the buffer we use as scratch space for integer
@@ -287,7 +283,6 @@
int width; /* width from format (%8d), or 0 */
int prec; /* precision from format; <0 for N/A */
wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */
-#ifdef FLOATING_POINT
/*
* We can decompose the printed representation of floating
* point numbers into several parts, some of which may be empty:
@@ -316,7 +311,6 @@
int ndig; /* actual number of digits returned by dtoa */
wchar_t expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */
char *dtoaresult = NULL;
-#endif
uintmax_t _umax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */
@@ -572,11 +566,9 @@
}
width = n;
goto reswitch;
-#ifdef FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (*fmt == 'h') {
fmt++;
@@ -628,7 +620,6 @@
}
base = DEC;
goto number;
-#ifdef FLOATING_POINT
case 'a':
case 'A':
if (ch == 'a') {
@@ -770,7 +761,6 @@
lead = expt;
}
break;
-#endif /* FLOATING_POINT */
#ifndef NO_PRINTF_PERCENT_N
case 'n':
if (flags & LLONGINT)
@@ -977,7 +967,6 @@
PAD(dprec - size, zeroes);
/* the string or number proper */
-#ifdef FLOATING_POINT
if ((flags & FPT) == 0) {
PRINT(cp, size);
} else { /* glue together f_p fragments */
@@ -1012,9 +1001,6 @@
PRINT(expstr, expsize);
}
}
-#else
- PRINT(cp, size);
-#endif
/* left-adjusting padding (always blank) */
if (flags & LADJUST)
PAD(width - realsz, blanks);
@@ -1039,10 +1025,8 @@
finish:
free(convbuf);
-#ifdef FLOATING_POINT
if (dtoaresult)
__freedtoa(dtoaresult);
-#endif
if (argtable != NULL && argtable != statargtable) {
munmap(argtable, argtablesiz);
argtable = NULL;
@@ -1220,11 +1204,9 @@
goto rflag;
}
goto reswitch;
-#ifdef FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (*fmt == 'h') {
fmt++;
@@ -1266,7 +1248,6 @@
case 'i':
ADDSARG();
break;
-#ifdef FLOATING_POINT
case 'a':
case 'A':
case 'e':
@@ -1280,7 +1261,6 @@
else
ADDTYPE(T_DOUBLE);
break;
-#endif /* FLOATING_POINT */
#ifndef NO_PRINTF_PERCENT_N
case 'n':
if (flags & LLONGINT)
@@ -1384,14 +1364,12 @@
case TP_LLONG:
(*argtable)[n].plonglongarg = va_arg(ap, long long *);
break;
-#ifdef FLOATING_POINT
case T_DOUBLE:
(*argtable)[n].doublearg = va_arg(ap, double);
break;
case T_LONG_DOUBLE:
(*argtable)[n].longdoublearg = va_arg(ap, long double);
break;
-#endif
case TP_CHAR:
(*argtable)[n].pchararg = va_arg(ap, char *);
break;
@@ -1472,7 +1450,6 @@
}
-#ifdef FLOATING_POINT
static int
exponent(wchar_t *p0, int exp, int fmtch)
{
@@ -1507,4 +1484,3 @@
}
return (p - p0);
}
-#endif /* FLOATING_POINT */
diff --git a/libc/stdio/vfwscanf.c b/libc/stdio/vfwscanf.c
index 0a7bfa9..a05fffe 100644
--- a/libc/stdio/vfwscanf.c
+++ b/libc/stdio/vfwscanf.c
@@ -42,9 +42,7 @@
#include <wctype.h>
#include "local.h"
-#ifdef FLOATING_POINT
#include "floatio.h"
-#endif
#define BUF 513 /* Maximum length of numeric string. */
@@ -252,14 +250,12 @@
base = 16;
break;
-#ifdef FLOATING_POINT
case 'e': case 'E':
case 'f': case 'F':
case 'g': case 'G':
case 'a': case 'A':
c = CT_FLOAT;
break;
-#endif
case 's':
c = CT_STRING;
@@ -680,7 +676,6 @@
nconversions++;
break;
-#ifdef FLOATING_POINT
case CT_FLOAT:
/* scan a floating point number as if by strtod */
if (width == 0 || width > sizeof(buf) /
@@ -705,7 +700,6 @@
nread += width;
nconversions++;
break;
-#endif /* FLOATING_POINT */
}
}
input_failure: