cat: with -E fix handling of \r\n spanning buffers
commita574283c7ab6f9b506a324f83e28fe9a6064eddd
authorPádraig Brady <P@draigBrady.com>
Sat, 7 Aug 2021 17:47:57 +0000 (7 18:47 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 7 Aug 2021 23:09:38 +0000 (8 00:09 +0100)
treea28df38f7943027aba6d02ccac2a5ab74dff3344
parent02fc0e3f683f3858513c7c7226d30503e7f7ec97
cat: with -E fix handling of \r\n spanning buffers

We must delay handling when \r is the last character
of the buffer being processed, as the next character
may or may not be \n.

* src/cat.c (pending_cr): A new global to record whether
the last character processed (in -E mode) is '\r'.
(cat): Honor pending_cr when processing the start of the buffer.
(main): Honor pending_cr if no more files to process.
* tests/misc/cat-E.sh: Add test cases.
Fixes https://bugs.gnu.org/49925
src/cat.c
tests/misc/cat-E.sh