Mercurial > vim
diff src/vim9compile.c @ 21630:3c6c52fbc8ea v8.2.1365
patch 8.2.1365: Vim9: no error for missing white space around operator
Commit: https://github.com/vim/vim/commit/bb1b5e24ecc0abe1fee164e9de13796989eff784
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 5 10:53:21 2020 +0200
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 https://github.com/vim/vim/issues/6618)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Aug 2020 11:00:08 +0200 |
parents | d0128ecd4341 |
children | a640bc762196 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4244,6 +4244,18 @@ compile_expr7( } /* + * 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 * % number modulo @@ -4275,10 +4287,7 @@ compile_expr6(char_u **arg, cctx_T *cctx 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 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 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 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; }