1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2020-08-05 10:53:21 +02:00
parent 282f9c64e5
commit bb1b5e24ec
7 changed files with 80 additions and 26 deletions

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;
}