This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Support %N$/*N$ style format arguments in GCC diagnostics
Jakub Jelinek <firstname.lastname@example.org> writes:
> On Wed, May 18, 2005 at 05:34:52PM +0000, Joseph S. Myers wrote:
>> > BTW, shouldn't we implement %n$ style arguments in addition to % ones?
>> > It seems e.g. several turkish translations relied on this...
>> Chiaki Ishikawa had a long patch series attempting to implement them but I
>> don't think they ever got in reviewable form or were following an approach
>> Zack liked.
> Seeing that the last po commit added a big number of %N$ arguments, I wrote
> following patch.
I'm glad to see someone picking up this ball again.
> I tried to make the requirements match POSIX *printf requirements.
> pp_base_format_text works in 3 phases, first it scans the format string
> and records the arguments, then, with optional help of a hook stores
> the arguments into a union and finally prints them as it used to print them
> before, only instead of va_arg directly it uses that union.
I'd like to draw your attention to the algorithm outlined in
<http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02551.html>. I think
it's pretty close to the algorithm you implemented, but it doesn't
need the union (at the cost of slight, IMO actively desirable,
deviation from POSIX - you can't refer to the same argument twice with
different format specifiers) and should be structurally simpler.
Also, it deals quite nicely with the %H/%J issue you brought up; in
fact, it opens the way for us to resurrect C++'s old %+D notation and
not have to pass decls twice in so many places.