\
(var) = _val = read_uleb128 (start, &length_return, end); \
if ((var) != _val) \
- error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
- __FILE__, __LINE__, _val); \
+ error (_("Internal error: %s:%d: LEB value (%s) " \
+ "too large for containing variable\n"), \
+ __FILE__, __LINE__, dwarf_vmatoa ("u", _val)); \
start += length_return; \
} \
while (0)
\
(var) = _val = read_sleb128 (start, &length_return, end); \
if ((var) != _val) \
- error (_("Internal error: %s%d: LEB value (%#" DWARF_VMA_FMT "x) too large for containing variable\n"), \
- __FILE__, __LINE__, _val); \
+ error (_("Internal error: %s:%d: LEB value (%s) " \
+ "too large for containing variable\n"), \
+ __FILE__, __LINE__, dwarf_vmatoa ("d", _val)); \
start += length_return; \
} \
while (0)
} \
while (0)
\f
+/* Print a BFD_VMA to an internal buffer, for use in error messages.
+ BFD_FMA_FMT can't be used in translated strings. */
+
+static const char *
+bfd_vmatoa (char *fmtch, bfd_vma value)
+{
+ /* bfd_vmatoa is used more then once in a printf call for output.
+ Cycle through an array of buffers. */
+ static int buf_pos = 0;
+ static struct bfd_vmatoa_buf
+ {
+ char place[64];
+ } buf[4];
+ char *ret;
+ char fmt[32];
+
+ ret = buf[buf_pos++].place;
+ buf_pos %= ARRAY_SIZE (buf);
+
+ sprintf (fmt, "%%%s%s", BFD_VMA_FMT, fmtch);
+ snprintf (ret, sizeof (buf[0].place), fmt, value);
+ return ret;
+}
+
/* Retrieve NMEMB structures, each SIZE bytes long from FILE starting at OFFSET +
the offset of the current archive member, if we are examining an archive.
Put the retrieved data into VAR, if it is not NULL. Otherwise allocate a buffer
|| (bfd_size_type) ((size_t) nmemb) != nmemb))
{
if (reason)
- error (_("Size truncation prevents reading 0x%" BFD_VMA_FMT "x"
- " elements of size 0x%" BFD_VMA_FMT "x for %s\n"),
- nmemb, size, reason);
+ error (_("Size truncation prevents reading %s"
+ " elements of size %s for %s\n"),
+ bfd_vmatoa ("u", nmemb), bfd_vmatoa ("u", size), reason);
return NULL;
}
if (amt < nmemb)
{
if (reason)
- error (_("Size overflow prevents reading 0x%" BFD_VMA_FMT "x"
- " elements of size 0x%" BFD_VMA_FMT "x for %s\n"),
- nmemb, size, reason);
+ error (_("Size overflow prevents reading %s"
+ " elements of size %s for %s\n"),
+ bfd_vmatoa ("u", nmemb), bfd_vmatoa ("u", size), reason);
return NULL;
}
|| offset + archive_file_offset + amt > current_file_size)
{
if (reason)
- error (_("Reading 0x%" BFD_VMA_FMT "x"
- " bytes extends past end of file for %s\n"),
- amt, reason);
+ error (_("Reading %s bytes extends past end of file for %s\n"),
+ bfd_vmatoa ("u", amt), reason);
return NULL;
}
if (mvar == NULL)
{
if (reason)
- error (_("Out of memory allocating 0x%" BFD_VMA_FMT "x"
- " bytes for %s\n"),
- amt, reason);
+ error (_("Out of memory allocating %s bytes for %s\n"),
+ bfd_vmatoa ("u", amt), reason);
return NULL;
}
if (fread (mvar, (size_t) size, (size_t) nmemb, file) != nmemb)
{
if (reason)
- error (_("Unable to read in 0x%" BFD_VMA_FMT "x bytes of %s\n"),
- amt, reason);
+ error (_("Unable to read in %s bytes of %s\n"),
+ bfd_vmatoa ("u", amt), reason);
if (mvar != var)
free (mvar);
return NULL;
if (sizeof (size_t) < sizeof (bfd_size_type)
&& (bfd_size_type) ((size_t) number) != number)
{
- error (_("Size truncation prevents reading %" BFD_VMA_FMT "u"
- " elements of size %u\n"),
- number, ent_size);
+ error (_("Size truncation prevents reading %s elements of size %u\n"),
+ bfd_vmatoa ("u", number), ent_size);
return NULL;
}
attempting to allocate memory when the read is bound to fail. */
if (ent_size * number > current_file_size)
{
- error (_("Invalid number of dynamic entries: %" BFD_VMA_FMT "u\n"),
- number);
+ error (_("Invalid number of dynamic entries: %s\n"),
+ bfd_vmatoa ("u", number));
return NULL;
}
e_data = (unsigned char *) cmalloc ((size_t) number, ent_size);
if (e_data == NULL)
{
- error (_("Out of memory reading %" BFD_VMA_FMT "u dynamic entries\n"),
- number);
+ error (_("Out of memory reading %s dynamic entries\n"),
+ bfd_vmatoa ("u", number));
return NULL;
}
if (fread (e_data, ent_size, (size_t) number, file) != number)
{
- error (_("Unable to read in %" BFD_VMA_FMT "u bytes of dynamic data\n"),
- number * ent_size);
+ error (_("Unable to read in %s bytes of dynamic data\n"),
+ bfd_vmatoa ("u", number * ent_size));
free (e_data);
return NULL;
}
i_data = (bfd_vma *) cmalloc ((size_t) number, sizeof (*i_data));
if (i_data == NULL)
{
- error (_("Out of memory allocating space for %" BFD_VMA_FMT "u"
- " dynamic entries\n"),
- number);
+ error (_("Out of memory allocating space for %s dynamic entries\n"),
+ bfd_vmatoa ("u", number));
free (e_data);
return NULL;
}