insert-file-contents 1 KiB seek fix
This improves on recent fixes to Bug#77315.
When sampling the first 1 KiB and last 3 KiB, do not seek before
BEG if given. Instead, sample starting at BEG, to be consistent
with the non-optimized version.
* src/fileio.c (xlseek): Return POS, for convenience.
(Finsert_file_contents): Sample the first 1 KiB correctly when BEG.
In a CURPOS local, keep track of the input file offset, or for
nonseekable files the number of bytes read, while this value is
important. This lets us avoid some unnecessary seeks. Report an
error earlier if the file is not seekable and BEG is nonzero,
to save work and simplify the code. When sampling, discard less
data, as this is simpler and there’s little point to discarding it.
(cherry picked from commit
2903b0b92cfdf87fbbb764c4f202479e9a1ac941)