To: vim_dev@googlegroups.com Subject: Patch 9.0.0637 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0637 Problem: Syntax of commands in Vim9 script depends on +eval feature. Solution: Use same syntax with and without the +eval feature. Files: src/ex_docmd.c, src/errors.h, src/testdir/test10.in, src/testdir/test10.ok, src/testdir/Make_all.mak *** ../vim-9.0.0636/src/ex_docmd.c 2022-10-01 19:43:48.606494048 +0100 --- src/ex_docmd.c 2022-10-02 12:34:51.948576549 +0100 *************** *** 1684,1693 **** 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 == '"'; } --- 1684,1691 ---- *************** *** 1736,1744 **** int ni; // set when Not Implemented char_u *cmd; int starts_with_colon = FALSE; - #ifdef FEAT_EVAL int may_have_range; int vim9script; int did_set_expr_line = FALSE; #endif int sourcing = flags & DOCMD_VERBOSE; --- 1734,1742 ---- int ni; // set when Not Implemented char_u *cmd; int starts_with_colon = FALSE; int may_have_range; int vim9script; + #ifdef FEAT_EVAL int did_set_expr_line = FALSE; #endif int sourcing = flags & DOCMD_VERBOSE; *************** *** 1787,1795 **** 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 --- 1785,1790 ---- *************** *** 1805,1813 **** * 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. if (vim9script && (flags & DOCMD_RANGEOK) == 0) { may_have_range = FALSE; --- 1800,1809 ---- * We need the command to know what kind of range it uses. */ cmd = ea.cmd; ! // 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,1837 **** 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; p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL); if (ea.cmdidx == CMD_SIZE) { char_u *ar = skip_range(ea.cmd, TRUE, NULL); --- 1818,1835 ---- else may_have_range = TRUE; if (may_have_range) ea.cmd = skip_range(ea.cmd, TRUE, NULL); 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,1852 **** } } else - #endif p = find_ex_command(&ea, NULL, NULL, NULL); #ifdef FEAT_EVAL --- 1844,1849 ---- *************** *** 1930,1942 **** } 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; /* * 5. Parse the command. --- 1927,1936 ---- } ea.cmd = cmd; if (!may_have_range) ea.line1 = ea.line2 = default_address(&ea); ! else if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) ! goto doend; /* * 5. Parse the command. *************** *** 5275,5298 **** } #endif ! // 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') { /* --- 5269,5288 ---- } #endif ! // Check for '"'/'#': start of comment or '|': next command // :@" and :*" do not start a comment! // :redir @" doesn't either. else if ((*p == '"' && !in_vim9script() && !(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] != '@')) || (*p == '#' && in_vim9script() && !(eap->argt & EX_NOTRLCOM) && p > eap->cmd && VIM_ISWHITE(p[-1])) || *p == '|' || *p == '\n') { /* *************** *** 5636,5645 **** { int comment_char = '"'; - #ifdef FEAT_EVAL if (in_vim9script()) comment_char = '#'; - #endif return (c == NUL || c == '|' || c == comment_char || c == '\n'); } --- 5626,5633 ---- *************** *** 5654,5665 **** 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 == '"'; } --- 5642,5651 ---- *** ../vim-9.0.0636/src/errors.h 2022-09-29 19:14:37.675876694 +0100 --- src/errors.h 2022-10-02 12:12:17.384390042 +0100 *************** *** 2713,2720 **** --- 2713,2722 ---- INIT(= N_("E1048: Item not found in script: %s")); EXTERN char e_item_not_exported_in_script_str[] INIT(= N_("E1049: Item not exported in script: %s")); + #endif EXTERN char e_colon_required_before_range_str[] INIT(= N_("E1050: Colon required before a range: %s")); + #ifdef FEAT_EVAL EXTERN char e_wrong_argument_type_for_plus[] INIT(= N_("E1051: Wrong argument type for +")); EXTERN char e_cannot_declare_an_option[] *** ../vim-9.0.0636/src/testdir/test10.in 2022-10-02 12:56:33.433866218 +0100 --- src/testdir/test10.in 2022-10-02 12:49:20.516556629 +0100 *************** *** 0 **** --- 1,21 ---- + Test that vim9script also works without the +eval feature. + + STARTTEST + :/^START/+1,/^END/-1:w! Xvim9 + :so Xvim9 + ENDTEST + + START + vim9script + + if 1 + echo 'this is skipped without +eval' + endif + + # colon required for a range + :$-1,$w! test.out + qa! + END + + first line + last line *** ../vim-9.0.0636/src/testdir/test10.ok 2022-10-02 12:56:33.437866195 +0100 --- src/testdir/test10.ok 2022-10-02 12:42:15.000778606 +0100 *************** *** 0 **** --- 1,2 ---- + first line + last line *** ../vim-9.0.0636/src/testdir/Make_all.mak 2022-09-23 19:42:27.814236815 +0100 --- src/testdir/Make_all.mak 2022-10-02 12:42:36.840498850 +0100 *************** *** 12,17 **** --- 12,18 ---- # Tests for tiny and small builds. SCRIPTS_TINY = \ + test10 \ test20 \ test21 \ test22 \ *************** *** 22,27 **** --- 23,29 ---- test27 SCRIPTS_TINY_OUT = \ + test10.out \ test20.out \ test21.out \ test22.out \ *** ../vim-9.0.0636/src/version.c 2022-10-01 21:22:14.038403172 +0100 --- src/version.c 2022-10-02 12:42:54.064284316 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 637, /**/ -- If you're sending someone Styrofoam, what do you pack it in? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///