coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

head: fix bug with non-terminated files.

Open karlmcdowall opened this issue 10 months ago • 3 comments

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).

karlmcdowall avatar Mar 18 '25 18:03 karlmcdowall

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)

github-actions[bot] avatar Mar 18 '25 19:03 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Mar 18 '25 20:03 github-actions[bot]

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!

github-actions[bot] avatar Mar 19 '25 16:03 github-actions[bot]

GNU testsuite comparison:

Congrats! The gnu test tests/misc/stdbuf is no longer failing!

github-actions[bot] avatar Mar 22 '25 22:03 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Mar 25 '25 20:03 github-actions[bot]