comparison src/dict.c @ 13037:6e81a68d63a1 v8.0.1394

patch 8.0.1394: cannot intercept a yank command commit https://github.com/vim/vim/commit/7e1652c63c96585b9e2235c195a3c322b1f11595 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 16 18:27:02 2017 +0100 patch 8.0.1394: cannot intercept a yank command Problem: Cannot intercept a yank command. Solution: Add the TextYankPost autocommand event. (Philippe Vaucher et al., closes #2333)
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Dec 2017 18:30:05 +0100
parents 162bcd0debd7
children 3c80092eb211
comparison
equal deleted inserted replaced
13036:754780887de1 13037:6e81a68d63a1
45 d->dv_copyID = 0; 45 d->dv_copyID = 0;
46 } 46 }
47 return d; 47 return d;
48 } 48 }
49 49
50 dict_T *
51 dict_alloc_lock(int lock)
52 {
53 dict_T *d = dict_alloc();
54
55 if (d != NULL)
56 d->dv_lock = lock;
57 return d;
58 }
59
50 /* 60 /*
51 * Allocate an empty dict for a return value. 61 * Allocate an empty dict for a return value.
52 * Returns OK or FAIL. 62 * Returns OK or FAIL.
53 */ 63 */
54 int 64 int
55 rettv_dict_alloc(typval_T *rettv) 65 rettv_dict_alloc(typval_T *rettv)
56 { 66 {
57 dict_T *d = dict_alloc(); 67 dict_T *d = dict_alloc_lock(0);
58 68
59 if (d == NULL) 69 if (d == NULL)
60 return FAIL; 70 return FAIL;
61 71
62 rettv_dict_set(rettv, d); 72 rettv_dict_set(rettv, d);
63 rettv->v_lock = 0;
64 return OK; 73 return OK;
65 } 74 }
66 75
67 /* 76 /*
68 * Set a dictionary as the return value 77 * Set a dictionary as the return value
78 87
79 /* 88 /*
80 * Free a Dictionary, including all non-container items it contains. 89 * Free a Dictionary, including all non-container items it contains.
81 * Ignores the reference count. 90 * Ignores the reference count.
82 */ 91 */
83 static void 92 void
84 dict_free_contents(dict_T *d) 93 dict_free_contents(dict_T *d)
85 { 94 {
86 int todo; 95 int todo;
87 hashitem_T *hi; 96 hashitem_T *hi;
88 dictitem_T *di; 97 dictitem_T *di;
100 hash_remove(&d->dv_hashtab, hi); 109 hash_remove(&d->dv_hashtab, hi);
101 dictitem_free(di); 110 dictitem_free(di);
102 --todo; 111 --todo;
103 } 112 }
104 } 113 }
114
115 /* The hashtab is still locked, it has to be re-initialized anyway */
105 hash_clear(&d->dv_hashtab); 116 hash_clear(&d->dv_hashtab);
106 } 117 }
107 118
108 static void 119 static void
109 dict_free_dict(dict_T *d) 120 dict_free_dict(dict_T *d)
844 } 855 }
845 } 856 }
846 } 857 }
847 } 858 }
848 859
860 /*
861 * Make each item in the dict readonly (not the value of the item).
862 */
863 void
864 dict_set_items_ro(dict_T *di)
865 {
866 int todo = (int)di->dv_hashtab.ht_used;
867 hashitem_T *hi;
868
869 /* Set readonly */
870 for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
871 {
872 if (HASHITEM_EMPTY(hi))
873 continue;
874 --todo;
875 HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX;
876 }
877 }
878
849 #endif /* defined(FEAT_EVAL) */ 879 #endif /* defined(FEAT_EVAL) */