diff options
author | cheloha <cheloha@openbsd.org> | 2020-12-11 05:48:22 +0000 |
---|---|---|
committer | cheloha <cheloha@openbsd.org> | 2020-12-11 05:48:22 +0000 |
commit | 8d576c92c5d93d1e61ef1d918cae5fa9a9421c10 (patch) | |
tree | 721e8fd7edb392808559110f172070673aaa2f91 /bin | |
parent | bpf(4): BIOCGRTIMEOUT, BIOCSRTIMEOUT: protect bd_rtout with bd_mtx (diff) | |
download | wireguard-openbsd-8d576c92c5d93d1e61ef1d918cae5fa9a9421c10.tar.xz wireguard-openbsd-8d576c92c5d93d1e61ef1d918cae5fa9a9421c10.zip |
cat(1): -n flag: correctly enumerate files with more than INT_MAX lines
If we bump 'lines' from an int to an unsigned long long we can
trivially support files with more than INT_MAX lines.
ok millert@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cat/cat.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 1f2208bf74b..1b09d4f8493 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cat.c,v 1.30 2020/12/04 02:25:56 cheloha Exp $ */ +/* $OpenBSD: cat.c,v 1.31 2020/12/11 05:48:22 cheloha Exp $ */ /* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */ /* @@ -132,7 +132,8 @@ cook_args(char **argv) void cook_buf(FILE *fp, const char *filename) { - int ch, gobble, line, prev; + unsigned long long line; + int ch, gobble, prev; line = gobble = 0; for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) { @@ -147,7 +148,7 @@ cook_buf(FILE *fp, const char *filename) } if (nflag) { if (!bflag || ch != '\n') { - (void)fprintf(stdout, "%6d\t", ++line); + fprintf(stdout, "%6llu\t", ++line); if (ferror(stdout)) break; } else if (eflag) { |