Patch 8.2.1076
Patch 8.2.1076 Problem:Vim9: no line break allowed in :if expression. Solution: Skip linebreak. Files: src/eval.c, src/proto/eval.pro, src/evalvars.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.1075/src/eval.c 2020-06-27 21:56:13.764343724 +0200 --- src/eval.c 2020-06-27 22:55:44.094945696 +0200 *** *** 166,175 { typval_T tv; varnumber_T retval = FALSE; if (skip) ++emsg_skip; ! if (eval0(arg, , eap, skip ? NULL : _EVALUATE) == FAIL) *error = TRUE; else { --- 166,181 { typval_T tv; varnumber_T retval = FALSE; + evalarg_T evalarg; + + CLEAR_FIELD(evalarg); + evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE; + evalarg.eval_cookie = eap != NULL && eap->getline == getsourceline + ? eap->cookie : NULL; if (skip) ++emsg_skip; ! if (eval0(arg, , eap, ) == FAIL) *error = TRUE; else { *** *** 182,187 --- 188,194 } if (skip) --emsg_skip; + clear_evalarg(, eap); return (int)retval; } *** *** 1884,1889 --- 1891,1914 } /* + * After using "evalarg" filled from "eap" free the memory. + */ + void + clear_evalarg(evalarg_T *evalarg, exarg_T *eap) + { + if (evalarg != NULL && eap != NULL && evalarg->eval_tofree != NULL) + { + // We may need to keep the original command line, e.g. for + // ":let" it has the variable names. But we may also need the + // new one, "nextcmd" points into it. Keep both. + vim_free(eap->cmdline_tofree); + eap->cmdline_tofree = *eap->cmdlinep; + *eap->cmdlinep = evalarg->eval_tofree; + evalarg->eval_tofree = NULL; + } + } + + /* * The "evaluate" argument: When FALSE, the argument is only parsed but not * executed. The function may return OK, but the rettv will be of type * VAR_UNKNOWN. The function still returns FAIL for a syntax error. *** *** 1934,1949 if (eap != NULL) eap->nextcmd = check_nextcmd(p); ! if (evalarg != NULL && eap != NULL && evalarg->eval_tofree != NULL) ! { ! // We may need to keep the original command line, e.g. for ! // ":let" it has the variable names. But we may also need the ! // new one, "nextcmd" points into it. Keep both. ! vim_free(eap->cmdline_tofree); ! eap->cmdline_tofree = *eap->cmdlinep; ! *eap->cmdlinep = evalarg->eval_tofree; ! evalarg->eval_tofree = NULL; ! } return ret; } --- 1959,1965 if (eap != NULL) eap->nextcmd = check_nextcmd(p); ! clear_evalarg(evalarg, eap); return ret; } *** *** 5223,5228 --- 5239,5245 arg = skipwhite(arg); } eap->nextcmd = check_nextcmd(arg); + clear_evalarg(, eap); if (eap->skip) --emsg_skip; *** ../vim-8.2.1075/src/proto/eval.pro 2020-06-27 21:17:55.359214424 +0200 --- src/proto/eval.pro 2020-06-27 22:45:49.897705439 +0200 *** *** 30,35 --- 30,36 char_u *eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext); char_u *eval_next_line(evalarg_T *evalarg); char_u *skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg); + void clear_evalarg(evalarg_T *evalarg, exarg_T *eap); int eval0(char_u *arg, typval_T *rettv, exarg_T *eap, evalarg_T *evalarg); int eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg); void eval_addblob(typval_T *tv1, typval_T *tv2); *** ../vim-8.2.1075/src/evalvars.c 2020-06-27 18:06:42.148575132 +0200 --- src/evalvars.c 2020-06-27 22:45:28.101806140 +0200 *** *** 804,810 i = eval0(expr, , eap, ); if (eap->skip) --emsg_skip; ! vim_free(evalarg.eval_tofree); } if (eap->skip) { --- 804,810 i = eval0(expr, , eap, ); if (eap->skip) --emsg_skip; ! clear_evalarg(, eap); } if (eap->skip) { *** ../vim-8.2.1075/src/testdir/test_vim9_cmd.vim 2020-06-27 21:56:13.764343724 +0200 --- src/testdir/test_vim9_cmd.vim 2020-06-27 22:49:19.132736358 +0200 *** *** 101,105 --- 101,146 CheckScriptSuccess(lines) enddef + def Test_if_linebreak() + let lines =<< trim END + vim9script + if 1 && + 2 + || 3 + g:res = 42 + endif + assert_equal(42, g:res) + END + CheckScriptSuccess(lines) + unlet g:res + + lines =<< trim END + vim9script + if 1 && + 0 + g:res = 0 + elseif 0 || + 0 + || 1 + g:res = 12 + endif + assert_equal(12, g:res) + END + CheckScriptSuccess(lines) + unlet g:res + enddef + + def Test_while_linebreak() +
Patch 8.2.1075
Patch 8.2.1075 Problem:Vim9: no line break allowed in :echo expression. Solution: Skip linebreak. Files: src/eval.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.1074/src/eval.c 2020-06-27 21:17:55.359214424 +0200 --- src/eval.c 2020-06-27 21:50:42.850114096 +0200 *** *** 5190,5195 --- 5190,5196 CLEAR_FIELD(evalarg); evalarg.eval_flags = eap->skip ? 0 : EVAL_EVALUATE; + evalarg.eval_cookie = eap->getline == getsourceline ? eap->cookie : NULL; if (eap->skip) ++emsg_skip; *** ../vim-8.2.1074/src/testdir/test_vim9_cmd.vim 2020-05-10 21:47:40.152613769 +0200 --- src/testdir/test_vim9_cmd.vim 2020-06-27 21:55:18.544699676 +0200 *** *** 78,82 --- 78,105 assert_equal({'0': 0, '1': 1, '2': 2}, nrd) enddef + def Test_echo_linebreak() + let lines =<< trim END + vim9script + redir @a + echo 'one' + .. 'two' + redir END + assert_equal("\nonetwo", @a) + END + CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + redir @a + echo 11 + + 77 + - 22 + redir END + assert_equal("\n66", @a) + END + CheckScriptSuccess(lines) + enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.1074/src/version.c 2020-06-27 21:17:55.363214407 +0200 --- src/version.c 2020-06-27 21:52:22.357667527 +0200 *** *** 756,757 --- 756,759 { /* Add new patch number below this line */ + /**/ + 1075, /**/ -- Why is "abbreviation" such a long word? /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202006271956.05RJufSO157744%40masaka.moolenaar.net.
Patch 8.2.1074
Patch 8.2.1074 Problem:Vim9: no line break allowed after some operators. Solution: Skip a line break after the operator. Add eval_may_get_next_line() to simplify checking for a line break. Files: src/eval.c, src/proto/eval.pro, src/dict.c, src/list.c, src/userfunc.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1073/src/eval.c 2020-06-27 20:46:26.058241052 +0200 --- src/eval.c 2020-06-27 21:16:08.835674580 +0200 *** *** 1871,1876 --- 1871,1888 return skipwhite(line); } + char_u * + skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg) + { + int getnext; + char_u *p = skipwhite(arg); + + eval_next_non_blank(p, evalarg, ); + if (getnext) + return eval_next_line(evalarg); + return p; + } + /* * The "evaluate" argument: When FALSE, the argument is only parsed but not * executed. The function may return OK, but the rettv will be of type *** *** 1998,2004 /* * Get the second variable. Recursive! */ ! *arg = skipwhite(*arg + 1); nested_evalarg.eval_flags = result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval1(arg, rettv, _evalarg) == FAIL) --- 2010,2016 /* * Get the second variable. Recursive! */ ! *arg = skipwhite_and_linebreak(*arg + 1, evalarg); nested_evalarg.eval_flags = result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval1(arg, rettv, _evalarg) == FAIL) *** *** 2021,2027 /* * Get the third variable. Recursive! */ ! *arg = skipwhite(*arg + 1); nested_evalarg.eval_flags = !result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval1(arg, , _evalarg) == FAIL) --- 2033,2039 /* * Get the third variable. Recursive! */ ! *arg = skipwhite_and_linebreak(*arg + 1, evalarg); nested_evalarg.eval_flags = !result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval1(arg, , _evalarg) == FAIL) *** *** 2103,2109 /* * Get the second variable. */ ! *arg = skipwhite(*arg + 2); nested_evalarg.eval_flags = !result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval3(arg, , _evalarg) == FAIL) --- 2115,2121 /* * Get the second variable. */ ! *arg = skipwhite_and_linebreak(*arg + 2, evalarg); nested_evalarg.eval_flags = !result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval3(arg, , _evalarg) == FAIL) *** *** 2197,2203 /* * Get the second variable. */ ! *arg = skipwhite(*arg + 2); nested_evalarg.eval_flags = result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval4(arg, , _evalarg) == FAIL) --- 2209,2215 /* * Get the second variable. */ ! *arg = skipwhite_and_linebreak(*arg + 2, evalarg); nested_evalarg.eval_flags = result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval4(arg, , _evalarg) == FAIL) *** *** 2328,2334 /* * Get the second variable. */ ! *arg = skipwhite(p + len); if (eval5(arg, , evalarg) == FAIL) { clear_tv(rettv); --- 2340,2346 /* * Get the second variable. */ ! *arg = skipwhite_and_linebreak(p + len, evalarg); if (eval5(arg, , evalarg) == FAIL) { clear_tv(rettv); *** *** 2452,2461 */ if (op == '.' && *(*arg + 1) == '.') // .. string concatenation ++*arg; ! *arg = skipwhite(*arg + 1); ! eval_next_non_blank(*arg, evalarg, ); ! if (getnext) ! *arg = eval_next_line(evalarg); if (eval6(arg, , evalarg, op == '.') == FAIL) { clear_tv(rettv); --- 2464,2470 */ if (op == '.' && *(*arg + 1) == '.') // .. string concatenation ++*arg; ! *arg = skipwhite_and_linebreak(*arg + 1, evalarg); if (eval6(arg, , evalarg, op == '.') == FAIL) { clear_tv(rettv); *** *** 2893,2910 * nested expression: (expression). */ case '(': { ! int getnext; ! ! *arg = skipwhite(*arg + 1); ! eval_next_non_blank(*arg, evalarg, ); ! if (getnext) ! *arg = eval_next_line(evalarg); ! ret =
Patch 8.2.1073
Patch 8.2.1073 Problem:Vim9: no line break allowed in () expression. Solution: Skip a line break. Files: src/eval.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1072/src/eval.c 2020-06-27 18:06:42.148575132 +0200 --- src/eval.c 2020-06-27 20:44:21.690704752 +0200 *** *** 2453,2458 --- 2453,2461 if (op == '.' && *(*arg + 1) == '.') // .. string concatenation ++*arg; *arg = skipwhite(*arg + 1); + eval_next_non_blank(*arg, evalarg, ); + if (getnext) + *arg = eval_next_line(evalarg); if (eval6(arg, , evalarg, op == '.') == FAIL) { clear_tv(rettv); *** *** 2890,2897 --- 2893,2910 * nested expression: (expression). */ case '(': { + int getnext; + *arg = skipwhite(*arg + 1); + eval_next_non_blank(*arg, evalarg, ); + if (getnext) + *arg = eval_next_line(evalarg); + ret = eval1(arg, rettv, evalarg); // recursive! + + eval_next_non_blank(*arg, evalarg, ); + if (getnext) + *arg = eval_next_line(evalarg); if (**arg == ')') ++*arg; else if (ret == OK) *** ../vim-8.2.1072/src/testdir/test_vim9_expr.vim 2020-06-27 18:06:42.152575113 +0200 --- src/testdir/test_vim9_expr.vim 2020-06-27 20:40:33.447800202 +0200 *** *** 1137,1142 --- 1137,1155 assert_equal(true, !+-+0) enddef + def Test_expr7_parens_vim9script() + let lines =<< trim END + vim9script + let s = ( + 'one' + .. + 'two' + ) + assert_equal('onetwo', s) + END + CheckScriptSuccess(lines) + enddef + def Test_expr7_negate() assert_equal(-99, -99) assert_equal(99, --99) *** ../vim-8.2.1072/src/version.c 2020-06-27 18:13:04.966631915 +0200 --- src/version.c 2020-06-27 20:45:36.870341758 +0200 *** *** 756,757 --- 756,759 { /* Add new patch number below this line */ + /**/ + 1073, /**/ -- LETTERS TO THE EDITOR (The Times of London) Dear Sir, I am firmly opposed to the spread of microchips either to the home or to the office. We have more than enough of them foisted upon us in public places. They are a disgusting Americanism, and can only result in the farmers being forced to grow smaller potatoes, which in turn will cause massive unemployment in the already severely depressed agricultural industry. Yours faithfully, Capt. Quinton D'Arcy, J. P. Sevenoaks /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202006271847.05RIl52A131246%40masaka.moolenaar.net.
Re: [vim/vim] Wrong syntax coloring (#6331)
Christian Brabandt wrote: On Do, 25 Jun 2020, Charles Campbell wrote: I think it is not about matchit itself, it was just an example. The thing was when using a plugin manager like vim-plug and you want to enable the matchit plugin, you use: Plug 'k-takata/matchit.vim' in your vimrc. And apparently, the ' is not detected as a string, but rather as a mark command (or something similar). I am not sure if it will be easy to fix however. Oh -- Plug is a command set up by a plugin. Yeah -- I don't see a good way to differentiate between marks and strings for it, either. Chip -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/ceafee25-9fa0-ba49-3f44-4ab51310e40c%40drchip.org.
Patch 8.2.1072
Patch 8.2.1072 Problem:Missing libvterm test. Solution: Sync with libvterm revision 768. Files: src/libvterm/src/state.c, src/libvterm/t/63screen_resize.test *** ../vim-8.2.1071/src/libvterm/src/state.c2020-06-21 17:57:28.017960419 +0200 --- src/libvterm/src/state.c2020-06-27 18:09:00.275892535 +0200 *** *** 1844,1857 state->pos.col++; } - if(state->pos.row >= rows) - state->pos.row = rows - 1; if(state->pos.row < 0) state->pos.row = 0; ! if(state->pos.col >= cols) ! state->pos.col = cols - 1; if(state->pos.col < 0) state->pos.col = 0; updatecursor(state, , 1); --- 1844,1857 state->pos.col++; } if(state->pos.row < 0) state->pos.row = 0; ! if(state->pos.row >= rows) ! state->pos.row = rows - 1; if(state->pos.col < 0) state->pos.col = 0; + if(state->pos.col >= cols) + state->pos.col = cols - 1; updatecursor(state, , 1); *** ../vim-8.2.1071/src/libvterm/t/63screen_resize.test 2020-05-18 21:50:32.932742338 +0200 --- src/libvterm/t/63screen_resize.test 2020-06-27 18:10:29.791437826 +0200 *** *** 69,74 --- 69,90 ?screen_chars 22,0,23,10 = "Line 25" ?cursor = 23,0 + !Resize shorter does not send the cursor to a negative row + # See also https://github.com/vim/vim/pull/6141 + RESET + WANTSCREEN -b + RESIZE 25,80 + WANTSCREEN b + PUSH "\e[24HLine 24\r\nLine 25\e[H" + ?cursor = 0,0 + RESIZE 20,80 + sb_pushline 80 = + sb_pushline 80 = + sb_pushline 80 = + sb_pushline 80 = + sb_pushline 80 = + ?cursor = 0,0 + !Resize taller attempts to pop scrollback RESET WANTSCREEN -b *** ../vim-8.2.1071/src/version.c 2020-06-27 18:06:42.152575113 +0200 --- src/version.c 2020-06-27 18:10:06.987554419 +0200 *** *** 756,757 --- 756,759 { /* Add new patch number below this line */ + /**/ + 1072, /**/ -- ARTHUR: If you do not open these doors, we will take this castle by force ... [A bucket of slops land on ARTHUR. He tries to retain his dignity.] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202006271613.05RGDVUk101696%40masaka.moolenaar.net.
Patch 8.2.1071
Patch 8.2.1071 Problem:Vim9: no line break allowed inside a lambda. Solution: Handle line break inside a lambda in Vim9 script. Files: src/eval.c, src/proto/eval.pro, src/evalvars.c, src/userfunc.c, src/proto/userfunc.pro, src/popupwin.c, src/vim9compile.c, src/ex_eval.c, src/globals.h, src/structs.h, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1070/src/eval.c 2020-06-27 14:11:50.494644105 +0200 --- src/eval.c 2020-06-27 18:02:08.197832760 +0200 *** *** 325,332 if (skip) ++emsg_skip; ! if (eval0(arg, , eap, skip ? NULL : _EVALUATE) ! == FAIL || skip) retval = NULL; else { --- 325,331 if (skip) ++emsg_skip; ! if (eval0(arg, , eap, skip ? NULL : _EVALUATE) == FAIL || skip) retval = NULL; else { *** *** 353,358 --- 352,412 } /* + * Skip over an expression at "*pp". + * If in Vim9 script and line breaks are encountered, the lines are + * concatenated. "evalarg->eval_tofree" will be set accordingly. + * Return FAIL for an error, OK otherwise. + */ + int + skip_expr_concatenate(char_u **start, char_u **end, evalarg_T *evalarg) + { + typval_T rettv; + int res; + int vim9script = current_sctx.sc_version == SCRIPT_VERSION_VIM9; + garray_T*gap = >eval_ga; + int save_flags = evalarg == NULL ? 0 : evalarg->eval_flags; + + if (vim9script && evalarg->eval_cookie != NULL) + { + ga_init2(gap, sizeof(char_u *), 10); + if (ga_grow(gap, 1) == OK) + // leave room for "start" + ++gap->ga_len; + } + + // Don't evaluate the expression. + if (evalarg != NULL) + evalarg->eval_flags &= ~EVAL_EVALUATE; + *end = skipwhite(*end); + res = eval1(end, , evalarg); + if (evalarg != NULL) + evalarg->eval_flags = save_flags; + + if (vim9script && evalarg->eval_cookie != NULL + && evalarg->eval_ga.ga_len > 1) + { + char_u *p; + size_t endoff = STRLEN(*end); + + // Line breaks encountered, concatenate all the lines. + *((char_u **)gap->ga_data) = *start; + p = ga_concat_strings(gap, ""); + *((char_u **)gap->ga_data) = NULL; + ga_clear_strings(gap); + gap->ga_itemsize = 0; + if (p == NULL) + return FAIL; + *start = p; + vim_free(evalarg->eval_tofree); + evalarg->eval_tofree = p; + // Compute "end" relative to the end. + *end = *start + STRLEN(*start) - endoff; + } + + return res; + } + + /* * Top level evaluation function, returning a string. * When "convert" is TRUE convert a List into a sequence of lines and convert * a Float to a String. *** *** 1794,1807 } /* ! * To be called when eval_next_non_blank() sets "getnext" to TRUE. */ char_u * eval_next_line(evalarg_T *evalarg) { ! vim_free(evalarg->eval_tofree); ! evalarg->eval_tofree = getsourceline(0, evalarg->eval_cookie, 0, TRUE); ! return skipwhite(evalarg->eval_tofree); } /* --- 1848,1874 } /* ! * To be called after eval_next_non_blank() sets "getnext" to TRUE. */ char_u * eval_next_line(evalarg_T *evalarg) { ! garray_T *gap = >eval_ga; ! char_u*line; ! ! line = getsourceline(0, evalarg->eval_cookie, 0, TRUE); ! if (gap->ga_itemsize > 0 && ga_grow(gap, 1) == OK) ! { ! // Going to concatenate the lines after parsing. ! ((char_u **)gap->ga_data)[gap->ga_len] = line; ! ++gap->ga_len; ! } ! else ! { ! vim_free(evalarg->eval_tofree); ! evalarg->eval_tofree = line; ! } ! return skipwhite(line); } /* *** *** 1831,1838 int called_emsg_before = called_emsg; int flags = evalarg == NULL ? 0 : evalarg->eval_flags; - if (evalarg != NULL) - evalarg->eval_tofree = NULL; p = skipwhite(arg); ret = eval1(, rettv, evalarg); --- 1898,1903 *** *** 1857,1878 if (eap != NULL) eap->nextcmd = check_nextcmd(p); ! if (evalarg != NULL) { ! if (eap != NULL) ! { ! if (evalarg->eval_tofree != NULL) ! { ! // We may need to keep the original command line, e.g. for ! // ":let" it has the variable names. But we may also need the ! // new one, "nextcmd" points into it. Keep both. ! vim_free(eap->cmdline_tofree); ! eap->cmdline_tofree = *eap->cmdlinep; ! *eap->cmdlinep = evalarg->eval_tofree; ! } ! } ! else ! vim_free(evalarg->eval_tofree); } return ret; --- 1922,1936 if (eap != NULL)
Patch 8.2.1070
Patch 8.2.1070 Problem:Vim9: leaking memory when lacking white space in dict. Solution: Clear the typval. Files: src/dict.c *** ../vim-8.2.1069/src/dict.c 2020-06-27 14:11:50.494644105 +0200 --- src/dict.c 2020-06-27 17:00:45.628111974 +0200 *** *** 862,867 --- 862,868 if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) { semsg(_(e_white_after), ":"); + clear_tv(); goto failret; } *** ../vim-8.2.1069/src/version.c 2020-06-27 16:36:01.908867818 +0200 --- src/version.c 2020-06-27 17:03:50.887033013 +0200 *** *** 756,757 --- 756,759 { /* Add new patch number below this line */ + /**/ + 1070, /**/ -- Living on Earth includes an annual free trip around the Sun. /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202006271504.05RF4W3B077742%40masaka.moolenaar.net.
Patch 8.2.1069
Patch 8.2.1069 Problem:Vim9: fail to check for white space in list. Solution: Add check for white space. Files: src/list.c *** ../vim-8.2.1068/src/list.c 2020-06-26 22:46:23.233370940 +0200 --- src/list.c 2020-06-27 14:10:11.955524573 +0200 *** *** 1168,1173 --- 1168,1174 list_T*l = NULL; typval_T tv; listitem_T*item; + int vim9script = current_sctx.sc_version == SCRIPT_VERSION_VIM9; int had_comma; if (evaluate) *** *** 1198,1207 clear_tv(); } ! // the comma must comma after the value had_comma = **arg == ','; if (had_comma) *arg = skipwhite(*arg + 1); // the "]" can be on the next line eval_next_non_blank(*arg, evalarg, ); --- 1199,1215 clear_tv(); } ! // the comma must come after the value had_comma = **arg == ','; if (had_comma) + { + if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) + { + semsg(_(e_white_after), ","); + goto failret; + } *arg = skipwhite(*arg + 1); + } // the "]" can be on the next line eval_next_non_blank(*arg, evalarg, ); *** ../vim-8.2.1068/src/version.c 2020-06-27 14:11:50.494644105 +0200 --- src/version.c 2020-06-27 14:53:09.713773683 +0200 *** *** 756,757 --- 756,759 { /* Add new patch number below this line */ + /**/ + 1069, /**/ -- No children may attend school with their breath smelling of "wild onions." [real standing law in West Virginia, United States of America] /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202006271436.05REaW9u071016%40masaka.moolenaar.net.
Patch 8.2.1068
Patch 8.2.1068 Problem:Vim9: no line break allowed inside a dict. Solution: Handle line break inside a dict in Vim9 script. Files: src/eval.c, src/dict.c, src/proto/dict.pro, src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1067/src/eval.c 2020-06-27 13:11:46.863462713 +0200 --- src/eval.c 2020-06-27 13:49:56.32740 +0200 *** *** 2787,2793 case '#': if ((*arg)[1] == '{') { ++*arg; ! ret = eval_dict(arg, rettv, flags, TRUE); } else ret = NOTDONE; --- 2787,2793 case '#': if ((*arg)[1] == '{') { ++*arg; ! ret = eval_dict(arg, rettv, evalarg, TRUE); } else ret = NOTDONE; *** *** 2799,2805 */ case '{': ret = get_lambda_tv(arg, rettv, evaluate); if (ret == NOTDONE) ! ret = eval_dict(arg, rettv, flags, FALSE); break; /* --- 2799,2805 */ case '{': ret = get_lambda_tv(arg, rettv, evaluate); if (ret == NOTDONE) ! ret = eval_dict(arg, rettv, evalarg, FALSE); break; /* *** ../vim-8.2.1067/src/dict.c 2020-06-24 18:37:28.355249390 +0200 --- src/dict.c 2020-06-27 14:09:58.023658054 +0200 *** *** 792,801 * Return OK or FAIL. Returns NOTDONE for {expr}. */ int ! eval_dict(char_u **arg, typval_T *rettv, int flags, int literal) { ! int evaluate = flags & EVAL_EVALUATE; ! evalarg_T evalarg; dict_T*d = NULL; typval_T tvkey; typval_T tv; --- 792,801 * Return OK or FAIL. Returns NOTDONE for {expr}. */ int ! eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) { ! int evaluate = evalarg == NULL ? FALSE !: evalarg->eval_flags & EVAL_EVALUATE; dict_T*d = NULL; typval_T tvkey; typval_T tv; *** *** 804,812 char_u*start = skipwhite(*arg + 1); char_ubuf[NUMBUFLEN]; int vim9script = current_sctx.sc_version == SCRIPT_VERSION_VIM9; ! ! CLEAR_FIELD(evalarg); ! evalarg.eval_flags = flags; /* * First check if it's not a curly-braces thing: {expr}. --- 804,811 char_u*start = skipwhite(*arg + 1); char_ubuf[NUMBUFLEN]; int vim9script = current_sctx.sc_version == SCRIPT_VERSION_VIM9; ! int had_comma; ! int getnext; /* * First check if it's not a curly-braces thing: {expr}. *** *** 833,843 tv.v_type = VAR_UNKNOWN; *arg = skipwhite(*arg + 1); while (**arg != '}' && **arg != NUL) { if ((literal ? get_literal_key(arg, ) ! : eval1(arg, , )) == FAIL)// recursive! goto failret; if (**arg != ':') --- 832,845 tv.v_type = VAR_UNKNOWN; *arg = skipwhite(*arg + 1); + eval_next_non_blank(*arg, evalarg, ); + if (getnext) + *arg = eval_next_line(evalarg); while (**arg != '}' && **arg != NUL) { if ((literal ? get_literal_key(arg, ) ! : eval1(arg, , evalarg)) == FAIL) // recursive! goto failret; if (**arg != ':') *** *** 857,865 goto failret; } } *arg = skipwhite(*arg + 1); ! if (eval1(arg, , ) == FAIL) // recursive! { if (evaluate) clear_tv(); --- 859,875 goto failret; } } + if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) + { + semsg(_(e_white_after), ":"); + goto failret; + } *arg = skipwhite(*arg + 1); ! eval_next_non_blank(*arg, evalarg, ); ! if (getnext) ! *arg = eval_next_line(evalarg); ! if (eval1(arg, , evalarg) == FAIL) // recursive! { if (evaluate) clear_tv(); *** *** 887,901 } clear_tv(); if (**arg == '}') break; ! if (**arg != ',') { if (evaluate) semsg(_(e_missing_dict_comma), *arg); goto failret; } - *arg = skipwhite(*arg + 1); } if (**arg != '}') --- 897,926 } clear_tv(); + // the comma must come after the value + had_comma = **arg == ','; + if (had_comma) + { + if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) + { + semsg(_(e_white_after), ","); + goto failret; + } +
Patch 8.2.1067
Patch 8.2.1067 Problem:Expression "!expr->func()" does not work. Solution: Apply plus and minus earlier. (closes #6348) Files: src/eval.c, src/proto/eval.pro, src/evalvars.c, src/userfunc.c, src/testdir/test_expr.vim, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1066/src/eval.c 2020-06-26 22:46:23.229370947 +0200 --- src/eval.c 2020-06-27 12:55:24.069015504 +0200 *** *** 51,57 static int eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg); static int eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int want_string); static int eval7(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int want_string); ! static int eval7_leader(typval_T *rettv, char_u *start_leader, char_u **end_leaderp); static int free_unref_items(int copyID); static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end); --- 51,57 static int eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg); static int eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int want_string); static int eval7(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int want_string); ! static int eval7_leader(typval_T *rettv, int numeric_only, char_u *start_leader, char_u **end_leaderp); static int free_unref_items(int copyID); static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end); *** *** 2756,2761 --- 2756,2766 case '8': case '9': case '.': ret = get_number_tv(arg, rettv, evaluate, want_string); + + // Apply prefixed "-" and "+" now. Matters especially when + // "->" follows. + if (ret == OK && evaluate && end_leader > start_leader) + ret = eval7_leader(rettv, TRUE, start_leader, _leader); break; /* *** *** 2879,2901 // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) ! ret = handle_subscript(arg, rettv, flags, TRUE, ! start_leader, _leader); /* * Apply logical NOT and unary '-', from right to left, ignore '+'. */ if (ret == OK && evaluate && end_leader > start_leader) ! ret = eval7_leader(rettv, start_leader, _leader); return ret; } /* * Apply the leading "!" and "-" before an eval7 expression to "rettv". * Adjusts "end_leaderp" until it is at "start_leader". */ static int ! eval7_leader(typval_T *rettv, char_u *start_leader, char_u **end_leaderp) { char_u*end_leader = *end_leaderp; int ret = OK; --- 2884,2910 // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) ! ret = handle_subscript(arg, rettv, flags, TRUE); /* * Apply logical NOT and unary '-', from right to left, ignore '+'. */ if (ret == OK && evaluate && end_leader > start_leader) ! ret = eval7_leader(rettv, FALSE, start_leader, _leader); return ret; } /* * Apply the leading "!" and "-" before an eval7 expression to "rettv". + * When "numeric_only" is TRUE only handle "+" and "-". * Adjusts "end_leaderp" until it is at "start_leader". */ static int ! eval7_leader( ! typval_T*rettv, ! int numeric_only, ! char_u *start_leader, ! char_u **end_leaderp) { char_u*end_leader = *end_leaderp; int ret = OK; *** *** 2921,2926 --- 2930,2940 --end_leader; if (*end_leader == '!') { + if (numeric_only) + { + ++end_leader; + break; + } #ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) f = !f; *** *** 4871,4879 char_u**arg, typval_T *rettv, int flags, // do more than finding the end ! int verbose,// give error messages ! char_u*start_leader, // start of '!' and '-' prefixes ! char_u**end_leaderp) // end of '!' and '-' prefixes { int evaluate = flags & EVAL_EVALUATE; int ret = OK; --- 4885,4891 char_u**arg, typval_T *rettv, int flags, // do more than finding the end ! int verbose)// give error messages { int evaluate = flags & EVAL_EVALUATE; int ret = OK; *** *** 4910,4919 } else if (**arg == '-') { - // Expression "-1.0->method()" applies the leader "-" before - // applying ->. - if (evaluate && *end_leaderp > start_leader) -
Patch 8.2.1066
Patch 8.2.1066 Problem:Lua arrays are zero based. Solution: Make Lua arrays one based. (Prabir Shrestha, closes #6347) Note: this is not backwards compatible. Files: runtime/doc/if_lua.txt, src/if_lua.c, src/testdir/test_lua.vim *** ../vim-8.2.1065/runtime/doc/if_lua.txt 2020-06-25 19:27:53.032387614 +0200 --- runtime/doc/if_lua.txt 2020-06-27 12:29:15.345494160 +0200 *** *** 217,227 Lua are reflected in Vim and vice-versa. A list "l" has the following properties and methods: Properties -- o "#l" is the number of items in list "l", equivalent to "len(l)" in Vim. ! o "l[k]" returns the k-th item in "l"; "l" is zero-indexed, as in Vim. To modify the k-th item, simply do "l[k] = newitem"; in particular, "l[k] = nil" removes the k-th item from "l". o "l()" returns an iterator for "l". --- 217,231 Lua are reflected in Vim and vice-versa. A list "l" has the following properties and methods: + NOTE: In patch 8.2.1066 array indexes were changed from zero-based to + one-based. You can check with: > + if has("patch-8.2.1066") + Properties -- o "#l" is the number of items in list "l", equivalent to "len(l)" in Vim. ! o "l[k]" returns the k-th item in "l"; "l" is one-indexed, as in Lua. To modify the k-th item, simply do "l[k] = newitem"; in particular, "l[k] = nil" removes the k-th item from "l". o "l()" returns an iterator for "l". *** *** 237,247 :let l = [1, 'item'] :lua l = vim.eval('l') -- same 'l' :lua l:add(vim.list()) ! :lua l[0] = math.pi :echo l[0] " 3.141593 ! :lua l[0] = nil -- remove first item :lua l:insert(true, 1) ! :lua print(l, #l, l[0], l[1], l[-1]) :lua for item in l() do print(item) end < --- 241,251 :let l = [1, 'item'] :lua l = vim.eval('l') -- same 'l' :lua l:add(vim.list()) ! :lua l[1] = math.pi :echo l[0] " 3.141593 ! :lua l[1] = nil -- remove first item :lua l:insert(true, 1) ! :lua print(l, #l, l[1], l[2]) :lua for item in l() do print(item) end < *** ../vim-8.2.1065/src/if_lua.c2020-06-25 20:56:38.723128804 +0200 --- src/if_lua.c2020-06-27 12:32:22.164244827 +0200 *** *** 871,877 list_T *l = luaV_unbox(L, luaV_List, 1); if (lua_isnumber(L, 2)) // list item? { ! listitem_T *li = list_find(l, (long) luaL_checkinteger(L, 2)); if (li == NULL) lua_pushnil(L); else --- 871,883 list_T *l = luaV_unbox(L, luaV_List, 1); if (lua_isnumber(L, 2)) // list item? { ! long n = (long) luaL_checkinteger(L, 2); ! listitem_T *li; ! ! // Lua array index starts with 1 while Vim uses 0, subtract 1 to ! // normalize. ! n -= 1; ! li = list_find(l, n); if (li == NULL) lua_pushnil(L); else *** *** 900,905 --- 906,915 list_T *l = luaV_unbox(L, luaV_List, 1); long n = (long) luaL_checkinteger(L, 2); listitem_T *li; + + // Lua array index starts with 1 while Vim uses 0, subtract 1 to normalize. + n -= 1; + if (l->lv_lock) luaL_error(L, "list is locked"); li = list_find(l, n); *** ../vim-8.2.1065/src/testdir/test_lua.vim2020-06-25 19:27:53.036387595 +0200 --- src/testdir/test_lua.vim2020-06-27 12:24:13.893946785 +0200 *** *** 327,334 call assert_equal(7, luaeval('#l')) call assert_match('^list: \%(0x\)\?\x\+$', luaeval('tostring(l)')) ! lua l[0] = 124 ! lua l[5] = nil lua l:insert('first') lua l:insert('xx', 3) call assert_equal(['first', 124, 'abc', 'xx', v:true, v:false, v:null, {'a': 1, 'b': 2, 'c': 3}], l) --- 327,334 call assert_equal(7, luaeval('#l')) call assert_match('^list: \%(0x\)\?\x\+$', luaeval('tostring(l)')) ! lua l[1] = 124 ! lua l[6] = nil lua l:insert('first') lua l:insert('xx', 3) call assert_equal(['first', 124, 'abc', 'xx', v:true, v:false, v:null, {'a': 1, 'b': 2, 'c': 3}], l) *** *** 367,388 lua l = vim.list():add(1):add(2) lua l = l:add(l) ! call assert_equal(1, luaeval('l[0]')) ! call assert_equal(2, luaeval('l[1]')) ! call assert_equal(1, luaeval('l[2][0]')) ! call assert_equal(2, luaeval('l[2][1]')) ! call assert_equal(1, luaeval('l[2][2][0]')) ! call assert_equal(2, luaeval('l[2][2][1]')) call assert_equal('[1, 2, [...]]', string(luaeval('l'))) call assert_match('^list: \%(0x\)\?\x\+$', luaeval('tostring(l)')) ! call assert_equal(luaeval('tostring(l)'), luaeval('tostring(l[2])')) ! call assert_equal(luaeval('l'), luaeval('l[2]')) ! call assert_equal(luaeval('l'), luaeval('l[2][2]')) lua l = nil endfunc ---