From 51c45e89b50a4841147b9fbd7c6095ab79a10c71 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Thu, 30 May 2024 07:50:08 +0200 Subject: patch 9.1.0450: evalc. code too complex Problem: eval.c code too complex Solution: refactor eval6() and eval9() functions into several smaller functions (Yegappan Lakshmanan) closes: #14875 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- src/dict.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/dict.c') diff --git a/src/dict.c b/src/dict.c index c78995d80e..bf45b0b928 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1091,6 +1091,33 @@ failret: return OK; } +/* + * Evaluate a literal dictionary: #{key: val, key: val} + * "*arg" points to the "#". + * On return, "*arg" points to the character after the Dict. + * Return OK or FAIL. Returns NOTDONE for {expr}. + */ + int +eval_lit_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg) +{ + int vim9script = in_vim9script(); + int ret = OK; + + if (vim9script) + { + ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE; + } + else if ((*arg)[1] == '{') + { + ++*arg; + ret = eval_dict(arg, rettv, evalarg, TRUE); + } + else + ret = NOTDONE; + + return ret; +} + /* * Go over all entries in "d2" and add them to "d1". * When "action" is "error" then a duplicate key is an error. -- cgit v1.2.3