> Tony's right; try it with a broken DOS-format file - line 1 ends \r\n,
> line 2 \n.
> echo -n "a\r\nb\n" >tmp/testfile
Thanks, Matt and Tony, for the explanation. Now I see the problem.
> However, I also can't find any reference to this behavior in the help,
> and it definitely strikes me as a bug - I can't see why you'd ever
> want autodetection to override a manual decision from the user. One
> more question for Bram when he gets back, I guess.
I agree completely. Here are two patches, both of which fix the problem
(and applying both will doubly fix it, I guess, but is certainly
overkill). Bram can choose to apply one, or roll his own, presuming he
also believes this is a bug, but I think anyone would have a hard time
arguing that it isn't! Regarding the first patch, actually (as can be
seen from the second patch) only the change to try_unix is relevant, but
the logic makes sense to apply to all three. (I prefer the first patch
as it readably demonstrates the logic of the behaviour we want to see,
unlike the second which is more of a hack to fix the bug.)
If you could send me a reply when you see this, Bram, that'd be good,
just so I know it's in the pipeline.
Smiles,
Ben.
diff -r b5612f1e2b6c src/fileio.c
--- a/src/fileio.c Mon Oct 06 23:20:05 2008 +1100
+++ b/src/fileio.c Thu Oct 23 00:44:20 2008 +1100
@@ -261,9 +261,12 @@
int msg_save = msg_scroll;
linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of
* last read was missing the eol */
- int try_mac = (vim_strchr(p_ffs, 'm') != NULL);
- int try_dos = (vim_strchr(p_ffs, 'd') != NULL);
- int try_unix = (vim_strchr(p_ffs, 'x') != NULL);
+ int try_mac = (vim_strchr(p_ffs, 'm') != NULL) &&
+ (eap == NULL || eap->force_ff == 0);
+ int try_dos = (vim_strchr(p_ffs, 'd') != NULL) &&
+ (eap == NULL || eap->force_ff == 0);
+ int try_unix = (vim_strchr(p_ffs, 'x') != NULL) &&
+ (eap == NULL || eap->force_ff == 0);
int file_rewind = FALSE;
#ifdef FEAT_MBYTE
int can_retry;
diff -r b5612f1e2b6c src/fileio.c
--- a/src/fileio.c Mon Oct 06 23:20:05 2008 +1100
+++ b/src/fileio.c Thu Oct 23 00:48:52 2008 +1100
@@ -2111,6 +2111,7 @@
else if (ff_error != EOL_DOS)
{
if ( try_unix
+ && (eap == NULL || eap->force_ff == 0)
&& !read_stdin
&& (read_buffer
|| lseek(fd, (off_t)0L, SEEK_SET) == 0))
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---