diff options
author | ZyX <kp-pav@yandex.ru> | 2016-02-03 19:35:49 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:45:49 +0300 |
commit | 3c3921955040967b8f5489316342d95d80c235bb (patch) | |
tree | 9f576ae357a40997c273c9677e951156fa99f61c /src | |
parent | 85244e68e3c2bf2bb8a175665fe759ef426c8e2a (diff) | |
download | rneovim-3c3921955040967b8f5489316342d95d80c235bb.tar.gz rneovim-3c3921955040967b8f5489316342d95d80c235bb.tar.bz2 rneovim-3c3921955040967b8f5489316342d95d80c235bb.zip |
eval: Get rid of VV_LEN constant
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 22 | ||||
-rw-r--r-- | src/nvim/eval.h | 5 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f13be7954b..7edc1402f5 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -289,11 +289,11 @@ typedef enum { // The reason to use this table anyway is for very quick access to the // variables with the VV_ defines. static struct vimvar { - char *vv_name; /* name of variable, without v: */ - dictitem_T vv_di; /* value and name for key */ - char vv_filler[16]; /* space for LONGEST name below!!! */ - char vv_flags; /* VV_COMPAT, VV_RO, VV_RO_SBX */ -} vimvars[VV_LEN] = + char *vv_name; ///< Name of the variable, without v:. + dictitem_T vv_di; ///< Value of the variable, with name. + char vv_filler[16]; ///< Space for longest name from below. + char vv_flags; ///< Flags: #VV_COMPAT, #VV_RO, #VV_RO_SBX. +} vimvars[] = { /* * The order here must match the VV_ defines in eval.h! @@ -465,7 +465,6 @@ const list_T *eval_msgpack_type_lists[] = { void eval_init(void) { jobs = pmap_new(uint64_t)(); - int i; struct vimvar *p; init_var_dict(&globvardict, &globvars_var, VAR_DEF_SCOPE); @@ -474,7 +473,7 @@ void eval_init(void) hash_init(&compat_hashtab); hash_init(&func_hashtab); - for (i = 0; i < VV_LEN; ++i) { + for (size_t i = 0; i < ARRAY_SIZE(vimvars); ++i) { p = &vimvars[i]; STRCPY(p->vv_di.di_key, p->vv_name); if (p->vv_flags & VV_RO) @@ -534,7 +533,7 @@ void eval_clear(void) { struct vimvar *p; - for (int i = 0; i < VV_LEN; ++i) { + for (size_t i = 0; i < ARRAY_SIZE(vimvars); ++i) { p = &vimvars[i]; if (p->vv_di.di_tv.v_type == VAR_STRING) { xfree(p->vv_str); @@ -3188,7 +3187,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) static size_t bdone; static size_t wdone; static size_t tdone; - static int vidx; + static size_t vidx; static hashitem_T *hi; hashtab_T *ht; @@ -3250,9 +3249,10 @@ char_u *get_user_var_name(expand_T *xp, int idx) return cat_prefix_varname('t', hi->hi_key); } - /* v: variables */ - if (vidx < VV_LEN) + // v: variables + if (vidx < ARRAY_SIZE(vimvars)) { return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name); + } xfree(varnamebuf); varnamebuf = NULL; diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 89aa263434..40111abf8d 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -54,7 +54,7 @@ EXTERN ufunc_T dumuf; #define HI2UF(hi) HIKEY2UF((hi)->hi_key) /* Defines for Vim variables. These must match vimvars[] in eval.c! */ -enum { +typedef enum { VV_COUNT, VV_COUNT1, VV_PREVCOUNT, @@ -125,8 +125,7 @@ enum { VV_TRUE, VV_NULL, VV_NONE, - VV_LEN, ///< Number of v: variables -}; +} VimVarIndex; /// All recognized msgpack types typedef enum { |