mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
565f118f8c
sort -m takes: 3 lines, 96003 bytes and emits: 4 lines, 96004 bytes The output line lengths before the fix are: ``` a x 32000 b x 23809 b x 8191 c x 32000 ``` So it splits one of the lines into two (23809 + 8191 = 32000). In addition, the output becomes unsorted because the shorter 'b' fragment sorts before the longer 'b' fragment. The issue is that in `chunks.rs`, `sep_iter` is relatve to `search_start`. But the returned value needs to be absolute position relative to the `buffer`. We end up with these particular numbers because - in merge.rs, initial chunk is created as `RecycledChunk::new(8 * 1024)` (8192 bytes) - `search_start = 8192`; newline is at absolute buffer index `32000` - `memchr_iter` returns `32000 - 8192 = 23808`, and newline adds + 1 byte