tech-userlevel archive

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

Re: Fwd: Re: fmtcheck() query



On 2017/12/13 2:41, Robert Elz wrote:
Missing, probably not, and I didn't know about file (hadn't looked to see
where fmtcheck() was used - though I did see the fix installed) - the case
I am think of is one that we typically handle with an "if" and two printf
statements, but which could be done with one with some increased flexibility.
...
And apart from all that, I just generally prefer flexibility over rigidity
in interfaces - lots of rope with which to hang yourself, or to produce
something of beauty.

Thank you so much for the thorough explanation. I become to think that
the previous behavior should be reasonable.

On 2017/12/13 7:58, Christos Zoulas wrote:
Yes, at least the new behavior made file(1) break and I am sure it is going
to break more 3rd party software that depend on this behavior. For example
file(1) uses fmtcheck to make sure that the formats in the description field
match the implicit type of the file entry line. Some description lines don't
use the values so they don't have format entries. Of course it was easy to
fix in this case by checking that the description contains a '%' and if it
does not, to skip the fmt_check() alltogether. Having said that, I agree
that the new behavior should be optional and since we are going to replace
fmt_check() with a new function that handles positional arguments we can
also add a flag to require exact matches or not.

Yes, I'm so sorry for this breakage of file(1). It clearly indicates
possible risks of changing the behavior of fmtcheck(3).

OK, I will revert fmtcheck.c, rev 1.11. Then, I will correct the manpage
in accordance with its actual behavior.

After that, I would like to replace fmtcheck(3) with new code based on
printf_fmtmatch() by uwe. The problem is how it should be:

(1) Introduce new function like

    const char *
    fmtmatch(const char *suspect, const char *default, int flag)

to libc. We can specify whether unused args are checked or not by flag.
fmtcheck(3) uses it internally.

Alternatively,

(2) Determine the behavior by a compile-time option. fmtcheck(3) in
libc does not complain about unused args. If someone need the rigorous
check, add fmtcheck.c to SRCS with a flag like, -DFMTCHECK_UNUSED_ARGS.

For (1), everyone can choose rigorous unused args checking. However,
at the same time, we carry in another non-standard function to our
libc. I'm worried about it, although I will carefully design its
interface and post it to tech-userlevel@ for review, of course...

Thanks,
rin


Home | Main Index | Thread Index | Old Index