commit ac0f2c94850b9a798bef73f5651f55496ff9fa58
parent 0a1817e8934bed90b69eb5fb277597c14037d8bd
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 12 May 2020 16:39:18 +0200
files: do not let a stray CR in a DOS file trigger Mac format
Only when a CR is seen before any LF, and the CR is not followed
by a LF, should this CR be interpreted as a line separator. And
only then the file should be reported as being in Mac format --
as long as --noconvert is not used.
This fixes https://savannah.gnu.org/bugs/?58357.
Bug existed since at least version 2.0.6.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/files.c b/src/files.c
@@ -683,7 +683,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
if ((num_lines == 0 || format != 0) && !ISSET(NO_CONVERT) &&
len > 0 && buf[len - 1] == '\r')
format |= 1;
- } else if ((num_lines == 0 || format != 0) && !ISSET(NO_CONVERT) &&
+ } else if ((num_lines == 0 || format == 2) && !ISSET(NO_CONVERT) &&
len > 0 && buf[len - 1] == '\r') {
format |= 2;
#endif