From 2d34e7b7050b27f32d78830ae13f54c7cc97fa01 Mon Sep 17 00:00:00 2001 From: cheloha Date: Sat, 1 Jan 2022 17:44:18 +0000 Subject: [PATCH] uniq(1): bump numchars, numfields from int to long long Also bump repeats from int to unsigned long long. While here, don't cast the result of strtonum() and unwrap some lines. --- usr.bin/uniq/uniq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 72474bfd1e7..437dcdae610 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uniq.c,v 1.31 2022/01/01 02:20:38 cheloha Exp $ */ +/* $OpenBSD: uniq.c,v 1.32 2022/01/01 17:44:18 cheloha Exp $ */ /* $NetBSD: uniq.c,v 1.7 1995/08/31 22:03:48 jtc Exp $ */ /* @@ -45,8 +45,9 @@ #include #include +long long numchars, numfields; +unsigned long long repeats; int cflag, dflag, iflag, uflag; -int numchars, numfields, repeats; void show(const char *); char *skip(char *); @@ -78,8 +79,7 @@ main(int argc, char *argv[]) dflag = 1; break; case 'f': - numfields = (int)strtonum(optarg, 0, INT_MAX, - &errstr); + numfields = strtonum(optarg, 0, LLONG_MAX, &errstr); if (errstr) errx(1, "field skip value is %s: %s", errstr, optarg); @@ -88,8 +88,7 @@ main(int argc, char *argv[]) iflag = 1; break; case 's': - numchars = (int)strtonum(optarg, 0, INT_MAX, - &errstr); + numchars = strtonum(optarg, 0, LLONG_MAX, &errstr); if (errstr) errx(1, "character skip value is %s: %s", @@ -187,7 +186,7 @@ show(const char *str) { if ((dflag && repeats) || (uflag && !repeats)) { if (cflag) - printf("%4d %s\n", repeats + 1, str); + printf("%4llu %s\n", repeats + 1, str); else printf("%s\n", str); } @@ -196,8 +195,8 @@ show(const char *str) char * skip(char *str) { + long long nchars, nfields; wchar_t wc; - int nchars, nfields; int len; int field_started; -- 2.20.1