diff options
Diffstat (limited to 'src/dict.c')
-rw-r--r-- | src/dict.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/dict.c b/src/dict.c index c2dc6a7c2..88cc4b3fc 100644 --- a/src/dict.c +++ b/src/dict.c @@ -649,6 +649,15 @@ dict_find(dict_T *d, char_u *key, int len) } /* + * Returns TRUE if "key" is present in Dictionary "d". + */ + int +dict_has_key(dict_T *d, char *key) +{ + return dict_find(d, (char_u *)key, -1) != NULL; +} + +/* * Get a typval_T item from a dictionary and copy it into "rettv". * Returns FAIL if the entry doesn't exist or out of memory. */ @@ -1582,8 +1591,8 @@ f_has_key(typval_T *argvars, typval_T *rettv) if (argvars[0].vval.v_dict == NULL) return; - rettv->vval.v_number = dict_find(argvars[0].vval.v_dict, - tv_get_string(&argvars[1]), -1) != NULL; + rettv->vval.v_number = dict_has_key(argvars[0].vval.v_dict, + (char *)tv_get_string(&argvars[1])); } #endif // defined(FEAT_EVAL) |