aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/uniq.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-12-04 21:29:51 -0600
committerRob Landley <rob@landley.net>2018-12-04 21:29:51 -0600
commit747e296ff656813340c9355d98b0a13cba8473bc (patch)
treee7ef2b20be56e2e5a2062168aa822fd6c6139b7d /toys/posix/uniq.c
parent141a075c0e192dc9910e777270114b1864270bfd (diff)
downloadtoybox-747e296ff656813340c9355d98b0a13cba8473bc.tar.gz
Add FLAG(x) macro, expanding to (toys.optflags & FLAG_##x)
Diffstat (limited to 'toys/posix/uniq.c')
-rw-r--r--toys/posix/uniq.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/toys/posix/uniq.c b/toys/posix/uniq.c
index 6c89c630..0ca01783 100644
--- a/toys/posix/uniq.c
+++ b/toys/posix/uniq.c
@@ -50,10 +50,10 @@ static char *skip(char *str)
static void print_line(FILE *f, char *line)
{
- if (toys.optflags & (TT.repeats ? FLAG_u : FLAG_d)) return;
- if (toys.optflags & FLAG_c) fprintf(f, "%7lu ", TT.repeats + 1);
+ if (TT.repeats ? FLAG(u) : FLAG(d)) return;
+ if (FLAG(c)) fprintf(f, "%7lu ", TT.repeats + 1);
fputs(line, f);
- if (toys.optflags & FLAG_z) fputc(0, f);
+ if (FLAG(z)) fputc(0, f);
}
void uniq_main(void)
@@ -65,7 +65,7 @@ void uniq_main(void)
if (toys.optc >= 1) infile = xfopen(toys.optargs[0], "r");
if (toys.optc >= 2) outfile = xfopen(toys.optargs[1], "w");
- if (toys.optflags & FLAG_z) eol = 0;
+ if (FLAG(z)) eol = 0;
// If first line can't be read
if (getdelim(&prevline, &prevsize, eol, infile) < 0) return;
@@ -84,9 +84,8 @@ void uniq_main(void)
}
if (!TT.w)
- diff = !(toys.optflags & FLAG_i) ? strcmp(t1, t2) : strcasecmp(t1, t2);
- else diff = !(toys.optflags & FLAG_i) ? strncmp(t1, t2, TT.w)
- : strncasecmp(t1, t2, TT.w);
+ diff = !FLAG(i) ? strcmp(t1, t2) : strcasecmp(t1, t2);
+ else diff = !FLAG(i) ? strncmp(t1, t2, TT.w) : strncasecmp(t1, t2, TT.w);
if (!diff) TT.repeats++;
else {