This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [COMMITTED PATCH] Fix %s that should be %B in several message formats.
Roland McGrath wrote:
>> Your patch is obviously incorrect, except for the last place you
>> change. Please fix.
>
> That last place was the actual one I had noticed and (knew how to) test.
> I'm confused about how the other cases I changed differ from that one.
> They pass a bfd * argument to (*_bfd_error_handler) first after the format,
> corresponding to a %s in the format.
It doesn't "correspond". The first argument is non-positional; it's always
the relevant bfd, and it's used anywhere in the format string where a %B is
present. %A is likewise special; remaining arguments are handled like
sprintf. See the comment in bfd.c:
> /* This is the default routine to handle BFD error messages.
> Like fprintf (stderr, ...), but also handles some extra format specifiers.
>
> %A section name from section. For group components, print group name too.
> %B file name from bfd. For archive components, prints archive too.
>
> Note - because these two extra format specifiers require special handling
> they are scanned for and processed in this function, before calling
> vfprintf. This means that the *arguments* for these format specifiers
> must be the first ones in the variable argument list, regardless of where
> the specifiers appear in the format string. Thus for example calling
> this function with a format string of:
>
> "blah %s blah %A blah %d blah %B"
>
> would involve passing the arguments as:
>
> "blah %s blah %A blah %d blah %B",
> asection_for_the_%A,
> bfd_for_the_%B,
> string_for_the_%s,
> integer_for_the_%d);
> */
cheers,
DaveK