Support for %d$c format specifier in diagnostics.c
Ishikawa
ishikawa@yk.rim.or.jp
Thu Jul 10 01:28:00 GMT 2003
Hello,
Thank you for your previous comments.
Supporting %d$s form format specifier
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;
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 ?
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.
So my main question would be why do we support two different series of
enlarging the size of the types in diagnostic.c?
("%d", "%wd") and ("%d", "%ld", "%lld").
("%x", "%wx") and ("%x", "%lx", "%llx").
("%o", "%wo") and ("%o", "%lo", "%llo").
("%u", "%wu") and ("%u", "%lu", "%llu").
Again, this may be a rhetorical question. I am trying to
support both of them anyway. However, I was unaware of the
subtle trick used by the macros to support (%d, %ld, and %lld),
and so am rewriting some code now. To simply support,
I need to make some reasonable assumptions such as
long int, unsigned long int would have the same sized memory
cell, etc.. (I am not sure if this is true on one's complement
machine if such exists anymore.)
Otherwise, the coding seems to have progressed very
much now.
Happy Hacking,
--
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