Support for %d$c format specifier in diagnostics.c
Ishikawa
ishikawa@yk.rim.or.jp
Thu Jul 10 22:13:00 GMT 2003
Gabriel Dos Reis wrote:
> | Thank you for your previous comments.
> |
> | Supporting %d$s form format specifier
>
> hugh. what is that supposed to mean?
Hi,
The support for positional argument specification in the
form of %d$c for diagnostic output routines
was suggested by Zack Weinberg in
http://gcc.gnu.org/ml/gcc/2003-06/msg02458.html
> | might take a few days more than I originally thought it would.
> |
> | A potential Bug:
> |
> | As I dive through the code, I think I found a bug in
> | the original code.
> |
> | Original BUG (?) found.
> | Near line 517 of diagnostic.c , "u" ought to be "o"';
> | case 'o':
> | if (wide)
> | output_formatted_scalar
> | (buffer, "%" HOST_WIDE_INT_PRINT "o",
> | va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
> | else
> | output_integer_with_precision
> | Here ---> (buffer, *text->args_ptr, precision, unsigned, "u");
> | break;
>
> Yes, the "u" above should have been "o". Thanks.
Great. I fixed my local copy, too.
> | This means that this feature of using precision of
> | %lu, and %llu as opposed to simple %u has not been used by
> | the diagnostic messages. [ Maybe I can forget about the precision :-) ]
> |
> | A question.
> |
> | Why are we using HOST_WIDE_INT ?
>
> because the "w" in "%wo" is for HOST_WIDE_INT. See
>
> http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02548.html
Obviously, there are more things in the background than
I could glean from the code alone.
> | Well this is somewhat a rhetorical question.
> |
> | I can guess that on some hosts, the distinction of short, int, and
> | long is such that we need to go to long (instead of simple int) to
> | make sure that we get the the most wide natural size of int.
> |
> | In that case, we must use HOST_WIDE_INT_PRINT_DEC instead of simple
> | "%d" to print such data. diagnostic.c supports "%wd" as opposed to
> | "%d" for this type of intrinsic wide int.
> |
> | But what surprised me a little bit is this.
> | We already support %d, %ld, and %lld in diagnostic.c.
>
> that should not be a surprise: %wd is not a susbtitute for %ld, nor %lld.
>
> | So my main question would be why do we support two different series of
> | enlarging the size of the types in diagnostic.c?
>
> there were (still are?) places where we need to support at least %ld.
> %wd is for abstracting over the actual data type behind HOST_WIDE_INT.
> I think it also makes sense for uniformity to also support long long.
So I take this %wd thing is rather new. No *.po files contain
the %w string yet.
I will check the mentioned URL to see if I handled
the %w construct adequately.
Oh, I posted the patch to diagnostic.c to gcc-patches mailing list,
but it can use some cleaning up, etc..
--
int main(void){int j=2003;/*(c)2003 cishikawa. */
char t[] ="<CI> @abcdefghijklmnopqrstuvwxyz.,\n\"";
char *i ="g>qtCIuqivb,gCwe\np@.ietCIuqi\"tqkvv is>dnamz";
while(*i)((j+=strchr(t,*i++)-(int)t),(j%=sizeof t-1),
(putchar(t[j])));return 0;}/* under GPL */
More information about the Gcc
mailing list