lalitmetkar / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

[patch] Non-empty file without EOL markers should use default fileformat instead of mac. #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. echo -n oneline > oneline.txt
2. echo "ffs=unix,dos,mac" >> ~/.vimrc
3. vim oneline.txt
4. set ff?

What is the expected output? What do you see instead?
Expected: "  fileformat=unix"
Currently: "  fileformat=mac"

On Windows, with ffs=dos,unix,mac instead, I expect to see "  fileformat=dos" 
but still see "  fileformat=mac".

What version of the product are you using? On what operating system?

Verified with version 7.3.154+hg~74503f6ee649-2ubuntu3.1 from Ubuntu, and with 
v7-3-608 built from the hg repository, on Ubuntu 11.10 Oneiric Ocelot.

Please provide any additional information below.

The three patches included each solve the problem, but in slightly different 
ways; choose only one.  The -minimal patch includes just enough to fix this 
issue, without affecting anything else.

The -rewrite and -macpref patches, on the other hand, rewrite the scanning 
logic to use at most one scan and to repair a related issue where mac would be 
preferred over unix for long dos-format files when ff=unix,mac and the <CR><NL> 
pair gets split up by the buffer boundary.  The difference between the two 
patches is whether mac or dos is preferred when there are more <CR><NL> pairs 
than bare carriage returns.  However, both now prefer mac over dos when there 
are more bare carriage returns than <CR><NL> pairs, which is a change from the 
current version; they can probably be modified to remove even that difference, 
though.

Original issue reported on code.google.com by esw...@gmail.com on 20 Jul 2012 at 7:41

Attachments:

GoogleCodeExporter commented 9 years ago
Revised reproduction steps:

1. echo -n "set ffs=unix,dos,mac" > oneline.txt
2. vim -u oneline.txt oneline.txt
3. set ff?

Original comment by esw...@gmail.com on 5 Nov 2012 at 9:36

GoogleCodeExporter commented 9 years ago

Original comment by chrisbr...@googlemail.com on 9 Jan 2015 at 12:16

GoogleCodeExporter commented 9 years ago
Issue 331 has been merged into this issue.

Original comment by chrisbr...@googlemail.com on 13 Feb 2015 at 11:29

GoogleCodeExporter commented 9 years ago
Updated minimal patch available at 
https://github.com/chrisbra/vim-mq-patches/blob/master/issue71_minimal

(okay, the name is misleading. I thought it was issue71)....

Original comment by chrisbr...@googlemail.com on 13 Feb 2015 at 5:57

GoogleCodeExporter commented 9 years ago
included and Fixed by 7.4.635

Original comment by chrisbr...@googlemail.com on 17 Feb 2015 at 3:34

GoogleCodeExporter commented 9 years ago
Moving the try_mac reset to inside the for loop seems to defeat its purpose, 
making mac format (nearly) impossible to choose if unix or dos is listed first 
in ffs.  Was that intended?

Original comment by esw...@gmail.com on 17 Feb 2015 at 7:13

GoogleCodeExporter commented 9 years ago
Can you give an example of where you would expect mac format to be detected but 
it doesn't work?

Original comment by brammool...@gmail.com on 19 Feb 2015 at 7:26

GoogleCodeExporter commented 9 years ago
Any file that either a) doesn't end with a carriage return, or b) is larger 
than the initial read buffer, and doesn't happen to have a carriage return in 
exactly the right place.  For example:

$ printf 'one\rtwo\rthree' > maclines
$ echo 'set ffs=dos,mac' > vimrc
$ vim -u vimrc maclines

As of version 7.4.640, this file is set to dos format; the attached patch 
(issue-77-repair.diff) fixes this.

I apologize for failing to notice the subtle difference between the original 
and updated minimal patches before it was merged.

Original comment by esw...@gmail.com on 20 Feb 2015 at 12:55

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch.  Can you please add a test for what you are fixing?
It probably fits in test30.

Original comment by brammool...@gmail.com on 20 Feb 2015 at 6:50

GoogleCodeExporter commented 9 years ago
> I apologize for failing to notice the subtle difference between the original 
and updated minimal patches before it was merged.

That might have been my fault. I had to merge this manually, as the patch did 
not apply cleanly and I might have made a mistake here. I apologize for that.

Original comment by chrisbr...@googlemail.com on 20 Feb 2015 at 9:06

GoogleCodeExporter commented 9 years ago
Patch with test cases for both the original problem and the new problem.  I've 
also highlighted a related potential issue in the existing cases, where a file 
with Unix and Mac line endings will be set to Dos format when ffs=dos,mac; is 
that intended?

Original comment by esw...@gmail.com on 21 Feb 2015 at 1:28

Attachments: