nano

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

commit ff4973458ca325f40ab96ba5188d40c798e94b92
parent f9ff902bbc18fa599e8690556fad70880f8dc25f
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 11 May 2020 15:32:41 +0200

tweaks: adjust the file format indicator in a quicker way

Diffstat:
Msrc/files.c | 9+++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -688,8 +688,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) * handle it! */ if ((num_lines == 0 || format != 0) && !ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r') { - if (format == 0 || format == 2) - format++; + format |= 1; } /* If it's a Mac file ('\r' without '\n' on the first line if we * think it's a *nix file, or on any line otherwise), and file @@ -699,8 +698,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) /* If we currently think the file is a *nix file, set format * to Mac. If we currently think the file is a DOS file, * set format to both DOS and Mac. */ - if (format == 0 || format == 1) - format += 2; + format |= 2; #endif } else { /* Store the character. */ @@ -780,8 +778,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) * set format to Mac if we currently think the file is a *nix file, or * to DOS-and-Mac if we currently think it is a DOS file. */ if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) { - if (format < 2) - format += 2; + format |= 2; /* Strip the carriage return. */ buf[--len] = '\0';