To: vim_dev@googlegroups.com Subject: Patch 8.2.0624 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0624 Problem: Vim9: no check for space before #comment. Solution: Add space checks. Fix :throw with double quoted string. Files: src/usercmd.c, src/userfunc.c, src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.0623/src/usercmd.c 2020-04-18 19:53:24.531912284 +0200 --- src/usercmd.c 2020-04-23 16:35:16.836576355 +0200 *************** *** 1007,1013 **** if (ASCII_ISALPHA(*p)) while (ASCII_ISALNUM(*p)) ++p; ! if (!ends_excmd(*p) && !VIM_ISWHITE(*p)) { emsg(_("E182: Invalid command name")); return; --- 1007,1013 ---- if (ASCII_ISALPHA(*p)) while (ASCII_ISALNUM(*p)) ++p; ! if (!ends_excmd2(eap->arg, p) && !VIM_ISWHITE(*p)) { emsg(_("E182: Invalid command name")); return; *************** *** 1018,1024 **** // If there is nothing after the name, and no attributes were specified, // we are listing commands p = skipwhite(end); ! if (!has_attr && ends_excmd(*p)) { uc_list(name, end - name); } --- 1018,1024 ---- // If there is nothing after the name, and no attributes were specified, // we are listing commands p = skipwhite(end); ! if (!has_attr && ends_excmd2(eap->arg, p)) { uc_list(name, end - name); } *** ../vim-8.2.0623/src/userfunc.c 2020-04-18 20:51:37.353348315 +0200 --- src/userfunc.c 2020-04-23 16:44:01.439451521 +0200 *************** *** 2373,2379 **** /* * ":function" without argument: list functions. */ ! if (ends_excmd(*eap->arg)) { if (!eap->skip) { --- 2373,2379 ---- /* * ":function" without argument: list functions. */ ! if (ends_excmd2(eap->cmd, eap->arg)) { if (!eap->skip) { *************** *** 3711,3717 **** if (!failed || eap->cstack->cs_trylevel > 0) { // Check for trailing illegal characters and a following command. ! if (!ends_excmd(*arg)) { if (!failed) { --- 3711,3717 ---- if (!failed || eap->cstack->cs_trylevel > 0) { // Check for trailing illegal characters and a following command. ! if (!ends_excmd2(eap->arg, arg)) { if (!failed) { *** ../vim-8.2.0623/src/vim9compile.c 2020-04-19 18:27:20.791953204 +0200 --- src/vim9compile.c 2020-04-23 16:55:18.897997480 +0200 *************** *** 5752,5762 **** { char_u *p = skipwhite(arg); - if (ends_excmd(*p)) - { - emsg(_(e_argreq)); - return NULL; - } if (compile_expr1(&p, cctx) == FAIL) return NULL; if (may_generate_2STRING(-1, cctx) == FAIL) --- 5752,5757 ---- *** ../vim-8.2.0623/src/testdir/test_vim9_script.vim 2020-04-20 22:42:28.232964333 +0200 --- src/testdir/test_vim9_script.vim 2020-04-23 17:05:12.612722764 +0200 *************** *** 361,367 **** enddef def ThrowFromDef() ! throw 'getout' enddef func CatchInFunc() --- 361,367 ---- enddef def ThrowFromDef() ! throw "getout" # comment enddef func CatchInFunc() *************** *** 430,436 **** call CheckDefFailure(['if 2', 'endtry'], 'E171:') call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') ! call CheckDefFailure(['throw'], 'E471:') call CheckDefFailure(['throw xxx'], 'E1001:') enddef --- 430,436 ---- call CheckDefFailure(['if 2', 'endtry'], 'E171:') call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') ! call CheckDefFailure(['throw'], 'E1015:') call CheckDefFailure(['throw xxx'], 'E1001:') enddef *************** *** 937,948 **** setline(1, 'default') execute 'call setline(1, "execute-string")' assert_equal('execute-string', getline(1)) let cmd1 = 'call setline(1,' let cmd2 = '"execute-var")' ! execute cmd1 cmd2 assert_equal('execute-var', getline(1)) execute cmd1 cmd2 '|call setline(1, "execute-var-string")' assert_equal('execute-var-string', getline(1)) let cmd_first = 'call ' let cmd_last = 'setline(1, "execute-var-var")' execute cmd_first .. cmd_last --- 937,954 ---- setline(1, 'default') execute 'call setline(1, "execute-string")' assert_equal('execute-string', getline(1)) + + execute "call setline(1, 'execute-string')" + assert_equal('execute-string', getline(1)) + let cmd1 = 'call setline(1,' let cmd2 = '"execute-var")' ! execute cmd1 cmd2 # comment assert_equal('execute-var', getline(1)) + execute cmd1 cmd2 '|call setline(1, "execute-var-string")' assert_equal('execute-var-string', getline(1)) + let cmd_first = 'call ' let cmd_last = 'setline(1, "execute-var-var")' execute cmd_first .. cmd_last *************** *** 950,966 **** bwipe! call CheckDefFailure(['execute xxx'], 'E1001:') enddef def Test_echo_cmd() ! echo 'some' echon 'thing' assert_match('^something$', Screenline(&lines)) let str1 = 'some' let str2 = 'more' echo str1 str2 assert_match('^some more$', Screenline(&lines)) enddef def Test_for_outside_of_function() --- 956,979 ---- bwipe! call CheckDefFailure(['execute xxx'], 'E1001:') + call CheckDefFailure(['execute "cmd"# comment'], 'E488:') enddef def Test_echo_cmd() ! echo 'some' # comment echon 'thing' assert_match('^something$', Screenline(&lines)) + echo "some" # comment + echon "thing" + assert_match('^something$', Screenline(&lines)) + let str1 = 'some' let str2 = 'more' echo str1 str2 assert_match('^some more$', Screenline(&lines)) + + call CheckDefFailure(['echo "xxx"# comment'], 'E488:') enddef def Test_for_outside_of_function() *************** *** 1164,1169 **** --- 1177,1194 ---- ], 'E488:') CheckDefFailure([ 'try', + ' throw#comment', + 'catch', + 'endtry', + ], 'E1015:') + CheckDefFailure([ + 'try', + ' throw "yes"#comment', + 'catch', + 'endtry', + ], 'E488:') + CheckDefFailure([ + 'try', ' echo "yes"', 'catch# comment', 'endtry', *************** *** 1380,1385 **** --- 1405,1469 ---- 'vim9script', 'syntax cluster Some contains=Word# comment', ], 'E475:') + + CheckScriptSuccess([ + 'vim9script', + 'command Echo echo # comment', + 'command Echo # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'command Echo echo# comment', + 'Echo', + ], 'E121:') + CheckScriptFailure([ + 'vim9script', + 'command Echo# comment', + ], 'E182:') + CheckScriptFailure([ + 'vim9script', + 'command Echo echo', + 'command Echo# comment', + ], 'E182:') + + CheckScriptSuccess([ + 'vim9script', + 'function # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'function# comment', + ], 'E129:') + CheckScriptSuccess([ + 'vim9script', + 'function CheckScriptSuccess # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'function CheckScriptSuccess# comment', + ], 'E488:') + + CheckScriptSuccess([ + 'vim9script', + 'func DeleteMe()', + 'endfunc', + 'delfunction DeleteMe # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'func DeleteMe()', + 'endfunc', + 'delfunction DeleteMe# comment', + ], 'E488:') + + CheckScriptSuccess([ + 'vim9script', + 'call execute("ls") # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'call execute("ls")# comment', + ], 'E488:') enddef def Test_vim9_comment_gui() *** ../vim-8.2.0623/src/version.c 2020-04-23 15:46:30.846664908 +0200 --- src/version.c 2020-04-23 17:05:44.964653299 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 624, /**/ -- hundred-and-one symptoms of being an internet addict: 1. You actually wore a blue ribbon to protest the Communications Decency Act. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///