Compare commits

...

6 Commits

Author SHA1 Message Date
Bram Moolenaar
c753478b82 patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Problem:    MS-Windows: warning for using fstat() with stat_T.
Solution:   use _fstat64() if available. (Naruhiko Nishino, closes #6625)
2020-08-05 12:10:50 +02:00
Bram Moolenaar
14ddd226da patch 8.2.1369: MS-Windows: autocommand test sometimes fails
Problem:    MS-Windows: autocommand test sometimes fails.
Solution:   Do not rely on the cat command.
2020-08-05 12:02:40 +02:00
Bram Moolenaar
ff1cd39cfe patch 8.2.1368: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around <, !=, etc.
2020-08-05 11:51:30 +02:00
Bram Moolenaar
b4caa163ff patch 8.2.1367: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around *, / and %.
2020-08-05 11:36:52 +02:00
Bram Moolenaar
a6296200bd patch 8.2.1366: test 49 is old style
Problem:    Test 49 is old style.
Solution:   Convert several tests to new style. (Yegappan Lakshmanan,
            closes #6629)
2020-08-05 11:23:13 +02:00
Bram Moolenaar
bb1b5e24ec patch 8.2.1365: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space. (closes #6618)
2020-08-05 10:53:21 +02:00
13 changed files with 2036 additions and 1788 deletions

View File

@@ -2422,7 +2422,7 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* var1 isnot var2
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2452,9 +2452,17 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
typval_T var2;
int ic;
int vim9script = in_vim9script();
int evaluate = evalarg == NULL
? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
{
error_white_both(p, len);
clear_tv(rettv);
return FAIL;
}
if (vim9script && type_is && (p[len] == '?' || p[len] == '#'))
{
@@ -2482,13 +2490,19 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(p + len, evalarg);
if (eval5(arg, &var2, evalarg) == FAIL)
{
clear_tv(rettv);
return FAIL;
}
if (evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE))
if (evaluate)
{
int ret;
@@ -2552,7 +2566,7 @@ eval_addlist(typval_T *tv1, typval_T *tv2)
* .. string concatenation
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2574,6 +2588,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
int getnext;
char_u *p;
int op;
int oplen;
int concat;
typval_T var2;
@@ -2584,11 +2599,20 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (op != '+' && op != '-' && !concat)
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
oplen = (concat && p[1] == '.') ? 2 : 1;
if (getnext)
*arg = eval_next_line(evalarg);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, oplen);
clear_tv(rettv);
return FAIL;
}
*arg = p;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
}
if ((op != '+' || (rettv->v_type != VAR_LIST
&& rettv->v_type != VAR_BLOB))
#ifdef FEAT_FLOAT
@@ -2613,9 +2637,13 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
if (op == '.' && *(*arg + 1) == '.') // .. string concatenation
++*arg;
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
{
error_white_both(p, oplen);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
if (eval6(arg, &var2, evalarg, op == '.') == FAIL)
{
clear_tv(rettv);
@@ -2740,7 +2768,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* % number modulo
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2782,17 +2810,25 @@ eval6(
if (op != '*' && op != '/' && op != '%')
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = p;
}
#ifdef FEAT_FLOAT
f1 = 0;
f2 = 0;
#endif
error = FALSE;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (evaluate)
{
#ifdef FEAT_FLOAT
@@ -2815,7 +2851,13 @@ eval6(
/*
* Get the second variable.
*/
*arg = skipwhite(*arg + 1);
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (eval7(arg, &var2, evalarg, FALSE) == FAIL)
return FAIL;
@@ -2928,7 +2970,7 @@ eval6(
* trailing ->name() method call
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -3358,6 +3400,7 @@ eval_method(
}
else
{
*arg = skipwhite(*arg);
if (**arg != '(')
{
if (verbose)
@@ -4841,7 +4884,7 @@ get_env_len(char_u **arg)
/*
* Get the length of the name of a function or internal variable.
* "arg" is advanced to the first non-white character after the name.
* "arg" is advanced to after the name.
* Return 0 if something is wrong.
*/
int
@@ -4867,7 +4910,7 @@ get_id_len(char_u **arg)
return 0;
len = (int)(p - *arg);
*arg = skipwhite(p);
*arg = p;
return len;
}

View File

@@ -1137,6 +1137,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
}
else
{
arg = skipwhite(arg);
if (tofree != NULL)
name = tofree;
if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
@@ -3358,6 +3359,7 @@ assert_error(garray_T *gap)
int
var_exists(char_u *var)
{
char_u *arg = var;
char_u *name;
char_u *tofree;
typval_T tv;
@@ -3366,7 +3368,7 @@ var_exists(char_u *var)
// get_name_len() takes care of expanding curly braces
name = var;
len = get_name_len(&var, &tofree, TRUE, FALSE);
len = get_name_len(&arg, &tofree, TRUE, FALSE);
if (len > 0)
{
if (tofree != NULL)
@@ -3375,12 +3377,13 @@ var_exists(char_u *var)
if (n)
{
// handle d.key, l[idx], f(expr)
n = (handle_subscript(&var, &tv, &EVALARG_EVALUATE, FALSE) == OK);
arg = skipwhite(arg);
n = (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, FALSE) == OK);
if (n)
clear_tv(&tv);
}
}
if (*var != NUL)
if (*arg != NUL)
n = FALSE;
vim_free(tofree);

View File

@@ -166,7 +166,15 @@
# ifndef MSWIN
# define mch_access(n, p) access((n), (p))
# endif
// Use 64-bit fstat function if available.
// NOTE: This condition is the same as for the stat_T type.
# if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__MINGW32__)
# define mch_fstat(n, p) _fstat64((n), (p))
# else
# define mch_fstat(n, p) fstat((n), (p))
# endif
# ifdef MSWIN // has its own mch_stat() function
# define mch_stat(n, p) vim_stat((n), (p))
# else

View File

@@ -17,6 +17,7 @@ char_u *peek_next_line_from_context(cctx_T *cctx);
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
char_u *to_name_const_end(char_u *arg);
exptype_T get_compare_type(char_u *p, int *len, int *type_is);
void error_white_both(char_u *op, int len);
int assignment_len(char_u *p, int *heredoc);
void vim9_declare_error(char_u *name);
int check_vim9_unlet(char_u *name);

View File

@@ -0,0 +1,69 @@
" Functions shared by the tests for Vim Script
" Commands to track the execution path of a script
com! XpathINIT let g:Xpath = ''
com! -nargs=1 -bar Xpath let g:Xpath ..= <args>
com! XloopINIT let g:Xloop = 1
com! -nargs=1 -bar Xloop let g:Xpath ..= <args> .. g:Xloop
com! XloopNEXT let g:Xloop += 1
" MakeScript() - Make a script file from a function. {{{2
"
" Create a script that consists of the body of the function a:funcname.
" Replace any ":return" by a ":finish", any argument variable by a global
" variable, and every ":call" by a ":source" for the next following argument
" in the variable argument list. This function is useful if similar tests are
" to be made for a ":return" from a function call or a ":finish" in a script
" file.
func MakeScript(funcname, ...)
let script = tempname()
execute "redir! >" . script
execute "function" a:funcname
redir END
execute "edit" script
" Delete the "function" and the "endfunction" lines. Do not include the
" word "function" in the pattern since it might be translated if LANG is
" set. When MakeScript() is being debugged, this deletes also the debugging
" output of its line 3 and 4.
exec '1,/.*' . a:funcname . '(.*)/d'
/^\d*\s*endfunction\>/,$d
%s/^\d*//e
%s/return/finish/e
%s/\<a:\(\h\w*\)/g:\1/ge
normal gg0
let cnt = 0
while search('\<call\s*\%(\u\|s:\)\w*\s*(.*)', 'W') > 0
let cnt = cnt + 1
s/\<call\s*\%(\u\|s:\)\w*\s*(.*)/\='source ' . a:{cnt}/
endwhile
g/^\s*$/d
write
bwipeout
return script
endfunc
" ExecAsScript - Source a temporary script made from a function. {{{2
"
" Make a temporary script file from the function a:funcname, ":source" it, and
" delete it afterwards. However, if an exception is thrown the file may remain,
" the caller should call DeleteTheScript() afterwards.
let s:script_name = ''
function! ExecAsScript(funcname)
" Make a script from the function passed as argument.
let s:script_name = MakeScript(a:funcname)
" Source and delete the script.
exec "source" s:script_name
call delete(s:script_name)
let s:script_name = ''
endfunction
function! DeleteTheScript()
if s:script_name
call delete(s:script_name)
let s:script_name = ''
endif
endfunc
com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)

View File

@@ -1,25 +1,4 @@
Results of test49.vim:
*** Test 18: OK (67224583)
*** Test 19: OK (69275973)
*** Test 20: OK (1874575085)
*** Test 21: OK (147932225)
*** Test 22: OK (4161)
*** Test 23: OK (49)
*** Test 24: OK (41)
*** Test 27: OK (1996459)
*** Test 28: OK (1996459)
*** Test 29: OK (170428555)
*** Test 30: OK (190905173)
*** Test 31: OK (190905173)
*** Test 34: OK (2146584868)
*** Test 35: OK (2146584868)
*** Test 36: OK (1071644672)
*** Test 37: OK (1071644672)
*** Test 38: OK (357908480)
*** Test 39: OK (357908480)
*** Test 40: OK (357908480)
*** Test 49: OK (179000669)
*** Test 50: OK (363550045)
*** Test 52: OK (1247112011)
*** Test 53: OK (131071)
*** Test 54: OK (2047)

File diff suppressed because it is too large Load Diff

View File

@@ -1618,7 +1618,7 @@ func Test_change_mark_in_autocmds()
write
au! BufWritePre
if executable('cat')
if has('unix')
write XtestFilter
write >> XtestFilter

View File

@@ -726,6 +726,38 @@ def Test_expr4_vimscript()
set noignorecase
END
CheckScriptSuccess(lines)
# check missing white space
lines =<< trim END
vim9script
echo 2>3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2 >3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2> 3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2!=3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2 !=3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2!= 3
END
CheckScriptFailure(lines, 'E1004:')
enddef
func Test_expr4_fails()
@@ -841,6 +873,15 @@ def Test_expr5_vim9script()
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 +
77 -
22
assert_equal(66, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 'one'
@@ -872,6 +913,39 @@ def Test_expr5_vim9script()
echo 'abc' isnot? 'abc'
END
CheckScriptFailure(lines, 'E15:')
# check white space
lines =<< trim END
vim9script
echo 5+6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5 +6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5+ 6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a'..'b'
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a' ..'b'
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a'.. 'b'
END
CheckScriptFailure(lines, 'E1004:')
enddef
def Test_expr5_float()
@@ -966,7 +1040,7 @@ def Test_expr6()
enddef
def Test_expr6_vim9script()
# only checks line continuation
# check line continuation
let lines =<< trim END
vim9script
let var = 11
@@ -983,6 +1057,32 @@ def Test_expr6_vim9script()
assert_equal(5, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 *
22 /
3
assert_equal(80, var)
END
CheckScriptSuccess(lines)
# check white space
lines =<< trim END
vim9script
echo 5*6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5 *6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5* 6
END
CheckScriptFailure(lines, 'E1004:')
enddef
def Test_expr6_float()

File diff suppressed because it is too large Load Diff

View File

@@ -754,6 +754,18 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1370,
/**/
1369,
/**/
1368,
/**/
1367,
/**/
1366,
/**/
1365,
/**/
1364,
/**/

View File

@@ -4243,6 +4243,18 @@ compile_expr7(
return OK;
}
/*
* Give the "white on both sides" error, taking the operator from "p[len]".
*/
void
error_white_both(char_u *op, int len)
{
char_u buf[10];
vim_strncpy(buf, op, len);
semsg(_(e_white_both), buf);
}
/*
* * number multiplication
* / number division
@@ -4275,10 +4287,7 @@ compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[1]))
{
char_u buf[3];
vim_strncpy(buf, op, 1);
semsg(_(e_white_both), buf);
error_white_both(op, 1);
return FAIL;
}
*arg = skipwhite(op + 1);
@@ -4354,10 +4363,7 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen]))
{
char_u buf[3];
vim_strncpy(buf, op, oplen);
semsg(_(e_white_both), buf);
error_white_both(op, oplen);
return FAIL;
}
@@ -4486,10 +4492,7 @@ compile_expr4(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[len]))
{
char_u buf[7];
vim_strncpy(buf, p, len);
semsg(_(e_white_both), buf);
error_white_both(p, len);
return FAIL;
}
@@ -5132,10 +5135,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (oplen > 0 && (!VIM_ISWHITE(*sp) || !VIM_ISWHITE(op[oplen])))
{
char_u buf[4];
vim_strncpy(buf, op, oplen);
semsg(_(e_white_both), buf);
error_white_both(op, oplen);
return NULL;
}