/* bucomm.c -- Bin Utils COMmon code.
Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002,
- 2003, 2005, 2006, 2007, 2008, 2009
+ 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GNU Binutils.
void
bfd_nonfatal (const char *string)
{
- const char *errmsg = bfd_errmsg (bfd_get_error ());
+ const char *errmsg;
+ errmsg = bfd_errmsg (bfd_get_error ());
+ fflush (stdout);
if (string)
fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
else
PROGRAM:file: bfd-error-message
PROGRAM:file[section]: bfd-error-message
PROGRAM:file: printf-message: bfd-error-message
- PROGRAM:file[section]: printf-message: bfd-error-message
-*/
+ PROGRAM:file[section]: printf-message: bfd-error-message. */
void
bfd_nonfatal_message (const char *filename,
- const bfd *bfd, const asection *section,
+ const bfd *abfd,
+ const asection *section,
const char *format, ...)
{
- const char *errmsg = bfd_errmsg (bfd_get_error ());
- const char *section_name = NULL;
+ const char *errmsg;
+ const char *section_name;
va_list args;
+ errmsg = bfd_errmsg (bfd_get_error ());
+ fflush (stdout);
+ section_name = NULL;
va_start (args, format);
fprintf (stderr, "%s", program_name);
- if (bfd)
+ if (abfd)
{
if (!filename)
- filename = bfd_get_archive_filename (bfd);
+ filename = bfd_get_archive_filename (abfd);
if (section)
- section_name = bfd_get_section_name (bfd, section);
+ section_name = bfd_get_section_name (abfd, section);
}
if (section_name)
fprintf (stderr, ":%s[%s]", filename, section_name);
void
report (const char * format, va_list args)
{
+ fflush (stdout);
fprintf (stderr, "%s: ", program_name);
vfprintf (stderr, format, args);
putc ('\n', stderr);
void
list_matching_formats (char **p)
{
+ fflush (stdout);
fprintf (stderr, _("%s: Matching formats:"), program_name);
while (*p)
fprintf (stderr, " %s", *p++);
list_supported_targets (const char *name, FILE *f)
{
int t;
- const char **targ_names = bfd_target_list ();
+ const char **targ_names;
if (name == NULL)
fprintf (f, _("Supported targets:"));
else
fprintf (f, _("%s: supported targets:"), name);
+ targ_names = bfd_target_list ();
for (t = 0; targ_names[t] != NULL; t++)
fprintf (f, " %s", targ_names[t]);
fprintf (f, "\n");
/* Returns the size of the named file. If the file does not
exist, or if it is not a real file, then a suitable non-fatal
- error message is printed and zero is returned. */
+ error message is printed and (off_t) -1 is returned. */
off_t
get_file_size (const char * file_name)
}
else if (! S_ISREG (statbuf.st_mode))
non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
+ else if (statbuf.st_size < 0)
+ non_fatal (_("Warning: '%s' has negative size, probably it is too large"),
+ file_name);
else
return statbuf.st_size;