]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1876: Vim9: parsing commands with newlines wrong v9.0.1876
authorChristian Brabandt <cb@256bit.org>
Tue, 5 Sep 2023 18:46:25 +0000 (20:46 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 5 Sep 2023 18:53:46 +0000 (20:53 +0200)
Problem:  Vim9: parsing commands with newlines wrong
Solution: Accept a '\n' for parsing lists and command arguments

closes: #13015
closes: #13020

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_docmd.c
src/list.c
src/macros.h
src/testdir/test_crash.vim
src/testdir/test_usercommands.vim
src/userfunc.c
src/version.c

index 10d979d493ac7c66a2f808c9369bcbeb84d27fd1..d4b972a2ef44ad647bff6a715d85f7ac699b8c6c 100644 (file)
@@ -3954,7 +3954,7 @@ find_ex_command(
 #ifdef FEAT_EVAL
     if (eap->cmdidx < CMD_SIZE
            && vim9
-           && !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!' && *p != '|'
+           && !IS_WHITE_NL_OR_NUL(*p) && *p != '!' && *p != '|'
            && (eap->cmdidx < 0 ||
                (cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
     {
index 6210fd63806da17cf3ba697952e744c8ab49475a..d1494c67d56e92119030bea4879fbfaf2f9811e5 100644 (file)
@@ -1592,7 +1592,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
        had_comma = **arg == ',';
        if (had_comma)
        {
-           if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]) && (*arg)[1] != ']')
+           if (vim9script && !IS_WHITE_NL_OR_NUL((*arg)[1]) && (*arg)[1] != ']')
            {
                semsg(_(e_white_space_required_after_str_str), ",", *arg);
                goto failret;
index b41a81827e85b96e2c2229a07e491397a05b1d22..d86097ced3a526a83d38ef233b168f88d373d82e 100644 (file)
@@ -43,6 +43,7 @@
  */
 #define VIM_ISWHITE(x)         ((x) == ' ' || (x) == '\t')
 #define IS_WHITE_OR_NUL(x)     ((x) == ' ' || (x) == '\t' || (x) == NUL)
+#define IS_WHITE_NL_OR_NUL(x)  ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == NUL)
 
 /*
  * LINEEMPTY() - return TRUE if the line is empty
index f7b528c3e98d7488084d47fdb1dc8a385bfee614..aa30684291c9cd567970ac98e83920a5b43a7ed7 100644 (file)
@@ -62,7 +62,6 @@ func Test_crash1()
 
   let file = 'crash/vim_regsub_both_poc'
   let args = printf(cmn_args, vim, file)
-  " using || because this poc causes vim to exit with exitstatus != 0
   call term_sendkeys(buf, args ..
     \ '  && echo "crash 7: [OK]" >> X_crash1_result.txt' .. "\<cr>")
   call TermWait(buf, 1000)
index 1e1856727a78ca145a381b4691df95daacfc9806..e161ee63fe6d2c688c5668cd65ea90390173dd2b 100644 (file)
@@ -772,6 +772,33 @@ func Test_usercmd_with_block()
   END
   call v9.CheckScriptFailure(lines, 'E1128:')
   delcommand BadCommand
+
+  let lines =<< trim END
+         vim9script
+    command Cmd {
+        g:result = [1,
+        2]
+    }
+    Cmd
+  END
+  call v9.CheckScriptSuccess(lines)
+  call assert_equal([1, 2], g:result)
+  delcommand Cmd
+       unlet! g:result
+
+  let lines =<< trim END
+               vim9script
+               command Cmd {
+                       g:result = and(0x80,
+                       0x80)
+    }
+    Cmd
+  END
+  call v9.CheckScriptSuccess(lines)
+  call assert_equal(128, g:result)
+  delcommand Cmd
+       unlet! g:result
+
 endfunc
 
 func Test_delcommand_buffer()
index 0ebd61872de87387d8016d561a4ac7ca5e19c185..6638849dbb43650e556e7a40000d6534e773b4bb 100644 (file)
@@ -1879,7 +1879,7 @@ get_func_arguments(
            argp = skipwhite(argp);
        if (*argp != ',')
            break;
-       if (vim9script && !IS_WHITE_OR_NUL(argp[1]))
+       if (vim9script && !IS_WHITE_NL_OR_NUL(argp[1]))
        {
            if (evaluate)
                semsg(_(e_white_space_required_after_str_str), ",", argp);
index f09039c64df19ffc4c9a9cbb7e86954752383990..db11876b30e720f889c600880ca3b6208faa6d2e 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1876,
 /**/
     1875,
 /**/