Mercurial > vim
diff src/eval.c @ 7611:9c420b8db435 v7.4.1105
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 16 16:49:28 2016 +0100
patch 7.4.1105
Problem: When using slices there is a mixup of variable name and namespace.
Solution: Recognize variables that can't be a namespace. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 16 Jan 2016 17:00:05 +0100 |
parents | 8fc60af6dbf5 |
children | 228ff048db20 |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -115,6 +115,8 @@ static char *e_illvar = N_("E461: Illega static char *e_float_as_string = N_("E806: using Float as a String"); #endif +#define NAMESPACE_CHAR (char_u *)"abglstvw" + static dictitem_T globvars_var; /* variable used for g: */ #define globvarht globvardict.dv_hashtab @@ -20666,7 +20668,17 @@ get_id_len(arg) /* Find the end of the name. */ for (p = *arg; eval_isnamec(*p); ++p) - ; + { + if (*p == ':') + { + /* "s:" is start of "s:var", but "n:" is not and can be used in + * slice "[n:]". Also "xx:" is not a namespace. */ + len = (int)(p - *arg); + if ((len == 1 && vim_strchr(NAMESPACE_CHAR, **arg) == NULL) + || len > 1) + break; + } + } if (p == *arg) /* no name found */ return 0; @@ -20766,6 +20778,7 @@ find_name_end(arg, expr_start, expr_end, int mb_nest = 0; int br_nest = 0; char_u *p; + int len; if (expr_start != NULL) { @@ -20801,6 +20814,15 @@ find_name_end(arg, expr_start, expr_end, if (*p == NUL) break; } + else if (br_nest == 0 && mb_nest == 0 && *p == ':') + { + /* "s:" is start of "s:var", but "n:" is not and can be used in + * slice "[n:]". Also "xx:" is not a namespace. */ + len = (int)(p - arg); + if ((len == 1 && vim_strchr(NAMESPACE_CHAR, *arg) == NULL) + || len > 1) + break; + } if (mb_nest == 0) {