printf: fix up dodgy use of #if HAVE_FOO and #if !HAVE_FOO

Should use #ifdef and #ifndef.
This commit is contained in:
Tim-Philipp Müller 2013-04-07 18:21:00 +01:00 committed by Tim-Philipp Müller
parent 79d6b91e27
commit 97b3948a9f
3 changed files with 13 additions and 13 deletions

View file

@ -29,10 +29,10 @@
#include <stddef.h>
/* Get intmax_t. */
#if HAVE_STDINT_H_WITH_UINTMAX
#ifdef HAVE_STDINT_H_WITH_UINTMAX
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H_WITH_UINTMAX
#ifdef HAVE_INTTYPES_H_WITH_UINTMAX
# include <inttypes.h>
#endif

View file

@ -378,7 +378,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
char *p;
unsigned int prefix_count;
int prefixes[2];
#if !HAVE_SNPRINTF
#ifndef HAVE_SNPRINTF
unsigned int tmp_length;
char tmpbuf[700];
char *tmp;
@ -658,7 +658,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
break;
}
*p = dp->conversion;
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
p[1] = '%';
p[2] = 'n';
p[3] = '\0';
@ -678,7 +678,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
abort ();
prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
}
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
/* Prepare checking whether snprintf returns the count
via %n. */
ENSURE_ALLOCATION (length + 1);
@ -688,14 +688,14 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
for (;;) {
size_t maxlen;
int count;
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
int retcount;
#endif
maxlen = allocated - length;
count = -1;
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
retcount = 0;
#define SNPRINTF_BUF(arg) \
@ -845,7 +845,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
while (digitp != dp->precision_end);
}
}
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
count = print_long_long (result + length, maxlen,
width, precision, dp->flags, dp->conversion, arg);
#else
@ -937,7 +937,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
abort ();
}
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
/* Portability: Not all implementations of snprintf()
are ISO C 99 compliant. Determine the number of
bytes that snprintf() has produced or would have
@ -972,7 +972,7 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
errno = EINVAL;
return NULL;
}
#if !HAVE_SNPRINTF
#ifndef HAVE_SNPRINTF
if (count >= tmp_length)
/* tmp_length was incorrectly calculated - fix the
code above! */
@ -990,11 +990,11 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
n = 2 * allocated;
ENSURE_ALLOCATION (n);
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
continue;
#endif
}
#if HAVE_SNPRINTF
#ifdef HAVE_SNPRINTF
/* The snprintf() result did fit. */
#else
/* Append the sprintf() result. */

View file

@ -27,7 +27,7 @@
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || defined (__STRICT_ANSI__)
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes