annotate src/testdir/test_fileformat.vim @ 10674:d6857a8dc07e v8.0.0227

patch 8.0.0227: crash with ff=dos when first line in file has no CR commit https://github.com/vim/vim/commit/2aa5f696b91a51f29873e340de4bdc182e1e8dd4 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 24 15:46:48 2017 +0100 patch 8.0.0227: crash with ff=dos when first line in file has no CR Problem: Crash when 'fileformat' is forced to "dos" and the first line in the file is empty and does not have a CR character. Solution: Don't check for CR before the start of the buffer.
author Christian Brabandt <cb@256bit.org>
date Tue, 24 Jan 2017 16:00:05 +0100
parents 0a6c66a06fdb
children 140bf183f946
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10268
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test behavior of fileformat after bwipeout of last buffer
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_fileformat_after_bw()
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 bwipeout
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 set fileformat&
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 if &fileformat == 'dos'
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 let test_fileformats = 'unix'
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 elseif &fileformat == 'unix'
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let test_fileformats = 'mac'
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 else " must be mac
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let test_fileformats = 'dos'
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 endif
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 exec 'set fileformats='.test_fileformats
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 bwipeout!
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(test_fileformats, &fileformat)
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 set fileformats&
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 endfunc
10668
6a252c6afd5b patch 8.0.0224: change to 'fileformats' from autocmd does not take effect
Christian Brabandt <cb@256bit.org>
parents: 10268
diff changeset
18
6a252c6afd5b patch 8.0.0224: change to 'fileformats' from autocmd does not take effect
Christian Brabandt <cb@256bit.org>
parents: 10268
diff changeset
19 func Test_fileformat_autocommand()
10674
d6857a8dc07e patch 8.0.0227: crash with ff=dos when first line in file has no CR
Christian Brabandt <cb@256bit.org>
parents: 10672
diff changeset
20 let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
10672
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
21 let ffs = &ffs
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
22 call writefile(filecnt, 'Xfile', 'b')
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
23 au BufReadPre Xfile set ffs=dos ff=dos
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
24 new Xfile
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
25 call assert_equal('dos', &l:ff)
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
26 call assert_equal('dos', &ffs)
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
27
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
28 " cleanup
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
29 call delete('Xfile')
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
30 let &ffs = ffs
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
31 au! BufReadPre Xfile
0a6c66a06fdb patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Christian Brabandt <cb@256bit.org>
parents: 10668
diff changeset
32 bw!
10668
6a252c6afd5b patch 8.0.0224: change to 'fileformats' from autocmd does not take effect
Christian Brabandt <cb@256bit.org>
parents: 10268
diff changeset
33 endfunc