Skip to content

Commit a530cca

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 48eaf51 + b8d732e commit a530cca

33 files changed

Lines changed: 3240 additions & 2833 deletions

runtime/doc/eval.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.2. Last change: 2020 Jul 21
1+
*eval.txt* For Vim version 8.2. Last change: 2020 Aug 01
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -4285,6 +4285,8 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()*
42854285
line number
42864286
<sflnum> script file line number, also when in
42874287
a function
4288+
<SID> "<SNR>123_" where "123" is the
4289+
current script ID |<SID>|
42884290
<cword> word under the cursor
42894291
<cWORD> WORD under the cursor
42904292
<client> the {clientid} of the last received
@@ -12146,7 +12148,8 @@ text...
1214612148
{endmarker}
1214712149
Set internal variable {var-name} to a |List|
1214812150
containing the lines of text bounded by the string
12149-
{endmarker}.
12151+
{endmarker}. The lines of text is used as a
12152+
|literal-string|.
1215012153
{endmarker} must not contain white space.
1215112154
{endmarker} cannot start with a lower case character.
1215212155
The last line should end only with the {endmarker}

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ test_libvterm:
23272327

23282328
# Run individual OLD style test.
23292329
# These do not depend on the executable, compile it when needed.
2330-
test1 test49 test59:
2330+
test1 test49:
23312331
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
23322332

23332333
# Run individual NEW style test.

src/eval.c

Lines changed: 117 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
300300
s = skipwhite(s);
301301
if (eval1_emsg(&s, rettv, NULL) == FAIL)
302302
return FAIL;
303-
if (*s != NUL) // check for trailing chars after expr
303+
if (*skipwhite(s) != NUL) // check for trailing chars after expr
304304
{
305305
clear_tv(rettv);
306306
semsg(_(e_invexpr2), s);
@@ -903,6 +903,7 @@ get_lval(
903903
clear_tv(&var1);
904904
return NULL;
905905
}
906+
p = skipwhite(p);
906907
}
907908

908909
// Optionally get the second index [ :expr].
@@ -2071,7 +2072,7 @@ eval0(
20712072
* expr2 ? expr1 : expr1
20722073
*
20732074
* "arg" must point to the first non-white of the expression.
2074-
* "arg" is advanced to the next non-white after the recognized expression.
2075+
* "arg" is advanced to just after the recognized expression.
20752076
*
20762077
* Note: "rettv.v_lock" is not set.
20772078
*
@@ -2110,7 +2111,15 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
21102111
if (getnext)
21112112
*arg = eval_next_line(evalarg_used);
21122113
else
2114+
{
2115+
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2116+
{
2117+
error_white_both(p, 1);
2118+
clear_tv(rettv);
2119+
return FAIL;
2120+
}
21132121
*arg = p;
2122+
}
21142123

21152124
result = FALSE;
21162125
if (evaluate)
@@ -2127,6 +2136,12 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
21272136
/*
21282137
* Get the second variable. Recursive!
21292138
*/
2139+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
2140+
{
2141+
error_white_both(p, 1);
2142+
clear_tv(rettv);
2143+
return FAIL;
2144+
}
21302145
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
21312146
evalarg_used->eval_flags = result ? orig_flags
21322147
: orig_flags & ~EVAL_EVALUATE;
@@ -2147,11 +2162,25 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
21472162
if (getnext)
21482163
*arg = eval_next_line(evalarg_used);
21492164
else
2165+
{
2166+
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2167+
{
2168+
error_white_both(p, 1);
2169+
clear_tv(rettv);
2170+
return FAIL;
2171+
}
21502172
*arg = p;
2173+
}
21512174

21522175
/*
21532176
* Get the third variable. Recursive!
21542177
*/
2178+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
2179+
{
2180+
error_white_both(p, 1);
2181+
clear_tv(rettv);
2182+
return FAIL;
2183+
}
21552184
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
21562185
evalarg_used->eval_flags = !result ? orig_flags
21572186
: orig_flags & ~EVAL_EVALUATE;
@@ -2178,7 +2207,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
21782207
* expr2 || expr2 || expr2 logical OR
21792208
*
21802209
* "arg" must point to the first non-white of the expression.
2181-
* "arg" is advanced to the next non-white after the recognized expression.
2210+
* "arg" is advanced to just after the recognized expression.
21822211
*
21832212
* Return OK or FAIL.
21842213
*/
@@ -2241,11 +2270,25 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
22412270
if (getnext)
22422271
*arg = eval_next_line(evalarg_used);
22432272
else
2273+
{
2274+
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2275+
{
2276+
error_white_both(p, 2);
2277+
clear_tv(rettv);
2278+
return FAIL;
2279+
}
22442280
*arg = p;
2281+
}
22452282

22462283
/*
22472284
* Get the second variable.
22482285
*/
2286+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
2287+
{
2288+
error_white_both(p, 2);
2289+
clear_tv(rettv);
2290+
return FAIL;
2291+
}
22492292
*arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
22502293
evalarg_used->eval_flags = !result ? orig_flags
22512294
: orig_flags & ~EVAL_EVALUATE;
@@ -2295,7 +2338,7 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
22952338
* expr3 && expr3 && expr3 logical AND
22962339
*
22972340
* "arg" must point to the first non-white of the expression.
2298-
* "arg" is advanced to the next non-white after the recognized expression.
2341+
* "arg" is advanced to just after the recognized expression.
22992342
*
23002343
* Return OK or FAIL.
23012344
*/
@@ -2358,11 +2401,25 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
23582401
if (getnext)
23592402
*arg = eval_next_line(evalarg_used);
23602403
else
2404+
{
2405+
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2406+
{
2407+
error_white_both(p, 2);
2408+
clear_tv(rettv);
2409+
return FAIL;
2410+
}
23612411
*arg = p;
2412+
}
23622413

23632414
/*
23642415
* Get the second variable.
23652416
*/
2417+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
2418+
{
2419+
error_white_both(p, 2);
2420+
clear_tv(rettv);
2421+
return FAIL;
2422+
}
23662423
*arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
23672424
evalarg_used->eval_flags = result ? orig_flags
23682425
: orig_flags & ~EVAL_EVALUATE;
@@ -2421,7 +2478,7 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
24212478
* var1 isnot var2
24222479
*
24232480
* "arg" must point to the first non-white of the expression.
2424-
* "arg" is advanced to the next non-white after the recognized expression.
2481+
* "arg" is advanced to just after the recognized expression.
24252482
*
24262483
* Return OK or FAIL.
24272484
*/
@@ -2451,9 +2508,17 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
24512508
typval_T var2;
24522509
int ic;
24532510
int vim9script = in_vim9script();
2511+
int evaluate = evalarg == NULL
2512+
? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
24542513

24552514
if (getnext)
24562515
*arg = eval_next_line(evalarg);
2516+
else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
2517+
{
2518+
error_white_both(p, len);
2519+
clear_tv(rettv);
2520+
return FAIL;
2521+
}
24572522

24582523
if (vim9script && type_is && (p[len] == '?' || p[len] == '#'))
24592524
{
@@ -2481,13 +2546,19 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
24812546
/*
24822547
* Get the second variable.
24832548
*/
2549+
if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))
2550+
{
2551+
error_white_both(p, 1);
2552+
clear_tv(rettv);
2553+
return FAIL;
2554+
}
24842555
*arg = skipwhite_and_linebreak(p + len, evalarg);
24852556
if (eval5(arg, &var2, evalarg) == FAIL)
24862557
{
24872558
clear_tv(rettv);
24882559
return FAIL;
24892560
}
2490-
if (evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE))
2561+
if (evaluate)
24912562
{
24922563
int ret;
24932564

@@ -2551,7 +2622,7 @@ eval_addlist(typval_T *tv1, typval_T *tv2)
25512622
* .. string concatenation
25522623
*
25532624
* "arg" must point to the first non-white of the expression.
2554-
* "arg" is advanced to the next non-white after the recognized expression.
2625+
* "arg" is advanced to just after the recognized expression.
25552626
*
25562627
* Return OK or FAIL.
25572628
*/
@@ -2573,6 +2644,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
25732644
int getnext;
25742645
char_u *p;
25752646
int op;
2647+
int oplen;
25762648
int concat;
25772649
typval_T var2;
25782650

@@ -2583,11 +2655,20 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
25832655
if (op != '+' && op != '-' && !concat)
25842656
break;
25852657

2658+
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
2659+
oplen = (concat && p[1] == '.') ? 2 : 1;
25862660
if (getnext)
25872661
*arg = eval_next_line(evalarg);
25882662
else
2663+
{
2664+
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
2665+
{
2666+
error_white_both(p, oplen);
2667+
clear_tv(rettv);
2668+
return FAIL;
2669+
}
25892670
*arg = p;
2590-
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
2671+
}
25912672
if ((op != '+' || (rettv->v_type != VAR_LIST
25922673
&& rettv->v_type != VAR_BLOB))
25932674
#ifdef FEAT_FLOAT
@@ -2612,9 +2693,13 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
26122693
/*
26132694
* Get the second variable.
26142695
*/
2615-
if (op == '.' && *(*arg + 1) == '.') // .. string concatenation
2616-
++*arg;
2617-
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
2696+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
2697+
{
2698+
error_white_both(p, oplen);
2699+
clear_tv(rettv);
2700+
return FAIL;
2701+
}
2702+
*arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
26182703
if (eval6(arg, &var2, evalarg, op == '.') == FAIL)
26192704
{
26202705
clear_tv(rettv);
@@ -2739,7 +2824,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
27392824
* % number modulo
27402825
*
27412826
* "arg" must point to the first non-white of the expression.
2742-
* "arg" is advanced to the next non-white after the recognized expression.
2827+
* "arg" is advanced to just after the recognized expression.
27432828
*
27442829
* Return OK or FAIL.
27452830
*/
@@ -2781,17 +2866,25 @@ eval6(
27812866
if (op != '*' && op != '/' && op != '%')
27822867
break;
27832868

2869+
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
27842870
if (getnext)
27852871
*arg = eval_next_line(evalarg);
27862872
else
2873+
{
2874+
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
2875+
{
2876+
error_white_both(p, 1);
2877+
clear_tv(rettv);
2878+
return FAIL;
2879+
}
27872880
*arg = p;
2881+
}
27882882

27892883
#ifdef FEAT_FLOAT
27902884
f1 = 0;
27912885
f2 = 0;
27922886
#endif
27932887
error = FALSE;
2794-
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
27952888
if (evaluate)
27962889
{
27972890
#ifdef FEAT_FLOAT
@@ -2814,7 +2907,13 @@ eval6(
28142907
/*
28152908
* Get the second variable.
28162909
*/
2817-
*arg = skipwhite(*arg + 1);
2910+
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
2911+
{
2912+
error_white_both(p, 1);
2913+
clear_tv(rettv);
2914+
return FAIL;
2915+
}
2916+
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
28182917
if (eval7(arg, &var2, evalarg, FALSE) == FAIL)
28192918
return FAIL;
28202919

@@ -2927,7 +3026,7 @@ eval6(
29273026
* trailing ->name() method call
29283027
*
29293028
* "arg" must point to the first non-white of the expression.
2930-
* "arg" is advanced to the next non-white after the recognized expression.
3029+
* "arg" is advanced to just after the recognized expression.
29313030
*
29323031
* Return OK or FAIL.
29333032
*/
@@ -3357,6 +3456,7 @@ eval_method(
33573456
}
33583457
else
33593458
{
3459+
*arg = skipwhite(*arg);
33603460
if (**arg != '(')
33613461
{
33623462
if (verbose)
@@ -4840,7 +4940,7 @@ get_env_len(char_u **arg)
48404940

48414941
/*
48424942
* Get the length of the name of a function or internal variable.
4843-
* "arg" is advanced to the first non-white character after the name.
4943+
* "arg" is advanced to after the name.
48444944
* Return 0 if something is wrong.
48454945
*/
48464946
int
@@ -4866,7 +4966,7 @@ get_id_len(char_u **arg)
48664966
return 0;
48674967

48684968
len = (int)(p - *arg);
4869-
*arg = skipwhite(p);
4969+
*arg = p;
48704970

48714971
return len;
48724972
}

0 commit comments

Comments
 (0)