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 | 52965a080109f8b03028dacac26f09ddb7cb84fe (patch) | |
tree | e89e48e0116e9eac1f33ac089083a7391a71d0f4 | |
parent | 072d25ea52a932a115c9ec892dbb8fd138fd8821 (diff) | |
download | vim-52965a080109f8b03028dacac26f09ddb7cb84fe.tar.gz |
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)
-rw-r--r-- | src/fileio.c | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c index 47814fab..319c7ba9 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 */ diff --git a/src/version.c b/src/version.c index 3d493b05..0c200411 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 635, +/**/ 634, /**/ 633, |