tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Fwd: Re: fmtcheck() query



    Date:        Mon, 11 Dec 2017 14:17:15 +0000 (UTC)
    From:        uwe%stderr.spb.ru@localhost (Valery Ushakov)
    Message-ID:  <p0m41b$qv5$1%blaine.gmane.org@localhost>


  | I guess the reason behind that requirement must be the fact that it's
  | not possible to skip arguments with va_arg().  So e.g. for "%3$s %1$d"
  | you wouldn't know how to get to the third argument as there's no type
  | info for the second: is it a 4-byte int, or 8-byte pointer, or 8-byte
  | double, etc.

There really needs to be a new format flag to specify that the conversion
is not to actually be used (generates no output at all) but which can be used
to specify the argument type, so one might write for the example you gave

	"%3$s %1$d%2$!e"

(where '!' is the new flag char) after which we know what type (what
size really) the unused 2nd arg is, but it is never actually used.
(The %2$!e part could be placed anywhere in the string with the same effect.)

But we don't have that (yet anyway...)

  | OTOH, we can't tell if the format misses some arguments intentionally.

I don't think that's fmtcheck's job.   Its purpose is (or should be) to
make sure the program does not mis-use the args (print some part of a
floating value as if it were a pointer...) rather than that it is perfect.

There are good reasons why args might want to be omitted sometimes, and
I think that should really be supported (trailing args particularly.)

kre



Home | Main Index | Thread Index | Old Index