diff options
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 744fb13447..1833461fa9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -76,6 +76,7 @@ #include "nvim/tag.h" #include "nvim/tempfile.h" #include "nvim/term.h" +#include "nvim/ui.h" #include "nvim/mouse.h" #include "nvim/undo.h" #include "nvim/version.h" @@ -499,7 +500,7 @@ void eval_init(void) job_event_pool = kmp_init(JobEventPool); } -#if defined(EXITFREE) || defined(PROTO) +#if defined(EXITFREE) void eval_clear(void) { struct vimvar *p; @@ -2750,7 +2751,7 @@ void ex_lockvar(exarg_T *eap) if (eap->forceit) deep = -1; else if (vim_isdigit(*arg)) { - deep = getdigits(&arg); + deep = getdigits_int(&arg); arg = skipwhite(arg); } @@ -4498,7 +4499,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) { char_u *p; char_u *name; - int extra = 0; + unsigned int extra = 0; /* * Find the end of the string, skipping backslashed characters. @@ -4847,7 +4848,6 @@ list_equal ( return item1 == NULL && item2 == NULL; } -#if defined(PROTO) /* * Return the dictitem that an entry in a hashtable points to. */ @@ -4855,12 +4855,6 @@ dictitem_T *dict_lookup(hashitem_T *hi) { return HI2DI(hi); } -#endif - -dictitem_T * dict_lookup(hashitem_T *hi) -{ - return HI2DI(hi); -} /* * Return TRUE when two dictionaries have exactly the same key/values. @@ -5129,7 +5123,7 @@ void list_append_list(list_T *list, list_T *itemlist) li->li_tv.v_lock = 0; li->li_tv.vval.v_list = itemlist; list_append(list, li); - ++list->lv_refcount; + ++itemlist->lv_refcount; } /* @@ -5543,49 +5537,48 @@ int garbage_collect(void) return did_free; } -/* - * Free lists and dictionaries that are no longer referenced. - */ +/// Free lists and dictionaries that are no longer referenced. +/// +/// Note: This function may only be called from garbage_collect(). +/// +/// @param copyID Free lists/dictionaries that don't have this ID. +/// @return true, if something was freed. static int free_unref_items(int copyID) { - dict_T *dd; - list_T *ll; - int did_free = FALSE; + bool did_free = false; - /* - * Go through the list of dicts and free items without the copyID. - */ - for (dd = first_dict; dd != NULL; ) + // Go through the list of dicts and free items without the copyID. + for (dict_T *dd = first_dict; dd != NULL; ) { if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) { - /* Free the Dictionary and ordinary items it contains, but don't - * recurse into Lists and Dictionaries, they will be in the list - * of dicts or list of lists. */ + // Free the Dictionary and ordinary items it contains, but don't + // recurse into Lists and Dictionaries, they will be in the list + // of dicts or list of lists. */ + dict_T *dd_next = dd->dv_used_next; dict_free(dd, FALSE); - did_free = TRUE; - - /* restart, next dict may also have been freed */ - dd = first_dict; - } else + did_free = true; + dd = dd_next; + } else { dd = dd->dv_used_next; + } + } - /* - * Go through the list of lists and free items without the copyID. - * But don't free a list that has a watcher (used in a for loop), these - * are not referenced anywhere. - */ - for (ll = first_list; ll != NULL; ) + // Go through the list of lists and free items without the copyID. + // But don't free a list that has a watcher (used in a for loop), these + // are not referenced anywhere. + for (list_T *ll = first_list; ll != NULL;) { if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) && ll->lv_watch == NULL) { - /* Free the List and ordinary items it contains, but don't recurse - * into Lists and Dictionaries, they will be in the list of dicts - * or list of lists. */ + // Free the List and ordinary items it contains, but don't recurse + // into Lists and Dictionaries, they will be in the list of dicts + // or list of lists. + list_T* ll_next = ll->lv_used_next; list_free(ll, FALSE); - did_free = TRUE; - - /* restart, next list may also have been freed */ - ll = first_list; - } else + did_free = true; + ll = ll_next; + } else { ll = ll->lv_used_next; + } + } return did_free; } @@ -5717,6 +5710,7 @@ dict_free ( /* Lock the hashtab, we don't want it to resize while freeing items. */ hash_lock(&d->dv_hashtab); + assert(d->dv_hashtab.ht_locked > 0); todo = (int)d->dv_hashtab.ht_used; for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi) { if (!HASHITEM_EMPTY(hi)) { @@ -10023,6 +10017,8 @@ static void f_has(typval_T *argvars, typval_T *rettv) #endif } else if (STRICMP(name, "syntax_items") == 0) { n = syntax_present(curwin); + } else if (STRICMP(name, "gui_running") == 0) { + n = ui_rgb_attached(); } } @@ -13370,7 +13366,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv) yank_type = MBLOCK; if (VIM_ISDIGIT(stropt[1])) { ++stropt; - block_len = getdigits(&stropt) - 1; + block_len = getdigits_long(&stropt) - 1; --stropt; } break; @@ -14440,7 +14436,7 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv) if (modec != 't' && modec != 'c' && modec != 'g') modec = 0; /* replace invalid with current */ } else { - if (t_colors > 1) + if (abstract_ui || t_colors > 1) modec = 'c'; else modec = 't'; @@ -18047,7 +18043,7 @@ static ufunc_T *find_func(char_u *name) return NULL; } -#if defined(EXITFREE) || defined(PROTO) +#if defined(EXITFREE) void free_all_functions(void) { hashitem_T *hi; |