summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dict.c b/src/dict.c
index d6b3b189a..c67eb42c5 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -605,6 +605,27 @@ dict_get_number(dict_T *d, char_u *key)
}
/*
+ * Get a number item from a dictionary.
+ * Returns 0 if the entry doesn't exist.
+ * Give an error if the entry is not a number.
+ */
+ varnumber_T
+dict_get_number_check(dict_T *d, char_u *key)
+{
+ dictitem_T *di;
+
+ di = dict_find(d, key, -1);
+ if (di == NULL)
+ return 0;
+ if (di->di_tv.v_type != VAR_NUMBER)
+ {
+ semsg(_(e_invarg2), tv_get_string(&di->di_tv));
+ return 0;
+ }
+ return tv_get_number(&di->di_tv);
+}
+
+/*
* Return an allocated string with the string representation of a Dictionary.
* May return NULL.
*/