summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-08-12 04:32:41 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-08-12 04:32:41 +0000
commit666e8f922ffe516cb4803887a91ddd75f308a79d (patch)
treec1d5e82d40b2ca178d179d5f1887ef1f88142a53 /libc/stdio
parent9a34fd5b8807487a89bb9dd4e895f1f448d75e94 (diff)
Revert commit by davidm to printf.c that initialized conv_num
needlessly. To do so increases the generated code size with bcc. Eliminate duplicate define warnings in wstring.c. Fix potentially broken preprocessor comparisons. The preprocessor converts integers to maximal signed type, so inequality comparisons involving UINTMAX_MAX, ULLONG_MAX, and (if no long long) ULONG_MAX were potentially broken.
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/printf.c8
-rw-r--r--libc/stdio/stdio.c6
2 files changed, 7 insertions, 7 deletions
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c
index 14e3f2173..47c11c6bf 100644
--- a/libc/stdio/printf.c
+++ b/libc/stdio/printf.c
@@ -764,7 +764,7 @@ extern int _ppfs_parsespec(ppfs_t *ppfs)
int n;
int argtype[MAX_ARGS_PER_SPEC+2];
int argnumber[3]; /* width, precision, 1st data arg */
- unsigned int conv_num = 0;
+ unsigned int conv_num; /* This does not need to be initialized. */
static const char spec_flags[] = SPEC_FLAGS;
static const char spec_chars[] = SPEC_CHARS;/* TODO: b? */
static const char spec_ranges[] = SPEC_RANGES;
@@ -1723,14 +1723,14 @@ int sprintf(char *__restrict buf, const char * __restrict format, ...)
*/
#define DIGITS_PER_BLOCK 9
-#if UINT_MAX >= 4294967295UL
+#if INT_MAX >= 2147483647L
#define DIGIT_BLOCK_TYPE int
#define DB_FMT "%.*d"
-#elif LONG_MAX >= 4294967295UL
+#elif LONG_MAX >= 2147483647L
#define DIGIT_BLOCK_TYPE long
#define DB_FMT "%.*ld"
#else
-#error need at least 32 bit longs
+#warning need at least 32 bit longs
#endif
/* Maximum number of calls to fnprintf to output double. */
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index b4208f97c..2c5f3bbed 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -95,7 +95,7 @@
#ifndef __STDIO_THREADSAFE
-#ifdef __BCC__
+#if defined(__BCC__) && 0
#define UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,STREAM) \
asm(".text\nexport _" "NAME" "_unlocked\n_" "NAME" "_unlocked = _" "NAME"); \
RETURNTYPE NAME PARAMS
@@ -108,7 +108,7 @@ RETURNTYPE NAME PARAMS
#define UNLOCKED(RETURNTYPE,NAME,PARAMS,ARGS) \
UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,stream)
-#ifdef __BCC__
+#if defined(__BCC__) && 0
#define UNLOCKED_VOID_RETURN(NAME,PARAMS,ARGS) \
asm(".text\nexport _" "NAME" "_unlocked\n_" "NAME" "_unlocked = _" "NAME"); \
void NAME PARAMS
@@ -3274,7 +3274,7 @@ void _stdio_fdout(int fd, ...)
/* Avoid using long long / and % operations to cut down dependencies on
* libgcc.a. Definitely helps on i386 at least. */
-#if (UINTMAX_MAX > UINT_MAX) && ((UINTMAX_MAX/UINT_MAX) - 2 <= UINT_MAX)
+#if (INTMAX_MAX > INT_MAX) && (((INTMAX_MAX/INT_MAX)/2) - 2 <= INT_MAX)
#define INTERNAL_DIV_MOD
#endif