mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
5194e3bc45
@ -2160,11 +2160,9 @@ get_lval (
|
|||||||
|
|
||||||
if (lp->ll_tv->v_type == VAR_DICT) {
|
if (lp->ll_tv->v_type == VAR_DICT) {
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
/* "[key]": get key from "var1" */
|
// "[key]": get key from "var1"
|
||||||
key = get_tv_string(&var1); /* is number or string */
|
key = get_tv_string_chk(&var1); // is number or string
|
||||||
if (*key == NUL) {
|
if (key == NULL) {
|
||||||
if (!quiet)
|
|
||||||
EMSG(_(e_emptykey));
|
|
||||||
clear_tv(&var1);
|
clear_tv(&var1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -4615,10 +4613,8 @@ eval_index (
|
|||||||
dictitem_T *item;
|
dictitem_T *item;
|
||||||
|
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
key = get_tv_string(&var1);
|
key = get_tv_string_chk(&var1);
|
||||||
if (*key == NUL) {
|
if (key == NULL) {
|
||||||
if (verbose)
|
|
||||||
EMSG(_(e_emptykey));
|
|
||||||
clear_tv(&var1);
|
clear_tv(&var1);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -6602,10 +6598,8 @@ static int get_dict_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
}
|
}
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
key = get_tv_string_buf_chk(&tvkey, buf);
|
key = get_tv_string_buf_chk(&tvkey, buf);
|
||||||
if (key == NULL || *key == NUL) {
|
if (key == NULL) {
|
||||||
/* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
|
// "key" is NULL when get_tv_string_buf_chk() gave an errmsg
|
||||||
if (key != NULL)
|
|
||||||
EMSG(_(e_emptykey));
|
|
||||||
clear_tv(&tvkey);
|
clear_tv(&tvkey);
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
|
@ -368,8 +368,7 @@ hash_T hash_hash(char_u *key)
|
|||||||
hash_T hash = *key;
|
hash_T hash = *key;
|
||||||
|
|
||||||
if (hash == 0) {
|
if (hash == 0) {
|
||||||
// Empty keys are not allowed, but we don't want to crash if we get one.
|
return (hash_T)0;
|
||||||
return (hash_T) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A simplistic algorithm that appears to do very well.
|
// A simplistic algorithm that appears to do very well.
|
||||||
|
@ -38,3 +38,17 @@ func Test_strcharpart()
|
|||||||
|
|
||||||
call assert_equal('a', strcharpart('axb', -1, 2))
|
call assert_equal('a', strcharpart('axb', -1, 2))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_dict()
|
||||||
|
let d = {'': 'empty', 'a': 'a', 0: 'zero'}
|
||||||
|
call assert_equal('empty', d[''])
|
||||||
|
call assert_equal('a', d['a'])
|
||||||
|
call assert_equal('zero', d[0])
|
||||||
|
call assert_true(has_key(d, ''))
|
||||||
|
call assert_true(has_key(d, 'a'))
|
||||||
|
|
||||||
|
let d[''] = 'none'
|
||||||
|
let d['a'] = 'aaa'
|
||||||
|
call assert_equal('none', d[''])
|
||||||
|
call assert_equal('aaa', d['a'])
|
||||||
|
endfunc
|
||||||
|
@ -737,7 +737,7 @@ static int included_patches[] = {
|
|||||||
// 1710 NA
|
// 1710 NA
|
||||||
// 1709 NA
|
// 1709 NA
|
||||||
// 1708,
|
// 1708,
|
||||||
// 1707,
|
1707,
|
||||||
// 1706 NA
|
// 1706 NA
|
||||||
// 1705 NA
|
// 1705 NA
|
||||||
1704,
|
1704,
|
||||||
|
Loading…
Reference in New Issue
Block a user