Re: head(1): increase line count maximum to LLONG_MAX
> On Oct 11, 2021, at 10:08 AM, Todd C. Miller wrote: > > On Sun, 10 Oct 2021 19:13:55 -0500, Scott Cheloha wrote: > >> This unifies the input maximums on 32-bit and 64-bit platforms. > > This really feels like a solution in search of a problem. However unlikely large files are, there is a history in our tree of increasing input limits to transparently support large(r) files: cat(1) (ok millert@): https://github.com/openbsd/src/commit/8d576c92c5d93d1e61ef1d918cae5fa9a9421c10 dd(1) (ok millert@): https://github.com/openbsd/src/commit/5a04faeb71440b1f24533a07e5230c7d4655f7da#diff-1b1e72ca344d152a8a9e82bd3f4ad570cc3d08d175b2a47aa9b3b271ed789928 tail(1) (ok millert@): https://github.com/openbsd/src/commit/c830e4ad7782508f7f7111bb524ecc767949e215 wc(1) (commited by millert@): https://github.com/openbsd/src/commit/5ca607faa74cf42c55020844f84274a2224f2481 -- I'll probably do nl(1) in the near future. It still counts lines with an int. nl(1) is trickier, though. Many more variables involved. head(1), in constrast, is trivial.
Re: head(1): increase line count maximum to LLONG_MAX
On Sun, 10 Oct 2021 19:13:55 -0500, Scott Cheloha wrote: > This unifies the input maximums on 32-bit and 64-bit platforms. This really feels like a solution in search of a problem. - todd
head(1): increase line count maximum to LLONG_MAX
This unifies the input maximums on 32-bit and 64-bit platforms. ok? Index: head.c === RCS file: /cvs/src/usr.bin/head/head.c,v retrieving revision 1.22 diff -u -p -r1.22 head.c --- head.c 10 Oct 2021 15:57:25 - 1.22 +++ head.c 11 Oct 2021 00:09:31 - @@ -50,9 +50,9 @@ main(int argc, char *argv[]) { const char *errstr; FILE*fp; - longcnt; + long long cnt; int ch, firsttime; - longlinecnt = 10; + long long linecnt = 10; int status = 0; if (pledge("stdio rpath", NULL) == -1) @@ -61,7 +61,7 @@ main(int argc, char *argv[]) /* handle obsolete -number syntax */ if (argc > 1 && argv[1][0] == '-' && isdigit((unsigned char)argv[1][1])) { - linecnt = strtonum(argv[1] + 1, 1, LONG_MAX, ); + linecnt = strtonum(argv[1] + 1, 1, LLONG_MAX, ); if (errstr != NULL) errx(1, "count is %s: %s", errstr, argv[1] + 1); argc--; @@ -71,7 +71,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "n:")) != -1) { switch (ch) { case 'n': - linecnt = strtonum(optarg, 1, LONG_MAX, ); + linecnt = strtonum(optarg, 1, LLONG_MAX, ); if (errstr != NULL) errx(1, "count is %s: %s", errstr, optarg); break;