" Tests for the substitute (:s) command
source shared.vim
source check.vim
source screendump.vim
" NOTE: This needs to be the first test to be
" run in the file, since it depends on
" that the previous substitution atom
" was not yet set.
"
" recursive call of :s and sub-replace special
" (did cause heap-use-after free in < v9.0.2121)
func Test_aaaa_substitute_expr_recursive_special()
func R()
" FIXME: leaving out the 'n' flag leaks memory, why?
%s/./\='.'/gn
endfunc
new Xfoobar_UAF
put ='abcdef'
let bufnr = bufnr('%')
try
silent! :s/./~\=R()/0
"call assert_fails(':s/./~\=R()/0', 'E939:')
let @/='.'
~g
catch /^Vim\%((\a\+)\)\=:E565:/
endtry
delfunc R
exe bufnr .. "bw!"
endfunc
func Test_multiline_subst()
enew!
call append(0, ["1 aa",
\ "bb",
\ "cc",
\ "2 dd",
\ "ee",
\ "3 ef",
\ "gh",
\ "4 ij",
\ "5 a8",
\ "8b c9",
\ "9d",
\ "6 e7",
\ "77f",
\ "xxxxx"])
1
" test if replacing a line break works with a back reference
/^1/,/^2/s/\n\(.\)/ \