diff src/ex_docmd.c @ 30604:9d7914012b82 v9.0.0637

patch 9.0.0637: syntax of commands in Vim9 script depends on +eval feature Commit: https://github.com/vim/vim/commit/eda29c971c0592d85c5856da7708f3edfdc54cfa Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 2 12:59:00 2022 +0100 patch 9.0.0637: syntax of commands in Vim9 script depends on +eval feature Problem: Syntax of commands in Vim9 script depends on +eval feature. Solution: Use same syntax with and without the +eval feature.
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Oct 2022 14:00:09 +0200
parents 37aa9fd2ed72
children 101f08b49ed3
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1684,10 +1684,8 @@ current_tab_nr(tabpage_T *tab)
     static int
 comment_start(char_u *p, int starts_with_colon UNUSED)
 {
-#ifdef FEAT_EVAL
     if (in_vim9script())
 	return p[0] == '#' && !starts_with_colon;
-#endif
     return *p == '"';
 }
 
@@ -1736,9 +1734,9 @@ do_one_cmd(
     int		ni;			// set when Not Implemented
     char_u	*cmd;
     int		starts_with_colon = FALSE;
-#ifdef FEAT_EVAL
     int		may_have_range;
     int		vim9script;
+#ifdef FEAT_EVAL
     int		did_set_expr_line = FALSE;
 #endif
     int		sourcing = flags & DOCMD_VERBOSE;
@@ -1787,9 +1785,6 @@ do_one_cmd(
     if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)
 	goto doend;
     apply_cmdmod(&cmdmod);
-#ifdef FEAT_EVAL
-    vim9script = in_vim9script();
-#endif
     after_modifier = ea.cmd;
 
 #ifdef FEAT_EVAL
@@ -1805,9 +1800,10 @@ do_one_cmd(
  * We need the command to know what kind of range it uses.
  */
     cmd = ea.cmd;
-#ifdef FEAT_EVAL
+
     // In Vim9 script a colon is required before the range.  This may also be
     // after command modifiers.
+    vim9script = in_vim9script();
     if (vim9script && (flags & DOCMD_RANGEOK) == 0)
     {
 	may_have_range = FALSE;
@@ -1822,16 +1818,18 @@ do_one_cmd(
     else
 	may_have_range = TRUE;
     if (may_have_range)
-#endif
 	ea.cmd = skip_range(ea.cmd, TRUE, NULL);
 
-#ifdef FEAT_EVAL
     if (vim9script && !may_have_range)
     {
 	if (ea.cmd == cmd + 1 && *cmd == '$')
 	    // should be "$VAR = val"
 	    --ea.cmd;
+#ifdef FEAT_EVAL
 	p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
+#else
+	p = find_ex_command(&ea, NULL, NULL, NULL);
+#endif
 	if (ea.cmdidx == CMD_SIZE)
 	{
 	    char_u *ar = skip_range(ea.cmd, TRUE, NULL);
@@ -1846,7 +1844,6 @@ do_one_cmd(
 	}
     }
     else
-#endif
 	p = find_ex_command(&ea, NULL, NULL, NULL);
 
 #ifdef FEAT_EVAL
@@ -1930,13 +1927,10 @@ do_one_cmd(
     }
 
     ea.cmd = cmd;
-#ifdef FEAT_EVAL
     if (!may_have_range)
 	ea.line1 = ea.line2 = default_address(&ea);
-    else
-#endif
-	if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
-	    goto doend;
+    else if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
+	goto doend;
 
 /*
  * 5. Parse the command.
@@ -5275,24 +5269,20 @@ separate_nextcmd(exarg_T *eap, int keep_
 	}
 #endif
 
-	// Check for '"': start of comment or '|': next command
+	// Check for '"'/'#': start of comment or '|': next command
 	// :@" and :*" do not start a comment!
 	// :redir @" doesn't either.
 	else if ((*p == '"'
-#ifdef FEAT_EVAL
 		    && !in_vim9script()
-#endif
 		    && !(eap->argt & EX_NOTRLCOM)
 		    && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
 							      || p != eap->arg)
 		    && (eap->cmdidx != CMD_redir
 					 || p != eap->arg + 1 || p[-1] != '@'))
-#ifdef FEAT_EVAL
 		|| (*p == '#'
 		    && in_vim9script()
 		    && !(eap->argt & EX_NOTRLCOM)
 		    && p > eap->cmd && VIM_ISWHITE(p[-1]))
-#endif
 		|| *p == '|' || *p == '\n')
 	{
 	    /*
@@ -5636,10 +5626,8 @@ ends_excmd(int c)
 {
     int comment_char = '"';
 
-#ifdef FEAT_EVAL
     if (in_vim9script())
 	comment_char = '#';
-#endif
     return (c == NUL || c == '|' || c == comment_char || c == '\n');
 }
 
@@ -5654,12 +5642,10 @@ ends_excmd2(char_u *cmd_start UNUSED, ch
 
     if (c == NUL || c == '|' || c == '\n')
 	return TRUE;
-#ifdef FEAT_EVAL
     if (in_vim9script())
 	//  # starts a comment, #{ might be a mistake, #{{ can start a fold
 	return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
 				 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
-#endif
     return c == '"';
 }