# define is_longlong is_long_double
#endif
+/* If `long' and `int' is effectively the same type we don't have to
+ handle `long separately. */
+#if INT_MAX == LONG_MAX
+# define is_long_num 0
+#else
+# define is_long_num is_long
+#endif
+
/* Global variables. */
static const char null[] = "(null)";
\
if (fspec == NULL) \
{ \
- if (is_long) \
+ if (is_long_num) \
signed_number = va_arg (ap, long int); \
else /* `char' and `short int' will be promoted to `int'. */ \
signed_number = va_arg (ap, int); \
} \
else \
- if (is_long) \
+ if (is_long_num) \
signed_number = args_value[fspec->data_arg].pa_long_int; \
else \
signed_number = args_value[fspec->data_arg].pa_int; \
{ \
if (fspec == NULL) \
{ \
- if (is_long) \
+ if (is_long_num) \
number.word = va_arg (ap, unsigned long int); \
else if (!is_short) \
number.word = va_arg (ap, unsigned int); \
number.word = (unsigned short int) va_arg (ap, unsigned int); \
} \
else \
- if (is_long) \
+ if (is_long_num) \
number.word = args_value[fspec->data_arg].pa_u_long_int; \
else if (is_char) \
number.word = (unsigned char) \
{ \
if (is_longlong) \
*(long long int *) va_arg (ap, void *) = done; \
- else if (is_long) \
+ else if (is_long_num) \
*(long int *) va_arg (ap, void *) = done; \
else if (!is_short) \
*(int *) va_arg (ap, void *) = done; \
else \
if (is_longlong) \
*(long long int *) args_value[fspec->data_arg].pa_pointer = done; \
- else if (is_long) \
+ else if (is_long_num) \
*(long int *) args_value[fspec->data_arg].pa_pointer = done; \
else if (!is_short) \
*(int *) args_value[fspec->data_arg].pa_pointer = done; \
# define need_longlong 1
#endif
+/* Determine whether we have to handle `long'. */
+#if INT_MAX == LONG_MAX
+# define need_long 0
+#else
+# define need_long 1
+#endif
+
/* Those are flags in the conversion format. */
-# define LONG 0x001 /* l: long or double */
-# define LONGDBL 0x002 /* L: long long or long double */
-# define SHORT 0x004 /* h: short */
-# define SUPPRESS 0x008 /* *: suppress assignment */
-# define POINTER 0x010 /* weird %p pointer (`fake hex') */
-# define NOSKIP 0x020 /* do not skip blanks */
-# define WIDTH 0x040 /* width was given */
-# define GROUP 0x080 /* ': group numbers */
-# define MALLOC 0x100 /* a: malloc strings */
-# define CHAR 0x200 /* hh: char */
+#define LONG 0x001 /* l: long or double */
+#define LONGDBL 0x002 /* L: long long or long double */
+#define SHORT 0x004 /* h: short */
+#define SUPPRESS 0x008 /* *: suppress assignment */
+#define POINTER 0x010 /* weird %p pointer (`fake hex') */
+#define NOSKIP 0x020 /* do not skip blanks */
+#define WIDTH 0x040 /* width was given */
+#define GROUP 0x080 /* ': group numbers */
+#define MALLOC 0x100 /* a: malloc strings */
+#define CHAR 0x200 /* hh: char */
#ifdef USE_IN_LIBIO
{
/* A double `l' is equivalent to an `L'. */
++f;
- flags |= need_longlong ? LONGDBL : LONG;
+ flags |= LONGDBL | LONG;
}
else
/* ints are long ints. */
case 'q':
case 'L':
/* doubles are long doubles, and ints are long long ints. */
- flags |= need_longlong ? LONGDBL : LONG;
+ flags |= LONGDBL | LONG;
break;
case 'a':
/* The `a' is used as a flag only if followed by `s', `S' or
/* Don't count the read-ahead. */
if (need_longlong && (flags & LONGDBL))
*ARG (long long int *) = read_in;
- else if (flags & LONG)
+ else if (need_long && (flags & LONG))
*ARG (long int *) = read_in;
else if (flags & SHORT)
*ARG (short int *) = read_in;
- else
+ else if (!(flags & CHAR))
*ARG (int *) = read_in;
+ else
+ *ARG (char *) = read_in;
#ifdef NO_BUG_IN_ISO_C_CORRIGENDUM_1
/* We have a severe problem here. The ISO C standard
{
if (need_longlong && (flags & LONGDBL))
*ARG (unsigned LONGLONG int *) = num.uq;
- else if (flags & LONG)
+ else if (need_long && (flags & LONG))
*ARG (unsigned long int *) = num.ul;
else if (flags & SHORT)
*ARG (unsigned short int *)
= (unsigned short int) num.ul;
- else if (flags & CHAR)
- *ARG (unsigned char *) = (unsigned char) num.ul;
- else
+ else if (!(flags & CHAR))
*ARG (unsigned int *) = (unsigned int) num.ul;
+ else
+ *ARG (unsigned char *) = (unsigned char) num.ul;
}
else
{
if (need_longlong && (flags & LONGDBL))
*ARG (LONGLONG int *) = num.q;
- else if (flags & LONG)
+ else if (need_long && (flags & LONG))
*ARG (long int *) = num.l;
else if (flags & SHORT)
*ARG (short int *) = (short int) num.l;
- else if (flags & CHAR)
- *ARG (signed char *) = (signed char) num.ul;
- else
+ else if (!(flags & CHAR))
*ARG (int *) = (int) num.l;
+ else
+ *ARG (signed char *) = (signed char) num.ul;
}
++done;
}
base = 16;
/* A PTR must be the same size as a `long int'. */
flags &= ~(SHORT|LONGDBL);
- flags |= LONG;
+ if (need_long)
+ flags |= LONG;
number_signed = 0;
read_pointer = 1;
goto number;