> 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))
Thanks for pointing it out.
Index: uniq.c
===================================================================
RCS file: /var/cvs/src/usr.bin/uniq/uniq.c,v
retrieving revision 1.25
diff -u -p -r1.25 uniq.c
--- uniq.c 21 Dec 2017 10:05:59 -0000 1.25
+++ uniq.c 23 Dec 2017 23:07:16 -0000
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
}
/* If different, print; set previous to new value. */
- if ((!iflag && strcmp(t1, t2)) || strcasecmp(t1, t2)) {
+ if ((iflag ? strcasecmp : strcmp)(t1, t2)) {
show(ofp, prevline);
t1 = prevline;
prevline = thisline;