On 2/22/25 6:33 PM, Robert Elz wrote:

Further, this spec also violates Chet's rule:

chet.ra...@case.edu said:
   | There is no user who would think that using a numbered conversion specifier
   | is not an absolute position in the original argument list.

which does not apply when the format string is reused -- format string
reuse in the presence of numbered conversions would make a lot more
sense if it did, and %2$ *always* (on every iteration of the format
string) meant the 2nd arg.   Then mixing numbered and unnumbered
conversion specs would make sense, with only the unnumbered ones
consuming the excess args (and would make them make absolutely no
sense with only numbered conversions of course).

Yes, that rule is hard and fast only in the case of the first time through
the format string. User expectations differ if you reuse it.


And finally, to Andreas' comment which was what inspired me to continue
this relatively meaningless thread:

   | As long as NL_ARGMAX >= 999.

No, there is no such restriction.

For printf(1), there is.

"In this case, the conversion specifier character '%' is replaced by the
sequence "%n$", where n is a decimal integer in the range [1,{NL_ARGMAX}],
giving the argument operand number."

An implementation is free to reject the numbered conversion if it exceeds
NL_ARGMAX, even if you say this is an application requirement, because of
rule 11 about out-of-range numbered conversion specifiers.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to