On Sun, Dec 24, 2017 at 12:01:17AM +0000, kshe wrote: > On Sat, 23 Dec 2017 23:13:22 +0000, Theo Buehler wrote: > > > Obviously, the relevant condition should have been > > > > > > if ((iflag ? strcasecmp : strcmp)(t1, t2) != 0) > > > > > > instead of awkwardly messing with logical AND and OR. > > > > Indeed, this is much better. I like your version, but perhaps others > > might like this one more: > > > > if ((iflag && strcasecmp(t1, t2)) || strcmp(t1, t2)) > > Well, this is even worse: this version not only has the same kind of > performance drawback as the current one, but it is also logically > incorrect, and will cause the `-i' flag to have no effect at all.
Sometimes I'm not only stupid but really, really stupid. Thanks > > If you really want to do this without a ternary operator, the equivalent > form is > > if (iflag && strcasecmp(t1, t2) || !iflag && strcmp(t1, t2)) > > which looks very dumb indeed, but at least it is logically sound. > > Regards, > > kshe >
