summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-02 16:51:21 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-02 16:51:21 +0200
commitb0ebbda06cf1a4a7c40cb274529c4c53de534e32 (patch)
tree8f0a2b35f078b542cb168e58d273304ee18efeed /src/dict.c
parentca2f7037c1a53bdbb6f5dc0a2f92d50020e062cc (diff)
patch 8.1.1452: line and col property of popup windows not properly checkedv8.1.1452
Problem: Line and col property of popup windows not properly checked. Solution: Check for "+" or "-" sign.
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 d6b3b189a6..c67eb42c58 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.
*/