To: vim_dev@googlegroups.com Subject: Patch 8.2.0612 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0612 Problem: Vim9: no check for space before #comment. Solution: Add space checks. Files: src/ex_eval.c, src/ex_cmds.c, src/regexp.c, src/proto/regexp.pro, src/gui.c, src/highlight.c, src/testdir/test_vim9_script.vim, src/testdir/test_sort.vim *** ../vim-8.2.0611/src/ex_eval.c 2020-04-13 17:20:56.174130307 +0200 --- src/ex_eval.c 2020-04-20 19:10:24.894038860 +0200 *************** *** 1021,1032 **** if (eap->cmdidx == CMD_elseif) { result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); // When throwing error exceptions, we want to throw always the first // of several errors in a row. This is what actually happens when // a conditional error was detected above and there is another failure // when parsing the expression. Since the skip flag is set in this // case, the parsing error will be ignored by emsg(). - if (!skip && !error) { if (result) --- 1021,1032 ---- if (eap->cmdidx == CMD_elseif) { result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); + // When throwing error exceptions, we want to throw always the first // of several errors in a row. This is what actually happens when // a conditional error was detected above and there is another failure // when parsing the expression. Since the skip flag is set in this // case, the parsing error will be ignored by emsg(). if (!skip && !error) { if (result) *************** *** 1518,1524 **** &cstack->cs_looplevel); } ! if (ends_excmd(*eap->arg)) // no argument, catch all errors { pat = (char_u *)".*"; end = NULL; --- 1518,1524 ---- &cstack->cs_looplevel); } ! if (ends_excmd2(eap->cmd, eap->arg)) // no argument, catch all errors { pat = (char_u *)".*"; end = NULL; *************** *** 1527,1533 **** else { pat = eap->arg + 1; ! end = skip_regexp(pat, *eap->arg, TRUE); } if (!give_up) --- 1527,1535 ---- else { pat = eap->arg + 1; ! end = skip_regexp_err(pat, *eap->arg, TRUE); ! if (end == NULL) ! give_up = TRUE; } if (!give_up) *************** *** 1548,1554 **** if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) && !(cstack->cs_flags[idx] & CSF_CAUGHT)) { ! if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { emsg(_(e_trailing)); return; --- 1550,1557 ---- if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) && !(cstack->cs_flags[idx] & CSF_CAUGHT)) { ! if (end != NULL && *end != NUL ! && !ends_excmd2(end, skipwhite(end + 1))) { emsg(_(e_trailing)); return; *** ../vim-8.2.0611/src/ex_cmds.c 2020-04-02 21:13:21.392362410 +0200 --- src/ex_cmds.c 2020-04-20 19:07:30.178073909 +0200 *************** *** 451,462 **** } else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) { ! s = skip_regexp(p + 1, *p, TRUE); ! if (*s != *p) ! { ! emsg(_(e_invalpat)); goto sortend; - } *s = NUL; // Use last search pattern if sort pattern is empty. if (s == p + 1) --- 451,459 ---- } else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) { ! s = skip_regexp_err(p + 1, *p, TRUE); ! if (s == NULL) goto sortend; *s = NUL; // Use last search pattern if sort pattern is empty. if (s == p + 1) *** ../vim-8.2.0611/src/regexp.c 2020-04-12 19:37:13.522297249 +0200 --- src/regexp.c 2020-04-20 19:07:05.682069445 +0200 *************** *** 534,550 **** /* * Skip past regular expression. ! * Stop at end of "startp" or where "dirc" is found ('/', '?', etc). * Take care of characters with a backslash in front of it. * Skip strings inside [ and ]. */ char_u * skip_regexp( char_u *startp, ! int dirc, int magic) { ! return skip_regexp_ex(startp, dirc, magic, NULL, NULL); } /* --- 534,570 ---- /* * Skip past regular expression. ! * Stop at end of "startp" or where "delim" is found ('/', '?', etc). * Take care of characters with a backslash in front of it. * Skip strings inside [ and ]. */ char_u * skip_regexp( char_u *startp, ! int delim, int magic) { ! return skip_regexp_ex(startp, delim, magic, NULL, NULL); ! } ! ! /* ! * Call skip_regexp() and when the delimiter does not match give an error and ! * return NULL. ! */ ! char_u * ! skip_regexp_err( ! char_u *startp, ! int delim, ! int magic) ! { ! char_u *p = skip_regexp(startp, delim, magic); ! ! if (*p != delim) ! { ! semsg(_("E654: missing delimiter after search pattern: %s"), startp); ! return NULL; ! } ! return p; } /* *** ../vim-8.2.0611/src/proto/regexp.pro 2020-04-02 21:13:21.388362421 +0200 --- src/proto/regexp.pro 2020-04-20 19:07:13.206071079 +0200 *************** *** 1,6 **** /* regexp.c */ int re_multiline(regprog_T *prog); ! char_u *skip_regexp(char_u *startp, int dirc, int magic); char_u *skip_regexp_ex(char_u *startp, int dirc, int magic, char_u **newp, int *dropped); reg_extmatch_T *ref_extmatch(reg_extmatch_T *em); void unref_extmatch(reg_extmatch_T *em); --- 1,7 ---- /* regexp.c */ int re_multiline(regprog_T *prog); ! char_u *skip_regexp(char_u *startp, int delim, int magic); ! char_u *skip_regexp_err(char_u *startp, int delim, int magic); char_u *skip_regexp_ex(char_u *startp, int dirc, int magic, char_u **newp, int *dropped); reg_extmatch_T *ref_extmatch(reg_extmatch_T *em); void unref_extmatch(reg_extmatch_T *em); *** ../vim-8.2.0611/src/gui.c 2020-04-12 15:10:36.618312729 +0200 --- src/gui.c 2020-04-20 19:19:15.373471110 +0200 *************** *** 5036,5042 **** // of the argument ending up after the shell prompt. msg_clr_eos_force(); #ifdef GUI_MAY_SPAWN ! if (!ends_excmd(*eap->arg)) gui_start(eap->arg); else #endif --- 5036,5042 ---- // of the argument ending up after the shell prompt. msg_clr_eos_force(); #ifdef GUI_MAY_SPAWN ! if (!ends_excmd2(eap->cmd, eap->arg)) gui_start(eap->arg); else #endif *************** *** 5045,5051 **** channel_gui_register_all(); #endif } ! if (!ends_excmd(*eap->arg)) ex_next(eap); } --- 5045,5051 ---- channel_gui_register_all(); #endif } ! if (!ends_excmd2(eap->cmd, eap->arg)) ex_next(eap); } *** ../vim-8.2.0611/src/highlight.c 2020-04-12 19:37:13.514297270 +0200 --- src/highlight.c 2020-04-20 19:26:50.584714691 +0200 *************** *** 658,664 **** /* * If no argument, list current highlighting. */ ! if (ends_excmd(*line)) { for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i) // TODO: only call when the group has attributes set --- 658,664 ---- /* * If no argument, list current highlighting. */ ! if (!init && ends_excmd2(line - 1, line)) { for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i) // TODO: only call when the group has attributes set *** ../vim-8.2.0611/src/testdir/test_vim9_script.vim 2020-04-20 17:46:10.592551923 +0200 --- src/testdir/test_vim9_script.vim 2020-04-20 19:29:40.644403393 +0200 *************** *** 1153,1174 **** CheckDefFailure([ 'try# comment', ! 'echo "yes"', 'catch', 'endtry', ], 'E488:') CheckDefFailure([ 'try', ! 'echo "yes"', 'catch# comment', 'endtry', ], 'E488:') CheckDefFailure([ 'try', 'echo "yes"', 'catch', 'endtry# comment', ], 'E488:') enddef def Test_vim9_comment_not_compiled() --- 1153,1228 ---- CheckDefFailure([ 'try# comment', ! ' echo "yes"', 'catch', 'endtry', ], 'E488:') + CheckScriptFailure([ + 'vim9script', + 'try# comment', + 'echo "yes"', + ], 'E488:') CheckDefFailure([ 'try', ! ' echo "yes"', 'catch# comment', 'endtry', ], 'E488:') + CheckScriptFailure([ + 'vim9script', + 'try', + ' echo "yes"', + 'catch# comment', + 'endtry', + ], 'E654:') + CheckDefFailure([ + 'try', + ' echo "yes"', + 'catch /pat/# comment', + 'endtry', + ], 'E488:') + CheckScriptFailure([ + 'vim9script', + 'try', + ' throw "pat"', + 'catch /pat/# comment', + 'endtry', + ], 'E605:') CheckDefFailure([ 'try', 'echo "yes"', 'catch', 'endtry# comment', ], 'E488:') + CheckScriptFailure([ + 'vim9script', + 'try', + ' echo "yes"', + 'catch', + 'endtry# comment', + ], 'E600:') + + CheckScriptSuccess([ + 'vim9script', + 'hi # comment', + ]) + CheckScriptFailure([ + 'vim9script', + 'hi# comment', + ], 'E416:') + enddef + + def Test_vim9_comment_gui() + CheckCanRunGui + + CheckScriptFailure([ + 'vim9script', + 'gui#comment' + ], 'E499:') + CheckScriptFailure([ + 'vim9script', + 'gui -f#comment' + ], 'E499:') enddef def Test_vim9_comment_not_compiled() *** ../vim-8.2.0611/src/testdir/test_sort.vim 2020-04-20 16:49:56.705830066 +0200 --- src/testdir/test_sort.vim 2020-04-20 19:40:17.834388335 +0200 *************** *** 1255,1261 **** call setline(1, ['line1', 'line2']) call assert_fails('sort no', 'E474:') call assert_fails('sort c', 'E475:') ! call assert_fails('sort #pat%', 'E682:') enew! endfunc --- 1255,1261 ---- call setline(1, ['line1', 'line2']) call assert_fails('sort no', 'E474:') call assert_fails('sort c', 'E475:') ! call assert_fails('sort #pat%', 'E654:') enew! endfunc *** ../vim-8.2.0611/src/version.c 2020-04-20 17:46:10.592551923 +0200 --- src/version.c 2020-04-20 18:56:30.980911014 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 612, /**/ -- Every engineer dreams about saving the universe and having sex with aliens. This is much more glamorous than the real life of an engineer, which consists of hiding from the universe and having sex without the participation of other life forms. (Scott Adams - The Dilbert principle) /// 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 ///