summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-02 17:36:54 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-02 17:36:54 +0100
commite0de171ecd2ff7acd56deda2cf81f0d13a69c803 (patch)
tree87667e0ae5a5517461d7f4e59514d9495170a05a /src/dict.c
parent7f76494aac512b1d603d9be4132184241f43872c (diff)
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntaxv8.2.2082
Problem: Vim9: can still use the depricated #{} dict syntax. Solution: Remove support for #{} in Vim9 script. (closes #7406, closes #7405)
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/dict.c b/src/dict.c
index 3b965d0ac2..819f5fa0ba 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -783,19 +783,30 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
}
/*
+ * Advance over a literal key, including "-". If the first character is not a
+ * literal key character then "key" is returned.
+ */
+ char_u *
+skip_literal_key(char_u *key)
+{
+ char_u *p;
+
+ for (p = key; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p)
+ ;
+ return p;
+}
+
+/*
* Get the key for #{key: val} into "tv" and advance "arg".
* Return FAIL when there is no valid key.
*/
static int
get_literal_key(char_u **arg, typval_T *tv)
{
- char_u *p;
+ char_u *p = skip_literal_key(*arg);
- if (!ASCII_ISALNUM(**arg) && **arg != '_' && **arg != '-')
+ if (p == *arg)
return FAIL;
-
- for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p)
- ;
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strnsave(*arg, p - *arg);
@@ -851,17 +862,15 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
while (**arg != '}' && **arg != NUL)
{
- char_u *p = to_name_end(*arg, FALSE);
+ int has_bracket = vim9script && **arg == '[';
- if (literal || (vim9script && *p == ':'))
+ if (literal || (vim9script && !has_bracket))
{
if (get_literal_key(arg, &tvkey) == FAIL)
goto failret;
}
else
{
- int has_bracket = vim9script && **arg == '[';
-
if (has_bracket)
*arg = skipwhite(*arg + 1);
if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive!