uniq(1): support arbitrarily long input lines
authorcheloha <cheloha@openbsd.org>
Mon, 1 Nov 2021 23:20:35 +0000 (23:20 +0000)
committercheloha <cheloha@openbsd.org>
Mon, 1 Nov 2021 23:20:35 +0000 (23:20 +0000)
commit9fe74df546332ef43334a67dc13d55e6392d6549
treec3221dec3e9871c7c2b8dc818e67a1b4ca7fc7fc
parent838f0b6de4538105536e21117faea8e09e76a8f7
uniq(1): support arbitrarily long input lines

Switch from fgets(3) to getline(3) to support input lines of any
length.

Tested by sthen@, who uncovered a dumb bug that cut throughput in
half.  getline(3) is indeed slower than fgets(3), but not *twice* as
slow.

millert@ suggests that preallocating both line buffers might be
worthwhile.  I will need to do some additional testing to figure out
whether 8KB buffers (like we had for fgets(3)) are appropriate
starting lengths.  For now I am not preallocating either buffer.

ok millert@ sthen@
usr.bin/uniq/uniq.c