Mercurial > vim
comparison src/eval.c @ 8839:9fa567d13551 v7.4.1707
commit https://github.com/vim/vim/commit/0921ecff1c5a74541bad6c073e8ade32247403d8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 3 22:44:36 2016 +0200
patch 7.4.1707
Problem: Cannot use empty dictionary key, even though it can be useful.
Solution: Allow using an empty dictionary key.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Apr 2016 22:45:05 +0200 |
parents | 6f41d68aa68e |
children | b76195a1e38e |
comparison
equal
deleted
inserted
replaced
8838:84ea805e989e | 8839:9fa567d13551 |
---|---|
2780 if (lp->ll_tv->v_type == VAR_DICT) | 2780 if (lp->ll_tv->v_type == VAR_DICT) |
2781 { | 2781 { |
2782 if (len == -1) | 2782 if (len == -1) |
2783 { | 2783 { |
2784 /* "[key]": get key from "var1" */ | 2784 /* "[key]": get key from "var1" */ |
2785 key = get_tv_string(&var1); /* is number or string */ | 2785 key = get_tv_string_chk(&var1); /* is number or string */ |
2786 if (*key == NUL) | 2786 if (key == NULL) |
2787 { | 2787 { |
2788 if (!quiet) | |
2789 EMSG(_(e_emptykey)); | |
2790 clear_tv(&var1); | 2788 clear_tv(&var1); |
2791 return NULL; | 2789 return NULL; |
2792 } | 2790 } |
2793 } | 2791 } |
2794 lp->ll_list = NULL; | 2792 lp->ll_list = NULL; |
5621 { | 5619 { |
5622 dictitem_T *item; | 5620 dictitem_T *item; |
5623 | 5621 |
5624 if (len == -1) | 5622 if (len == -1) |
5625 { | 5623 { |
5626 key = get_tv_string(&var1); | 5624 key = get_tv_string_chk(&var1); |
5627 if (*key == NUL) | 5625 if (key == NULL) |
5628 { | 5626 { |
5629 if (verbose) | |
5630 EMSG(_(e_emptykey)); | |
5631 clear_tv(&var1); | 5627 clear_tv(&var1); |
5632 return FAIL; | 5628 return FAIL; |
5633 } | 5629 } |
5634 } | 5630 } |
5635 | 5631 |
7752 goto failret; | 7748 goto failret; |
7753 } | 7749 } |
7754 if (evaluate) | 7750 if (evaluate) |
7755 { | 7751 { |
7756 key = get_tv_string_buf_chk(&tvkey, buf); | 7752 key = get_tv_string_buf_chk(&tvkey, buf); |
7757 if (key == NULL || *key == NUL) | 7753 if (key == NULL) |
7758 { | 7754 { |
7759 /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */ | 7755 /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */ |
7760 if (key != NULL) | |
7761 EMSG(_(e_emptykey)); | |
7762 clear_tv(&tvkey); | 7756 clear_tv(&tvkey); |
7763 goto failret; | 7757 goto failret; |
7764 } | 7758 } |
7765 } | 7759 } |
7766 | 7760 |