nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit fe94999c1c97943dd98bb11fc4d274bf130b09f8
parent 56bf29409bff312aae743876a78d279c65d2f892
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 13 May 2020 10:31:39 +0200

tweaks: don't bother overwriting a CR -- decreasing the length is enough

The string of bytes get properly terminated by encode_data(); there is
no need to do that earlier.

Diffstat:
Msrc/files.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -682,14 +682,14 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) if (input == '\n') { #ifndef NANO_TINY if (len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) { - buf[--len] = '\0'; if (num_lines == 0) format = 1; + len--; } } else if ((num_lines == 0 || format == 2) && !ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r') { - buf[--len] = '\0'; format = 2; + len--; #endif } else { /* Store the byte. */