]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4515: old subsitute syntax is still supported v8.2.4515
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Mar 2022 21:13:26 +0000 (21:13 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Mar 2022 21:13:26 +0000 (21:13 +0000)
Problem:    Old subsitute syntax is still supported.
Solution:   Disallow using backslash after ":s" in Vim9 script.

src/errors.h
src/ex_cmds.c
src/testdir/test_substitute.vim
src/version.c

index e302ecc6ed22ab6602e15cb5411ac6b6cbfa1978..6f275fa41262c17ef95d9be53a17a36519e80267 100644 (file)
@@ -3246,4 +3246,6 @@ EXTERN char e_cannot_use_s_colon_in_vim9_script_str[]
        INIT(= N_("E1268: Cannot use s: in Vim9 script: %s"));
 EXTERN char e_cannot_create_vim9_script_variable_in_function_str[]
        INIT(= N_("E1269: Cannot create a Vim9 script variable in a function: %s"));
+EXTERN char e_cannot_use_s_backslash_in_vim9_script[]
+       INIT(= N_("E1270: Cannot use :s\\/sub/ in Vim9 script"));
 #endif
index d926df5361ecdfc790ca44fc05a2656fb913d9ee..13cde84fd8466f393b2b2a1205467ed83ce800ce 100644 (file)
@@ -3737,6 +3737,11 @@ ex_substitute(exarg_T *eap)
         */
        if (*cmd == '\\')
        {
+           if (in_vim9script())
+           {
+               emsg(_(e_cannot_use_s_backslash_in_vim9_script));
+               return;
+           }
            ++cmd;
            if (vim_strchr((char_u *)"/?&", *cmd) == NULL)
            {
index 35b6b8a0245d39e3d1f38dda11ba067fd08e7409..262274928165c9ed3091172603447c322ec637a4 100644 (file)
@@ -811,6 +811,10 @@ func Test_sub_vi_compatibility()
   s\&green&
   call assert_equal('amber green yellow white green', getline(1))
   close!
+
+  call assert_fails('vim9cmd s\/white/', 'E1270:')
+  call assert_fails('vim9cmd s\?white?', 'E1270:')
+  call assert_fails('vim9cmd s\&white&', 'E1270:')
 endfunc
 
 " Test for substitute with the new text longer than the original text
index 238e6278e0d3694167b13c8ba21aebda11fbe197..4bbe08ce78296be49fa39d7610435ccf70daa7ad 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4515,
 /**/
     4514,
 /**/