To: vim_dev@googlegroups.com Subject: Patch 8.2.1326 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1326 Problem: Vim9: skipping over white space after list. Solution: Do not skip white space, a following [] would be misinterpreted. (closes #6552) Fix a few side effects. Files: src/list.c, src/dict.c, src/eval.c, src/userfunc.c, src/testdir/test_functions.vim, src/testdir/test_gn.vim, src/testdir/test_popupwin.vim, src/testdir/test_tabpage.vim, src/testdir/test_textprop.vim, src/testdir/test_textobjects.vim *** ../vim-8.2.1325/src/list.c 2020-07-12 17:07:01.024810908 +0200 --- src/list.c 2020-07-29 22:18:27.813479171 +0200 *************** *** 1199,1205 **** had_comma = **arg == ','; if (had_comma) { ! if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) { semsg(_(e_white_after), ","); goto failret; --- 1199,1205 ---- had_comma = **arg == ','; if (had_comma) { ! if (vim9script && !IS_WHITE_OR_NUL((*arg)[1])) { semsg(_(e_white_after), ","); goto failret; *************** *** 1231,1237 **** return FAIL; } ! *arg = skipwhite(*arg + 1); if (evaluate) rettv_list_set(rettv, l); --- 1231,1237 ---- return FAIL; } ! *arg += 1; if (evaluate) rettv_list_set(rettv, l); *** ../vim-8.2.1325/src/dict.c 2020-07-12 17:07:01.020810937 +0200 --- src/dict.c 2020-07-30 20:07:45.513052246 +0200 *************** *** 838,843 **** --- 838,847 ---- : eval1(arg, &tvkey, evalarg)) == FAIL) // recursive! goto failret; + // The colon should come right after the key, but this wasn't checked + // previously, so only require it in Vim9 script. + if (!vim9script) + *arg = skipwhite(*arg); if (**arg != ':') { if (evaluate) *** ../vim-8.2.1325/src/eval.c 2020-07-29 21:20:37.926626437 +0200 --- src/eval.c 2020-07-30 19:57:48.530616176 +0200 *************** *** 1913,1939 **** char_u * eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext) { *getnext = FALSE; if (in_vim9script() && evalarg != NULL && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL) ! && (*arg == NUL || (VIM_ISWHITE(arg[-1]) ! && vim9_comment_start(arg)))) { ! char_u *p; if (evalarg->eval_cookie != NULL) ! p = getline_peek(evalarg->eval_getline, evalarg->eval_cookie); else ! p = peek_next_line_from_context(evalarg->eval_cctx); ! if (p != NULL) { *getnext = TRUE; ! return skipwhite(p); } } ! return arg; } /* --- 1913,1940 ---- char_u * eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext) { + char_u *p = skipwhite(arg); + *getnext = FALSE; if (in_vim9script() && evalarg != NULL && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL) ! && (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p)))) { ! char_u *next; if (evalarg->eval_cookie != NULL) ! next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie); else ! next = peek_next_line_from_context(evalarg->eval_cctx); ! if (next != NULL) { *getnext = TRUE; ! return skipwhite(next); } } ! return p; } /* *************** *** 2039,2044 **** --- 2040,2046 ---- p = skipwhite(arg); ret = eval1(&p, rettv, evalarg); + p = skipwhite(p); if (ret == FAIL || !ends_excmd2(arg, p)) { *************** *** 2107,2112 **** --- 2109,2116 ---- if (getnext) *arg = eval_next_line(evalarg_used); + else + *arg = p; result = FALSE; if (evaluate) *************** *** 2142,2147 **** --- 2146,2153 ---- } if (getnext) *arg = eval_next_line(evalarg_used); + else + *arg = p; /* * Get the third variable. Recursive! *************** *** 2234,2239 **** --- 2240,2247 ---- { if (getnext) *arg = eval_next_line(evalarg_used); + else + *arg = p; /* * Get the second variable. *************** *** 2349,2354 **** --- 2357,2364 ---- { if (getnext) *arg = eval_next_line(evalarg_used); + else + *arg = p; /* * Get the second variable. *************** *** 2575,2580 **** --- 2585,2592 ---- if (getnext) *arg = eval_next_line(evalarg); + else + *arg = p; evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE); if ((op != '+' || (rettv->v_type != VAR_LIST && rettv->v_type != VAR_BLOB)) *************** *** 2756,2761 **** --- 2768,2774 ---- int evaluate; int getnext; typval_T var2; + char_u *p; int op; varnumber_T n1, n2; #ifdef FEAT_FLOAT *************** *** 2763,2774 **** #endif int error; ! op = *eval_next_non_blank(*arg, evalarg, &getnext); if (op != '*' && op != '/' && op != '%') break; if (getnext) *arg = eval_next_line(evalarg); #ifdef FEAT_FLOAT f1 = 0; --- 2776,2790 ---- #endif int error; ! p = eval_next_non_blank(*arg, evalarg, &getnext); ! op = *p; if (op != '*' && op != '/' && op != '%') break; if (getnext) *arg = eval_next_line(evalarg); + else + *arg = p; #ifdef FEAT_FLOAT f1 = 0; *************** *** 3115,3122 **** vim_free(alias); } - *arg = skipwhite(*arg); - // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) --- 3131,3136 ---- *************** *** 5152,5158 **** p = eval_next_non_blank(*arg, evalarg, &getnext); if (getnext && ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1])) ! || (*p == '-' && p[1] == '>' && (p[2] == '{' || ASCII_ISALPHA(p[2]))))) { *arg = eval_next_line(evalarg); --- 5166,5172 ---- p = eval_next_non_blank(*arg, evalarg, &getnext); if (getnext && ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1])) ! || (p[0] == '-' && p[1] == '>' && (p[2] == '{' || ASCII_ISALPHA(p[2]))))) { *arg = eval_next_line(evalarg); *************** *** 5178,5185 **** dict_unref(selfdict); selfdict = NULL; } ! else if (**arg == '-' && (*arg)[1] == '>') { if (ret == OK) { if ((*arg)[2] == '{') --- 5192,5200 ---- dict_unref(selfdict); selfdict = NULL; } ! else if (p[0] == '-' && p[1] == '>') { + *arg = p; if (ret == OK) { if ((*arg)[2] == '{') *** ../vim-8.2.1325/src/userfunc.c 2020-07-29 14:40:21.863245604 +0200 --- src/userfunc.c 2020-07-30 20:04:42.449534779 +0200 *************** *** 642,647 **** --- 642,651 ---- break; } ++argcount; + // The comma should come right after the argument, but this wasn't + // checked previously, thus only enforce it in Vim9 script. + if (!in_vim9script()) + argp = skipwhite(argp); if (*argp != ',') break; } *** ../vim-8.2.1325/src/testdir/test_functions.vim 2020-07-11 22:14:54.314422214 +0200 --- src/testdir/test_functions.vim 2020-07-30 19:49:38.203861030 +0200 *************** *** 1355,1361 **** func! Tcomplete(arglead, cmdline, pos) return "item1\nitem2\nitem3" endfunc ! call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\" \ .. "\\", 'xt') delfunc Tcomplete call assert_equal('item1 item2 item3', c) --- 1355,1361 ---- func! Tcomplete(arglead, cmdline, pos) return "item1\nitem2\nitem3" endfunc ! call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\" \ .. "\\", 'xt') delfunc Tcomplete call assert_equal('item1 item2 item3', c) *** ../vim-8.2.1325/src/testdir/test_gn.vim 2020-04-28 20:29:04.237851565 +0200 --- src/testdir/test_gn.vim 2020-07-30 19:50:47.575688886 +0200 *************** *** 120,126 **** sil! %d_ " search using the \zs atom ! call setline(1, [' nnoremap', '' , 'nnoremap']) set wrapscan&vim let @/ = '\_s\zsnnoremap' $ --- 120,126 ---- sil! %d_ " search using the \zs atom ! call setline(1, [' nnoremap', '', 'nnoremap']) set wrapscan&vim let @/ = '\_s\zsnnoremap' $ *** ../vim-8.2.1325/src/testdir/test_popupwin.vim 2020-07-27 22:40:20.694572378 +0200 --- src/testdir/test_popupwin.vim 2020-07-30 19:59:11.830400027 +0200 *************** *** 588,594 **** call setline(1, range(100)) for nr in range(7) call setline(nr * 12 + 1, "fold {{{") ! call setline(nr * 12 + 11 , "end }}}") endfor %foldclose set shell=/bin/sh noruler --- 588,594 ---- call setline(1, range(100)) for nr in range(7) call setline(nr * 12 + 1, "fold {{{") ! call setline(nr * 12 + 11, "end }}}") endfor %foldclose set shell=/bin/sh noruler *** ../vim-8.2.1325/src/testdir/test_tabpage.vim 2020-07-23 16:36:59.828375424 +0200 --- src/testdir/test_tabpage.vim 2020-07-30 20:00:34.206185417 +0200 *************** *** 350,356 **** call Check_tab_count(6, cmd . ' 3', 3) call Check_tab_count(6, cmd . ' 8', 4) for n in range(2) ! for c in ['0', '.+3', '+', '+2' , '-', '-2' , '$', '+99', '-99'] if n == 0 " pre count let entire_cmd = c . cmd let err_code = 'E16:' --- 350,356 ---- call Check_tab_count(6, cmd . ' 3', 3) call Check_tab_count(6, cmd . ' 8', 4) for n in range(2) ! for c in ['0', '.+3', '+', '+2', '-', '-2', '$', '+99', '-99'] if n == 0 " pre count let entire_cmd = c . cmd let err_code = 'E16:' *** ../vim-8.2.1325/src/testdir/test_textprop.vim 2020-07-11 22:14:54.318422203 +0200 --- src/testdir/test_textprop.vim 2020-07-30 20:01:30.482038372 +0200 *************** *** 1219,1225 **** call assert_fails('call prop_find({}, "x")', 'E474:') call assert_fails('call prop_find({"lnum" : -2})', 'E16:') call assert_fails('call prop_list(1, [])', 'E715:') ! call assert_fails('call prop_list(-1 , {})', 'E16:') call assert_fails('call prop_remove([])', 'E474:') call assert_fails('call prop_remove({}, -2)', 'E16:') call assert_fails('call prop_remove({})', 'E968:') --- 1219,1225 ---- call assert_fails('call prop_find({}, "x")', 'E474:') call assert_fails('call prop_find({"lnum" : -2})', 'E16:') call assert_fails('call prop_list(1, [])', 'E715:') ! call assert_fails('call prop_list(-1, {})', 'E16:') call assert_fails('call prop_remove([])', 'E474:') call assert_fails('call prop_remove({}, -2)', 'E16:') call assert_fails('call prop_remove({})', 'E968:') *** ../vim-8.2.1325/src/testdir/test_textobjects.vim 2020-06-18 15:33:21.705578661 +0200 --- src/testdir/test_textobjects.vim 2020-07-30 20:05:53.205348497 +0200 *************** *** 201,228 **** call assert_equal("c", matchstr("abcd", ".", 2, 0)) call assert_equal("a", matchstr("abcd", ".", 0, -1)) call assert_equal(-1, match("abcd", ".", 0, 5)) ! call assert_equal(0 , match("abcd", ".", 0, -1)) ! call assert_equal(0 , match('abc', '.', 0, 1)) ! call assert_equal(1 , match('abc', '.', 0, 2)) ! call assert_equal(2 , match('abc', '.', 0, 3)) call assert_equal(-1, match('abc', '.', 0, 4)) ! call assert_equal(1 , match('abc', '.', 1, 1)) ! call assert_equal(2 , match('abc', '.', 2, 1)) call assert_equal(-1, match('abc', '.', 3, 1)) ! call assert_equal(3 , match('abc', '$', 0, 1)) call assert_equal(-1, match('abc', '$', 0, 2)) ! call assert_equal(3 , match('abc', '$', 1, 1)) ! call assert_equal(3 , match('abc', '$', 2, 1)) ! call assert_equal(3 , match('abc', '$', 3, 1)) call assert_equal(-1, match('abc', '$', 4, 1)) ! call assert_equal(0 , match('abc', '\zs', 0, 1)) ! call assert_equal(1 , match('abc', '\zs', 0, 2)) ! call assert_equal(2 , match('abc', '\zs', 0, 3)) ! call assert_equal(3 , match('abc', '\zs', 0, 4)) call assert_equal(-1, match('abc', '\zs', 0, 5)) ! call assert_equal(1 , match('abc', '\zs', 1, 1)) ! call assert_equal(2 , match('abc', '\zs', 2, 1)) ! call assert_equal(3 , match('abc', '\zs', 3, 1)) call assert_equal(-1, match('abc', '\zs', 4, 1)) endfunc --- 201,228 ---- call assert_equal("c", matchstr("abcd", ".", 2, 0)) call assert_equal("a", matchstr("abcd", ".", 0, -1)) call assert_equal(-1, match("abcd", ".", 0, 5)) ! call assert_equal(0, match("abcd", ".", 0, -1)) ! call assert_equal(0, match('abc', '.', 0, 1)) ! call assert_equal(1, match('abc', '.', 0, 2)) ! call assert_equal(2, match('abc', '.', 0, 3)) call assert_equal(-1, match('abc', '.', 0, 4)) ! call assert_equal(1, match('abc', '.', 1, 1)) ! call assert_equal(2, match('abc', '.', 2, 1)) call assert_equal(-1, match('abc', '.', 3, 1)) ! call assert_equal(3, match('abc', '$', 0, 1)) call assert_equal(-1, match('abc', '$', 0, 2)) ! call assert_equal(3, match('abc', '$', 1, 1)) ! call assert_equal(3, match('abc', '$', 2, 1)) ! call assert_equal(3, match('abc', '$', 3, 1)) call assert_equal(-1, match('abc', '$', 4, 1)) ! call assert_equal(0, match('abc', '\zs', 0, 1)) ! call assert_equal(1, match('abc', '\zs', 0, 2)) ! call assert_equal(2, match('abc', '\zs', 0, 3)) ! call assert_equal(3, match('abc', '\zs', 0, 4)) call assert_equal(-1, match('abc', '\zs', 0, 5)) ! call assert_equal(1, match('abc', '\zs', 1, 1)) ! call assert_equal(2, match('abc', '\zs', 2, 1)) ! call assert_equal(3, match('abc', '\zs', 3, 1)) call assert_equal(-1, match('abc', '\zs', 4, 1)) endfunc *** ../vim-8.2.1325/src/version.c 2020-07-29 22:10:42.037708767 +0200 --- src/version.c 2020-07-29 22:19:47.145319218 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1326, /**/ -- The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers /// 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 ///