+2017-11-15 Alan Modra <amodra@gmail.com>
+
+ * bfd.c (union _bfd_doprnt_args): Add "Bad".
+ (_bfd_doprnt): Handle more flags.
+ (_bfd_doprnt_scan): Likewise. Tidy setting of args array.
+ (error_handler_internal): Init args type to Bad.
+
2017-11-14 Alan Modra <amodra@gmail.com>
PR 22431
void *p;
enum
{
+ Bad,
Int,
Long,
LongLong,
}
/* Move past flags. */
- while (strchr ("-+ #0", *ptr))
+ while (strchr ("-+ #0'I", *ptr))
*sptr++ = *ptr++;
if (*ptr == '*')
{
int wide_width = 0, short_width = 0;
unsigned int arg_no;
+ int arg_type;
ptr++;
}
/* Move past flags. */
- while (strchr ("-+ #0", *ptr))
+ while (strchr ("-+ #0'I", *ptr))
ptr++;
if (*ptr == '*')
if ((int) arg_no < 0)
arg_no = arg_count;
- if (arg_no >= 9)
- abort ();
+ arg_type = Bad;
switch (ptr[-1])
{
case 'd':
case 'c':
{
if (short_width)
- args[arg_no].type = Int;
+ arg_type = Int;
else
{
if (ptr[-2] == 'L')
switch (wide_width)
{
case 0:
- args[arg_no].type = Int;
+ arg_type = Int;
break;
case 1:
- args[arg_no].type = Long;
+ arg_type = Long;
break;
case 2:
default:
#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
- args[arg_no].type = LongLong;
+ arg_type = LongLong;
#else
- args[arg_no].type = Long;
+ arg_type = Long;
#endif
break;
}
case 'G':
{
if (wide_width == 0)
- args[arg_no].type = Double;
+ arg_type = Double;
else
{
#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
- args[arg_no].type = LongDouble;
+ arg_type = LongDouble;
#else
- args[arg_no].type = Double;
+ arg_type = Double;
#endif
}
}
case 'p':
case 'A':
case 'B':
- args[arg_no].type = Ptr;
+ arg_type = Ptr;
break;
default:
abort();
}
+
+ if (arg_no >= 9)
+ abort ();
+ args[arg_no].type = arg_type;
arg_count++;
}
}
static void
error_handler_internal (const char *fmt, va_list ap)
{
- int i, arg_count;
+ unsigned int i, arg_count;
union _bfd_doprnt_args args[9];
+ for (i = 0; i < sizeof (args) / sizeof (args[0]); i++)
+ args[i].type = Bad;
+
arg_count = _bfd_doprnt_scan (fmt, args);
for (i = 0; i < arg_count; i++)
{