This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Support for %d$c format specifier in diagnostics.c
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Ishikawa <ishikawa at yk dot rim dot or dot jp>
- Cc: Neil Booth <neil at daikokuya dot co dot uk>, gcc at gcc dot gnu dot org
- Date: Fri, 04 Jul 2003 17:17:46 -0700
- Subject: Re: Support for %d$c format specifier in diagnostics.c
- References: <m19WKhW-000H3mC@standard.erephon><20030628193135.GA1767@daikokuya.co.uk><87llvlk3gi.fsf@egil.codesourcery.com><3EFE65DC.52576EC7@yk.rim.or.jp><87vfupiglu.fsf@egil.codesourcery.com><3EFEE0EF.C560ED1A@yk.rim.or.jp><87isqoiwng.fsf@egil.codesourcery.com><3F061172.814BA7A0@yk.rim.or.jp>
Ishikawa <ishikawa@yk.rim.or.jp> writes:
> Zack Weinberg wrote:
>>
>> Ishikawa <ishikawa@yk.rim.or.jp> writes:
>>
>> >> LC_MESSAGES=C should disable translation without any other effect.
>> >> (Not all systems support this variable, however.)
>> >
>> > Thank you for the info. Hmm, I am not sure which system supports
>> > LC_MESSAGES and which doesn't.
>> If you are interested in I18N projects, another worthwhile improvement
>> would be to add support for %n$s notation to diagnostic.c. See
>> <http://www.opengroup.org/onlinepubs/007904975/functions/printf.html> for
>> details of how this is supposed to work.
>>
>> I'll be happy to answer questions as you have them.
>
> As per Zack's suggestion, I am working on the initial cut of
> the support of %n$s notation in diagnostic.c
> (This is not strictly I18N/L10N stuff, though.)
>
> Anyway, here is an overview of what I am coding and
> comment/feedback welcome.
You've got the right idea. Two comments:
> (UNLESS one such reference to a format specifier in the form of
> %n$c is done, we won't have the overhead of the array construction.)
Diagnostic message output doesn't have to be hyper-efficient. If it
simplifies the code to make the array always, do that.
> Now, I am not entirely sure of the usage
> rule of %n$c format specifier.
>
> It seems to me ONCE we use the %n$ construct,
> we probably need to use this format from this point on always.
> (Or we need to use this form for ALL the format specifiers.)
I believe SUS says somewhere that you can use this notation for all or
none, but not some. Even if it doesn't, I think that's an acceptable
limitation for GCC's implementation.
> OK %1$d %3$c %2$s %6$d %5$s %4$c
>
> OK %d %s %c %6$d %5$s %4$c
>
> ambiguous %d %s %c %6$d %s %4$c
> 1 2 3 4 5 6
So, yes, don't permit your third example, and I wouldn't permit the
second either.
zw