diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-02-17 14:15:19 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-02-17 14:15:19 +0100 |
commit | 05eb612ff3597fb7102f892bfd320f28b56d2fc6 (patch) | |
tree | 0b406f7ef1805f4d607c266bbe189b3fb6e0a87c /src/fileio.c | |
parent | f65aad5554f1d1f972f0bd38059da70e3cdf4c87 (diff) | |
download | vim-git-05eb612ff3597fb7102f892bfd320f28b56d2fc6.tar.gz |
updated for version 7.4.635v7.4.635
Problem: If no NL or CR is found in the first block of a file then the
'fileformat' may be set to "mac". (Issue 77)
Solution: Check if a CR was found. (eswald)
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c index 47814fab9..319c7ba97 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2101,6 +2101,10 @@ rewind_retry: { for (p = ptr; p < ptr + size; ++p) { + /* Reset the carriage return counter. */ + if (try_mac) + try_mac = 1; + if (*p == NL) { if (!try_unix @@ -2110,6 +2114,8 @@ rewind_retry: fileformat = EOL_UNIX; break; } + else if (*p == CAR && try_mac) + try_mac++; } /* Don't give in to EOL_UNIX if EOL_MAC is more likely */ @@ -2133,6 +2139,10 @@ rewind_retry: fileformat = EOL_MAC; } } + else if (fileformat == EOL_UNKNOWN && try_mac == 1) + /* Looking for CR but found no end-of-line markers at + * all: use the default format. */ + fileformat = default_fileformat(); } /* No NL found: may use Mac format */ |