• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision9d7914012b82458f96040d654ce090e2b3cda8ef (tree)
Time2022-10-02 21:00:09
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

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.

Change Summary

Incremental Difference

diff -r 827c77642cb1 -r 9d7914012b82 src/errors.h
--- a/src/errors.h Sat Oct 01 22:30:04 2022 +0200
+++ b/src/errors.h Sun Oct 02 14:00:09 2022 +0200
@@ -2713,8 +2713,10 @@
27132713 INIT(= N_("E1048: Item not found in script: %s"));
27142714 EXTERN char e_item_not_exported_in_script_str[]
27152715 INIT(= N_("E1049: Item not exported in script: %s"));
2716+#endif
27162717 EXTERN char e_colon_required_before_range_str[]
27172718 INIT(= N_("E1050: Colon required before a range: %s"));
2719+#ifdef FEAT_EVAL
27182720 EXTERN char e_wrong_argument_type_for_plus[]
27192721 INIT(= N_("E1051: Wrong argument type for +"));
27202722 EXTERN char e_cannot_declare_an_option[]
diff -r 827c77642cb1 -r 9d7914012b82 src/ex_docmd.c
--- a/src/ex_docmd.c Sat Oct 01 22:30:04 2022 +0200
+++ b/src/ex_docmd.c Sun Oct 02 14:00:09 2022 +0200
@@ -1684,10 +1684,8 @@
16841684 static int
16851685 comment_start(char_u *p, int starts_with_colon UNUSED)
16861686 {
1687-#ifdef FEAT_EVAL
16881687 if (in_vim9script())
16891688 return p[0] == '#' && !starts_with_colon;
1690-#endif
16911689 return *p == '"';
16921690 }
16931691
@@ -1736,9 +1734,9 @@
17361734 int ni; // set when Not Implemented
17371735 char_u *cmd;
17381736 int starts_with_colon = FALSE;
1739-#ifdef FEAT_EVAL
17401737 int may_have_range;
17411738 int vim9script;
1739+#ifdef FEAT_EVAL
17421740 int did_set_expr_line = FALSE;
17431741 #endif
17441742 int sourcing = flags & DOCMD_VERBOSE;
@@ -1787,9 +1785,6 @@
17871785 if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)
17881786 goto doend;
17891787 apply_cmdmod(&cmdmod);
1790-#ifdef FEAT_EVAL
1791- vim9script = in_vim9script();
1792-#endif
17931788 after_modifier = ea.cmd;
17941789
17951790 #ifdef FEAT_EVAL
@@ -1805,9 +1800,10 @@
18051800 * We need the command to know what kind of range it uses.
18061801 */
18071802 cmd = ea.cmd;
1808-#ifdef FEAT_EVAL
1803+
18091804 // In Vim9 script a colon is required before the range. This may also be
18101805 // after command modifiers.
1806+ vim9script = in_vim9script();
18111807 if (vim9script && (flags & DOCMD_RANGEOK) == 0)
18121808 {
18131809 may_have_range = FALSE;
@@ -1822,16 +1818,18 @@
18221818 else
18231819 may_have_range = TRUE;
18241820 if (may_have_range)
1825-#endif
18261821 ea.cmd = skip_range(ea.cmd, TRUE, NULL);
18271822
1828-#ifdef FEAT_EVAL
18291823 if (vim9script && !may_have_range)
18301824 {
18311825 if (ea.cmd == cmd + 1 && *cmd == '$')
18321826 // should be "$VAR = val"
18331827 --ea.cmd;
1828+#ifdef FEAT_EVAL
18341829 p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
1830+#else
1831+ p = find_ex_command(&ea, NULL, NULL, NULL);
1832+#endif
18351833 if (ea.cmdidx == CMD_SIZE)
18361834 {
18371835 char_u *ar = skip_range(ea.cmd, TRUE, NULL);
@@ -1846,7 +1844,6 @@
18461844 }
18471845 }
18481846 else
1849-#endif
18501847 p = find_ex_command(&ea, NULL, NULL, NULL);
18511848
18521849 #ifdef FEAT_EVAL
@@ -1930,13 +1927,10 @@
19301927 }
19311928
19321929 ea.cmd = cmd;
1933-#ifdef FEAT_EVAL
19341930 if (!may_have_range)
19351931 ea.line1 = ea.line2 = default_address(&ea);
1936- else
1937-#endif
1938- if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
1939- goto doend;
1932+ else if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
1933+ goto doend;
19401934
19411935 /*
19421936 * 5. Parse the command.
@@ -5275,24 +5269,20 @@
52755269 }
52765270 #endif
52775271
5278- // Check for '"': start of comment or '|': next command
5272+ // Check for '"'/'#': start of comment or '|': next command
52795273 // :@" and :*" do not start a comment!
52805274 // :redir @" doesn't either.
52815275 else if ((*p == '"'
5282-#ifdef FEAT_EVAL
52835276 && !in_vim9script()
5284-#endif
52855277 && !(eap->argt & EX_NOTRLCOM)
52865278 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
52875279 || p != eap->arg)
52885280 && (eap->cmdidx != CMD_redir
52895281 || p != eap->arg + 1 || p[-1] != '@'))
5290-#ifdef FEAT_EVAL
52915282 || (*p == '#'
52925283 && in_vim9script()
52935284 && !(eap->argt & EX_NOTRLCOM)
52945285 && p > eap->cmd && VIM_ISWHITE(p[-1]))
5295-#endif
52965286 || *p == '|' || *p == '\n')
52975287 {
52985288 /*
@@ -5636,10 +5626,8 @@
56365626 {
56375627 int comment_char = '"';
56385628
5639-#ifdef FEAT_EVAL
56405629 if (in_vim9script())
56415630 comment_char = '#';
5642-#endif
56435631 return (c == NUL || c == '|' || c == comment_char || c == '\n');
56445632 }
56455633
@@ -5654,12 +5642,10 @@
56545642
56555643 if (c == NUL || c == '|' || c == '\n')
56565644 return TRUE;
5657-#ifdef FEAT_EVAL
56585645 if (in_vim9script())
56595646 // # starts a comment, #{ might be a mistake, #{{ can start a fold
56605647 return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
56615648 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
5662-#endif
56635649 return c == '"';
56645650 }
56655651
diff -r 827c77642cb1 -r 9d7914012b82 src/testdir/Make_all.mak
--- a/src/testdir/Make_all.mak Sat Oct 01 22:30:04 2022 +0200
+++ b/src/testdir/Make_all.mak Sun Oct 02 14:00:09 2022 +0200
@@ -12,6 +12,7 @@
1212
1313 # Tests for tiny and small builds.
1414 SCRIPTS_TINY = \
15+ test10 \
1516 test20 \
1617 test21 \
1718 test22 \
@@ -22,6 +23,7 @@
2223 test27
2324
2425 SCRIPTS_TINY_OUT = \
26+ test10.out \
2527 test20.out \
2628 test21.out \
2729 test22.out \
diff -r 827c77642cb1 -r 9d7914012b82 src/testdir/test10.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test10.in Sun Oct 02 14:00:09 2022 +0200
@@ -0,0 +1,21 @@
1+Test that vim9script also works without the +eval feature.
2+
3+STARTTEST
4+:/^START/+1,/^END/-1:w! Xvim9
5+:so Xvim9
6+ENDTEST
7+
8+START
9+vim9script
10+
11+if 1
12+ echo 'this is skipped without +eval'
13+endif
14+
15+# colon required for a range
16+:$-1,$w! test.out
17+qa!
18+END
19+
20+first line
21+last line
diff -r 827c77642cb1 -r 9d7914012b82 src/testdir/test10.ok
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test10.ok Sun Oct 02 14:00:09 2022 +0200
@@ -0,0 +1,2 @@
1+first line
2+last line
diff -r 827c77642cb1 -r 9d7914012b82 src/version.c
--- a/src/version.c Sat Oct 01 22:30:04 2022 +0200
+++ b/src/version.c Sun Oct 02 14:00:09 2022 +0200
@@ -700,6 +700,8 @@
700700 static int included_patches[] =
701701 { /* Add new patch number below this line */
702702 /**/
703+ 637,
704+/**/
703705 636,
704706 /**/
705707 635,
Show on old repository browser