head: fix bug with non-terminated files.
Fixes #7472. Update to head app when printing all-but-last-n-lines of a file. Code now checks if the last line of the input file is missing a terminating newline character, and if so prints an extra line in the output. This aligns with GNU-head behavior.
Also made a change to improve performance of this usecase by using an optimized iterator (memchr-iter) for searching through the input file (gives a ~25% improvement for head -n -100000 ./shakespeare.txt vs the current mainline tip).
GNU testsuite comparison:
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
GNU testsuite comparison:
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
GNU testsuite comparison:
Congrats! The gnu test misc/stdbuf.log is no longer failing!
Congrats! The gnu test timeout/timeout.log is no longer failing!
GNU testsuite comparison:
Congrats! The gnu test tests/misc/stdbuf is no longer failing!
GNU testsuite comparison:
Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)