mirror of
https://github.com/neovim/neovim.git
synced 2025-09-10 13:28:19 +00:00
*: Fix lint errors found in new code in previously ignored files
This commit is contained in:
@@ -512,10 +512,10 @@ struct file_buffer {
|
|||||||
visualinfo_T b_visual;
|
visualinfo_T b_visual;
|
||||||
int b_visual_mode_eval; /* b_visual.vi_mode for visualmode() */
|
int b_visual_mode_eval; /* b_visual.vi_mode for visualmode() */
|
||||||
|
|
||||||
fmark_T b_last_cursor; /* cursor position when last unloading this
|
fmark_T b_last_cursor; // cursor position when last unloading this
|
||||||
buffer */
|
// buffer
|
||||||
fmark_T b_last_insert; /* where Insert mode was left */
|
fmark_T b_last_insert; // where Insert mode was left
|
||||||
fmark_T b_last_change; /* position of last change: '. mark */
|
fmark_T b_last_change; // position of last change: '. mark
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the changelist contains old change positions
|
* the changelist contains old change positions
|
||||||
|
@@ -5340,7 +5340,7 @@ static int list_concat(list_T *l1, list_T *l2, typval_T *tv)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* make a copy of the first list. */
|
/* make a copy of the first list. */
|
||||||
l = list_copy(NULL, l1, FALSE, 0);
|
l = list_copy(NULL, l1, false, 0);
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
tv->v_type = VAR_LIST;
|
tv->v_type = VAR_LIST;
|
||||||
@@ -18605,7 +18605,7 @@ int var_item_copy(const vimconv_T *const conv,
|
|||||||
typval_T *const to,
|
typval_T *const to,
|
||||||
const bool deep,
|
const bool deep,
|
||||||
const int copyID)
|
const int copyID)
|
||||||
FUNC_ATTR_NONNULL_ARG(2,3)
|
FUNC_ATTR_NONNULL_ARG(2, 3)
|
||||||
{
|
{
|
||||||
static int recurse = 0;
|
static int recurse = 0;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
@@ -18645,8 +18645,9 @@ int var_item_copy(const vimconv_T *const conv,
|
|||||||
/* use the copy made earlier */
|
/* use the copy made earlier */
|
||||||
to->vval.v_list = from->vval.v_list->lv_copylist;
|
to->vval.v_list = from->vval.v_list->lv_copylist;
|
||||||
++to->vval.v_list->lv_refcount;
|
++to->vval.v_list->lv_refcount;
|
||||||
} else
|
} else {
|
||||||
to->vval.v_list = list_copy(conv, from->vval.v_list, deep, copyID);
|
to->vval.v_list = list_copy(conv, from->vval.v_list, deep, copyID);
|
||||||
|
}
|
||||||
if (to->vval.v_list == NULL)
|
if (to->vval.v_list == NULL)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
break;
|
break;
|
||||||
@@ -18659,8 +18660,9 @@ int var_item_copy(const vimconv_T *const conv,
|
|||||||
/* use the copy made earlier */
|
/* use the copy made earlier */
|
||||||
to->vval.v_dict = from->vval.v_dict->dv_copydict;
|
to->vval.v_dict = from->vval.v_dict->dv_copydict;
|
||||||
++to->vval.v_dict->dv_refcount;
|
++to->vval.v_dict->dv_refcount;
|
||||||
} else
|
} else {
|
||||||
to->vval.v_dict = dict_copy(conv, from->vval.v_dict, deep, copyID);
|
to->vval.v_dict = dict_copy(conv, from->vval.v_dict, deep, copyID);
|
||||||
|
}
|
||||||
if (to->vval.v_dict == NULL)
|
if (to->vval.v_dict == NULL)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
break;
|
break;
|
||||||
@@ -20875,11 +20877,13 @@ static var_flavour_T var_flavour(char_u *varname)
|
|||||||
|
|
||||||
if (ASCII_ISUPPER(*p)) {
|
if (ASCII_ISUPPER(*p)) {
|
||||||
while (*(++p))
|
while (*(++p))
|
||||||
if (ASCII_ISLOWER(*p))
|
if (ASCII_ISLOWER(*p)) {
|
||||||
return VAR_FLAVOUR_SESSION;
|
return VAR_FLAVOUR_SESSION;
|
||||||
|
}
|
||||||
return VAR_FLAVOUR_SHADA;
|
return VAR_FLAVOUR_SHADA;
|
||||||
} else
|
} else {
|
||||||
return VAR_FLAVOUR_DEFAULT;
|
return VAR_FLAVOUR_DEFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over global variables
|
/// Iterate over global variables
|
||||||
|
@@ -4268,7 +4268,7 @@ static int
|
|||||||
in_history (
|
in_history (
|
||||||
int type,
|
int type,
|
||||||
char_u *str,
|
char_u *str,
|
||||||
int move_to_front, /* Move the entry to the front if it exists */
|
int move_to_front, // Move the entry to the front if it exists
|
||||||
int sep
|
int sep
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -4309,9 +4309,9 @@ in_history (
|
|||||||
history[type][i].hisstr = str;
|
history[type][i].hisstr = str;
|
||||||
history[type][i].timestamp = os_time();
|
history[type][i].timestamp = os_time();
|
||||||
history[type][i].additional_elements = NULL;
|
history[type][i].additional_elements = NULL;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -4378,7 +4378,7 @@ add_to_history (
|
|||||||
}
|
}
|
||||||
last_maptick = -1;
|
last_maptick = -1;
|
||||||
}
|
}
|
||||||
if (!in_history(histype, new_entry, TRUE, sep)) {
|
if (!in_history(histype, new_entry, true, sep)) {
|
||||||
if (++hisidx[histype] == hislen)
|
if (++hisidx[histype] == hislen)
|
||||||
hisidx[histype] = 0;
|
hisidx[histype] = 0;
|
||||||
hisptr = &history[histype][hisidx[histype]];
|
hisptr = &history[histype][hisidx[histype]];
|
||||||
@@ -4575,7 +4575,7 @@ int del_history_entry(int histype, char_u *str)
|
|||||||
int idx;
|
int idx;
|
||||||
int i;
|
int i;
|
||||||
int last;
|
int last;
|
||||||
int found = FALSE;
|
bool found = false;
|
||||||
|
|
||||||
regmatch.regprog = NULL;
|
regmatch.regprog = NULL;
|
||||||
regmatch.rm_ic = FALSE; /* always match case */
|
regmatch.rm_ic = FALSE; /* always match case */
|
||||||
@@ -4592,7 +4592,7 @@ int del_history_entry(int histype, char_u *str)
|
|||||||
if (hisptr->hisstr == NULL)
|
if (hisptr->hisstr == NULL)
|
||||||
break;
|
break;
|
||||||
if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) {
|
if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) {
|
||||||
found = TRUE;
|
found = true;
|
||||||
hist_free_entry(hisptr);
|
hist_free_entry(hisptr);
|
||||||
} else {
|
} else {
|
||||||
if (i != last) {
|
if (i != last) {
|
||||||
|
@@ -891,8 +891,8 @@ EXTERN int must_redraw INIT(= 0); /* type of redraw necessary */
|
|||||||
EXTERN int skip_redraw INIT(= FALSE); /* skip redraw once */
|
EXTERN int skip_redraw INIT(= FALSE); /* skip redraw once */
|
||||||
EXTERN int do_redraw INIT(= FALSE); /* extra redraw once */
|
EXTERN int do_redraw INIT(= FALSE); /* extra redraw once */
|
||||||
|
|
||||||
EXTERN int need_highlight_changed INIT(= TRUE);
|
EXTERN int need_highlight_changed INIT(= true);
|
||||||
EXTERN char *used_shada_file INIT(= NULL); /* name of ShaDa file to use */
|
EXTERN char *used_shada_file INIT(= NULL); // name of the ShaDa file to use
|
||||||
|
|
||||||
#define NSCRIPT 15
|
#define NSCRIPT 15
|
||||||
EXTERN FILE *scriptin[NSCRIPT]; /* streams to read script from */
|
EXTERN FILE *scriptin[NSCRIPT]; /* streams to read script from */
|
||||||
|
@@ -114,8 +114,8 @@ int main() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __AC_KHASH_H
|
#ifndef NVIM_LIB_KHASH_H
|
||||||
#define __AC_KHASH_H
|
#define NVIM_LIB_KHASH_H
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@header
|
@header
|
||||||
@@ -194,175 +194,229 @@ static const double __ac_HASH_UPPER = 0.77;
|
|||||||
khval_t *vals; \
|
khval_t *vals; \
|
||||||
} kh_##name##_t;
|
} kh_##name##_t;
|
||||||
|
|
||||||
#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
|
#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
|
||||||
extern kh_##name##_t *kh_init_##name(void); \
|
extern kh_##name##_t *kh_init_##name(void); \
|
||||||
extern void kh_dealloc_##name(kh_##name##_t *h); \
|
extern void kh_dealloc_##name(kh_##name##_t *h); \
|
||||||
extern void kh_destroy_##name(kh_##name##_t *h); \
|
extern void kh_destroy_##name(kh_##name##_t *h); \
|
||||||
extern void kh_clear_##name(kh_##name##_t *h); \
|
extern void kh_clear_##name(kh_##name##_t *h); \
|
||||||
extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
|
extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
|
||||||
extern void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
|
extern void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
|
||||||
extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
|
extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
|
||||||
extern void kh_del_##name(kh_##name##_t *h, khint_t x);
|
extern void kh_del_##name(kh_##name##_t *h, khint_t x);
|
||||||
|
|
||||||
#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
|
#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, \
|
||||||
SCOPE kh_##name##_t *kh_init_##name(void) \
|
__hash_equal) \
|
||||||
REAL_FATTR_UNUSED; \
|
SCOPE kh_##name##_t *kh_init_##name(void) \
|
||||||
SCOPE kh_##name##_t *kh_init_##name(void) { \
|
REAL_FATTR_UNUSED; \
|
||||||
return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \
|
SCOPE kh_##name##_t *kh_init_##name(void) { \
|
||||||
} \
|
return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \
|
||||||
SCOPE void kh_dealloc_##name(kh_##name##_t *h) \
|
} \
|
||||||
REAL_FATTR_UNUSED; \
|
SCOPE void kh_dealloc_##name(kh_##name##_t *h) \
|
||||||
SCOPE void kh_dealloc_##name(kh_##name##_t *h) \
|
REAL_FATTR_UNUSED; \
|
||||||
{ \
|
SCOPE void kh_dealloc_##name(kh_##name##_t *h) \
|
||||||
kfree((void *)h->keys); kfree(h->flags); \
|
{ \
|
||||||
kfree((void *)h->vals); \
|
kfree(h->keys); \
|
||||||
} \
|
kfree(h->flags); \
|
||||||
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
|
kfree(h->vals); \
|
||||||
REAL_FATTR_UNUSED; \
|
} \
|
||||||
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
|
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
|
||||||
{ \
|
REAL_FATTR_UNUSED; \
|
||||||
if (h) { \
|
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
|
||||||
kh_dealloc_##name(h); \
|
{ \
|
||||||
kfree(h); \
|
if (h) { \
|
||||||
} \
|
kh_dealloc_##name(h); \
|
||||||
} \
|
kfree(h); \
|
||||||
SCOPE void kh_clear_##name(kh_##name##_t *h) \
|
} \
|
||||||
REAL_FATTR_UNUSED; \
|
} \
|
||||||
SCOPE void kh_clear_##name(kh_##name##_t *h) \
|
SCOPE void kh_clear_##name(kh_##name##_t *h) \
|
||||||
{ \
|
REAL_FATTR_UNUSED; \
|
||||||
if (h && h->flags) { \
|
SCOPE void kh_clear_##name(kh_##name##_t *h) \
|
||||||
memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \
|
{ \
|
||||||
h->size = h->n_occupied = 0; \
|
if (h && h->flags) { \
|
||||||
} \
|
memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \
|
||||||
} \
|
h->size = h->n_occupied = 0; \
|
||||||
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
|
} \
|
||||||
REAL_FATTR_UNUSED; \
|
} \
|
||||||
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
|
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
|
||||||
{ \
|
REAL_FATTR_UNUSED; \
|
||||||
if (h->n_buckets) { \
|
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
|
||||||
khint_t k, i, last, mask, step = 0; \
|
{ \
|
||||||
mask = h->n_buckets - 1; \
|
if (h->n_buckets) { \
|
||||||
k = __hash_func(key); i = k & mask; \
|
khint_t k, i, last, mask, step = 0; \
|
||||||
last = i; \
|
mask = h->n_buckets - 1; \
|
||||||
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
|
k = __hash_func(key); i = k & mask; \
|
||||||
i = (i + (++step)) & mask; \
|
last = i; \
|
||||||
if (i == last) return h->n_buckets; \
|
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || \
|
||||||
} \
|
!__hash_equal(h->keys[i], key))) { \
|
||||||
return __ac_iseither(h->flags, i)? h->n_buckets : i; \
|
i = (i + (++step)) & mask; \
|
||||||
} else return 0; \
|
if (i == last) { \
|
||||||
} \
|
return h->n_buckets; \
|
||||||
SCOPE void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
|
} \
|
||||||
REAL_FATTR_UNUSED; \
|
} \
|
||||||
SCOPE void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
|
return __ac_iseither(h->flags, i) ? h->n_buckets : i; \
|
||||||
{ /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \
|
} else { \
|
||||||
khint32_t *new_flags = 0; \
|
return 0; \
|
||||||
khint_t j = 1; \
|
} \
|
||||||
{ \
|
} \
|
||||||
kroundup32(new_n_buckets); \
|
SCOPE void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
|
||||||
if (new_n_buckets < 4) new_n_buckets = 4; \
|
REAL_FATTR_UNUSED; \
|
||||||
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \
|
SCOPE void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
|
||||||
else { /* hash table size to be changed (shrink or expand); rehash */ \
|
{ /* This function uses 0.25*n_buckets bytes of working space instead of */ \
|
||||||
new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
|
/* [sizeof(key_t+val_t)+.25]*n_buckets. */ \
|
||||||
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
|
khint32_t *new_flags = 0; \
|
||||||
if (h->n_buckets < new_n_buckets) { /* expand */ \
|
khint_t j = 1; \
|
||||||
khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
|
{ \
|
||||||
h->keys = new_keys; \
|
kroundup32(new_n_buckets); \
|
||||||
if (kh_is_map) { \
|
if (new_n_buckets < 4) { \
|
||||||
khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
|
new_n_buckets = 4; \
|
||||||
h->vals = new_vals; \
|
} \
|
||||||
} \
|
/* requested size is too small */ \
|
||||||
} /* otherwise shrink */ \
|
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) { \
|
||||||
} \
|
j = 0; \
|
||||||
} \
|
} else { /* hash table size to be changed (shrink or expand); rehash */ \
|
||||||
if (j) { /* rehashing is needed */ \
|
new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) \
|
||||||
for (j = 0; j != h->n_buckets; ++j) { \
|
* sizeof(khint32_t)); \
|
||||||
if (__ac_iseither(h->flags, j) == 0) { \
|
memset(new_flags, 0xaa, \
|
||||||
khkey_t key = h->keys[j]; \
|
__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
|
||||||
khval_t val; \
|
if (h->n_buckets < new_n_buckets) { /* expand */ \
|
||||||
khint_t new_mask; \
|
khkey_t *new_keys = (khkey_t*)krealloc( \
|
||||||
new_mask = new_n_buckets - 1; \
|
(void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
|
||||||
if (kh_is_map) val = h->vals[j]; \
|
h->keys = new_keys; \
|
||||||
__ac_set_isdel_true(h->flags, j); \
|
if (kh_is_map) { \
|
||||||
while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \
|
khval_t *new_vals = (khval_t*)krealloc( \
|
||||||
khint_t k, i, step = 0; \
|
(void *)h->vals, new_n_buckets * sizeof(khval_t)); \
|
||||||
k = __hash_func(key); \
|
h->vals = new_vals; \
|
||||||
i = k & new_mask; \
|
} \
|
||||||
while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \
|
} /* otherwise shrink */ \
|
||||||
__ac_set_isempty_false(new_flags, i); \
|
} \
|
||||||
if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \
|
} \
|
||||||
{ khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
|
if (j) { /* rehashing is needed */ \
|
||||||
if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \
|
for (j = 0; j != h->n_buckets; ++j) { \
|
||||||
__ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \
|
if (__ac_iseither(h->flags, j) == 0) { \
|
||||||
} else { /* write the element and jump out of the loop */ \
|
khkey_t key = h->keys[j]; \
|
||||||
h->keys[i] = key; \
|
khval_t val; \
|
||||||
if (kh_is_map) h->vals[i] = val; \
|
khint_t new_mask; \
|
||||||
break; \
|
new_mask = new_n_buckets - 1; \
|
||||||
} \
|
if (kh_is_map) { \
|
||||||
} \
|
val = h->vals[j]; \
|
||||||
} \
|
} \
|
||||||
} \
|
__ac_set_isdel_true(h->flags, j); \
|
||||||
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
|
/* kick-out process; sort of like in Cuckoo hashing */ \
|
||||||
h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
|
while (1) { \
|
||||||
if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
|
khint_t k, i, step = 0; \
|
||||||
} \
|
k = __hash_func(key); \
|
||||||
kfree(h->flags); /* free the working space */ \
|
i = k & new_mask; \
|
||||||
h->flags = new_flags; \
|
while (!__ac_isempty(new_flags, i)) { \
|
||||||
h->n_buckets = new_n_buckets; \
|
i = (i + (++step)) & new_mask; \
|
||||||
h->n_occupied = h->size; \
|
} \
|
||||||
h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
|
__ac_set_isempty_false(new_flags, i); \
|
||||||
} \
|
/* kick out the existing element */ \
|
||||||
} \
|
if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { \
|
||||||
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
|
{ \
|
||||||
REAL_FATTR_UNUSED; \
|
khkey_t tmp = h->keys[i]; \
|
||||||
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
|
h->keys[i] = key; \
|
||||||
{ \
|
key = tmp; \
|
||||||
khint_t x; \
|
} \
|
||||||
if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \
|
if (kh_is_map) { \
|
||||||
if (h->n_buckets > (h->size<<1)) { \
|
khval_t tmp = h->vals[i]; \
|
||||||
kh_resize_##name(h, h->n_buckets - 1); /* clear "deleted" elements */ \
|
h->vals[i] = val; \
|
||||||
} else { \
|
val = tmp; \
|
||||||
kh_resize_##name(h, h->n_buckets + 1); /* expand the hash table */ \
|
} \
|
||||||
} \
|
/* mark it as deleted in the old hash table */ \
|
||||||
} /* TODO: to implement automatically shrinking; resize() already support shrinking */ \
|
__ac_set_isdel_true(h->flags, i); \
|
||||||
{ \
|
} else { /* write the element and jump out of the loop */ \
|
||||||
khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
|
h->keys[i] = key; \
|
||||||
x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \
|
if (kh_is_map) { \
|
||||||
if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \
|
h->vals[i] = val; \
|
||||||
else { \
|
} \
|
||||||
last = i; \
|
break; \
|
||||||
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
|
} \
|
||||||
if (__ac_isdel(h->flags, i)) site = i; \
|
} \
|
||||||
i = (i + (++step)) & mask; \
|
} \
|
||||||
if (i == last) { x = site; break; } \
|
} \
|
||||||
} \
|
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
|
||||||
if (x == h->n_buckets) { \
|
h->keys = (khkey_t*)krealloc((void *)h->keys, \
|
||||||
if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \
|
new_n_buckets * sizeof(khkey_t)); \
|
||||||
else x = i; \
|
if (kh_is_map) { \
|
||||||
} \
|
h->vals = (khval_t*)krealloc((void *)h->vals, \
|
||||||
} \
|
new_n_buckets * sizeof(khval_t)); \
|
||||||
} \
|
} \
|
||||||
if (__ac_isempty(h->flags, x)) { /* not present at all */ \
|
} \
|
||||||
h->keys[x] = key; \
|
kfree(h->flags); /* free the working space */ \
|
||||||
__ac_set_isboth_false(h->flags, x); \
|
h->flags = new_flags; \
|
||||||
++h->size; ++h->n_occupied; \
|
h->n_buckets = new_n_buckets; \
|
||||||
*ret = 1; \
|
h->n_occupied = h->size; \
|
||||||
} else if (__ac_isdel(h->flags, x)) { /* deleted */ \
|
h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
|
||||||
h->keys[x] = key; \
|
} \
|
||||||
__ac_set_isboth_false(h->flags, x); \
|
} \
|
||||||
++h->size; \
|
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
|
||||||
*ret = 2; \
|
REAL_FATTR_UNUSED; \
|
||||||
} else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \
|
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
|
||||||
return x; \
|
{ \
|
||||||
} \
|
khint_t x; \
|
||||||
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
|
if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \
|
||||||
REAL_FATTR_UNUSED; \
|
if (h->n_buckets > (h->size << 1)) { \
|
||||||
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
|
kh_resize_##name(h, h->n_buckets - 1); /* clear "deleted" elements */ \
|
||||||
{ \
|
} else { \
|
||||||
if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \
|
kh_resize_##name(h, h->n_buckets + 1); /* expand the hash table */ \
|
||||||
__ac_set_isdel_true(h->flags, x); \
|
} \
|
||||||
--h->size; \
|
} /* TODO: implement automatically shrinking; */ \
|
||||||
} \
|
/* resize() already support shrinking */ \
|
||||||
}
|
{ \
|
||||||
|
khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
|
||||||
|
x = site = h->n_buckets; \
|
||||||
|
k = __hash_func(key); \
|
||||||
|
i = k & mask; \
|
||||||
|
if (__ac_isempty(h->flags, i)) { \
|
||||||
|
x = i; /* for speed up */ \
|
||||||
|
} else { \
|
||||||
|
last = i; \
|
||||||
|
while (!__ac_isempty(h->flags, i) \
|
||||||
|
&& (__ac_isdel(h->flags, i) \
|
||||||
|
|| !__hash_equal(h->keys[i], key))) { \
|
||||||
|
if (__ac_isdel(h->flags, i)) { \
|
||||||
|
site = i; \
|
||||||
|
} \
|
||||||
|
i = (i + (++step)) & mask; \
|
||||||
|
if (i == last) { \
|
||||||
|
x = site; \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (x == h->n_buckets) { \
|
||||||
|
if (__ac_isempty(h->flags, i) && site != h->n_buckets) { \
|
||||||
|
x = site; \
|
||||||
|
} else { \
|
||||||
|
x = i; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (__ac_isempty(h->flags, x)) { /* not present at all */ \
|
||||||
|
h->keys[x] = key; \
|
||||||
|
__ac_set_isboth_false(h->flags, x); \
|
||||||
|
h->size++; \
|
||||||
|
h->n_occupied++; \
|
||||||
|
*ret = 1; \
|
||||||
|
} else if (__ac_isdel(h->flags, x)) { /* deleted */ \
|
||||||
|
h->keys[x] = key; \
|
||||||
|
__ac_set_isboth_false(h->flags, x); \
|
||||||
|
h->size++; \
|
||||||
|
*ret = 2; \
|
||||||
|
} else { \
|
||||||
|
*ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \
|
||||||
|
} \
|
||||||
|
return x; \
|
||||||
|
} \
|
||||||
|
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
|
||||||
|
REAL_FATTR_UNUSED; \
|
||||||
|
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
|
||||||
|
{ \
|
||||||
|
if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \
|
||||||
|
__ac_set_isdel_true(h->flags, x); \
|
||||||
|
--h->size; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define KHASH_DECLARE(name, khkey_t, khval_t) \
|
#define KHASH_DECLARE(name, khkey_t, khval_t) \
|
||||||
__KHASH_TYPE(name, khkey_t, khval_t) \
|
__KHASH_TYPE(name, khkey_t, khval_t) \
|
||||||
@@ -599,12 +653,17 @@ static kh_inline khint_t __ac_Wang_hash(khint_t key)
|
|||||||
@param kvar Variable to which value will be assigned
|
@param kvar Variable to which value will be assigned
|
||||||
@param code Block of code to execute
|
@param code Block of code to execute
|
||||||
*/
|
*/
|
||||||
#define kh_foreach_key(h, kvar, code) { khint_t __i; \
|
#define kh_foreach_key(h, kvar, code) \
|
||||||
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
|
{ \
|
||||||
if (!kh_exist(h,__i)) continue; \
|
khint_t __i; \
|
||||||
(kvar) = kh_key(h,__i); \
|
for (__i = kh_begin(h); __i != kh_end(h); __i++) { \
|
||||||
code; \
|
if (!kh_exist(h, __i)) { \
|
||||||
} }
|
continue; \
|
||||||
|
} \
|
||||||
|
(kvar) = kh_key(h, __i); \
|
||||||
|
code; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
/* More conenient interfaces */
|
/* More conenient interfaces */
|
||||||
|
|
||||||
@@ -651,21 +710,21 @@ typedef const char *kh_cstr_t;
|
|||||||
@param name Name of the hash table [symbol]
|
@param name Name of the hash table [symbol]
|
||||||
@param khval_t Type of values [type]
|
@param khval_t Type of values [type]
|
||||||
*/
|
*/
|
||||||
#define KHASH_MAP_INIT_STR(name, khval_t) \
|
#define KHASH_MAP_INIT_STR(name, khval_t) \
|
||||||
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
|
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
|
||||||
|
|
||||||
/*! @function
|
/*! @function
|
||||||
@abstract Return a literal for an empty hash table.
|
@abstract Return a literal for an empty hash table.
|
||||||
@param name Name of the hash table [symbol]
|
@param name Name of the hash table [symbol]
|
||||||
*/
|
*/
|
||||||
#define KHASH_EMPTY_TABLE(name) \
|
#define KHASH_EMPTY_TABLE(name) \
|
||||||
((kh_##name##_t) { \
|
((kh_##name##_t) { \
|
||||||
.n_buckets = 0, \
|
.n_buckets = 0, \
|
||||||
.size = 0, \
|
.size = 0, \
|
||||||
.n_occupied = 0, \
|
.n_occupied = 0, \
|
||||||
.upper_bound = 0, \
|
.upper_bound = 0, \
|
||||||
.flags = NULL, \
|
.flags = NULL, \
|
||||||
.keys = NULL, \
|
.keys = NULL, \
|
||||||
.vals = NULL, \
|
.vals = NULL, \
|
||||||
})
|
})
|
||||||
#endif /* __AC_KHASH_H */
|
#endif // NVIM_LIB_KHASH_H
|
||||||
|
@@ -2042,7 +2042,7 @@ static void usage(void)
|
|||||||
mch_msg(_(" -r, -L List swap files and exit\n"));
|
mch_msg(_(" -r, -L List swap files and exit\n"));
|
||||||
mch_msg(_(" -r <file> Recover crashed session\n"));
|
mch_msg(_(" -r <file> Recover crashed session\n"));
|
||||||
mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
|
mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
|
||||||
mch_msg(_(" -i <shada> Use <shada> instead of the default " SHADA_FILE "\n"));
|
mch_msg(_(" -i <shada> Use <shada> instead of the default " SHADA_FILE "\n")); // NOLINT(whitespace/line_length)
|
||||||
mch_msg(_(" --noplugin Don't load plugin scripts\n"));
|
mch_msg(_(" --noplugin Don't load plugin scripts\n"));
|
||||||
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
|
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
|
||||||
mch_msg(_(" -O[N] Like -o but split vertically\n"));
|
mch_msg(_(" -O[N] Like -o but split vertically\n"));
|
||||||
|
@@ -312,22 +312,21 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum)
|
|||||||
* to crash. */
|
* to crash. */
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
return posp;
|
return posp;
|
||||||
if (c > '~') /* check for islower()/isupper() */
|
if (c > '~') { // check for islower()/isupper()
|
||||||
;
|
} else if (c == '\'' || c == '`') { // previous context mark
|
||||||
else if (c == '\'' || c == '`') { /* previous context mark */
|
pos_copy = curwin->w_pcmark; // need to make a copy because
|
||||||
pos_copy = curwin->w_pcmark; /* need to make a copy because */
|
posp = &pos_copy; // w_pcmark may be changed soon
|
||||||
posp = &pos_copy; /* w_pcmark may be changed soon */
|
} else if (c == '"') { // to pos when leaving buffer
|
||||||
} else if (c == '"') /* to pos when leaving buffer */
|
|
||||||
posp = &(buf->b_last_cursor.mark);
|
posp = &(buf->b_last_cursor.mark);
|
||||||
else if (c == '^') /* to where Insert mode stopped */
|
} else if (c == '^') { // to where Insert mode stopped
|
||||||
posp = &(buf->b_last_insert.mark);
|
posp = &(buf->b_last_insert.mark);
|
||||||
else if (c == '.') /* to where last change was made */
|
} else if (c == '.') { // to where last change was made
|
||||||
posp = &(buf->b_last_change.mark);
|
posp = &(buf->b_last_change.mark);
|
||||||
else if (c == '[') /* to start of previous operator */
|
} else if (c == '[') { // to start of previous operator
|
||||||
posp = &(buf->b_op_start);
|
posp = &(buf->b_op_start);
|
||||||
else if (c == ']') /* to end of previous operator */
|
} else if (c == ']') { // to end of previous operator
|
||||||
posp = &(buf->b_op_end);
|
posp = &(buf->b_op_end);
|
||||||
else if (c == '{' || c == '}') { /* to previous/next paragraph */
|
} else if (c == '{' || c == '}') { // to previous/next paragraph
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
oparg_T oa;
|
oparg_T oa;
|
||||||
int slcb = listcmd_busy;
|
int slcb = listcmd_busy;
|
||||||
@@ -620,9 +619,9 @@ void do_marks(exarg_T *eap)
|
|||||||
if (arg != NULL && *arg == NUL)
|
if (arg != NULL && *arg == NUL)
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
|
|
||||||
show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE);
|
show_one_mark('\'', arg, &curwin->w_pcmark, NULL, true);
|
||||||
for (i = 0; i < NMARKS; ++i)
|
for (i = 0; i < NMARKS; ++i)
|
||||||
show_one_mark(i + 'a', arg, &curbuf->b_namedm[i].mark, NULL, TRUE);
|
show_one_mark(i + 'a', arg, &curbuf->b_namedm[i].mark, NULL, true);
|
||||||
for (i = 0; i < NGLOBALMARKS; ++i) {
|
for (i = 0; i < NGLOBALMARKS; ++i) {
|
||||||
if (namedfm[i].fmark.fnum != 0)
|
if (namedfm[i].fmark.fnum != 0)
|
||||||
name = fm_getname(&namedfm[i].fmark, 15);
|
name = fm_getname(&namedfm[i].fmark, 15);
|
||||||
@@ -636,14 +635,14 @@ void do_marks(exarg_T *eap)
|
|||||||
xfree(name);
|
xfree(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
show_one_mark('"', arg, &curbuf->b_last_cursor.mark, NULL, TRUE);
|
show_one_mark('"', arg, &curbuf->b_last_cursor.mark, NULL, true);
|
||||||
show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE);
|
show_one_mark('[', arg, &curbuf->b_op_start, NULL, true);
|
||||||
show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE);
|
show_one_mark(']', arg, &curbuf->b_op_end, NULL, true);
|
||||||
show_one_mark('^', arg, &curbuf->b_last_insert.mark, NULL, TRUE);
|
show_one_mark('^', arg, &curbuf->b_last_insert.mark, NULL, true);
|
||||||
show_one_mark('.', arg, &curbuf->b_last_change.mark, NULL, TRUE);
|
show_one_mark('.', arg, &curbuf->b_last_change.mark, NULL, true);
|
||||||
show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, TRUE);
|
show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, true);
|
||||||
show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, TRUE);
|
show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, true);
|
||||||
show_one_mark(-1, arg, NULL, NULL, FALSE);
|
show_one_mark(-1, arg, NULL, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -737,13 +736,14 @@ void ex_delmarks(exarg_T *eap)
|
|||||||
from = to = *p;
|
from = to = *p;
|
||||||
|
|
||||||
for (i = from; i <= to; ++i) {
|
for (i = from; i <= to; ++i) {
|
||||||
if (lower)
|
if (lower) {
|
||||||
curbuf->b_namedm[i - 'a'].mark.lnum = 0;
|
curbuf->b_namedm[i - 'a'].mark.lnum = 0;
|
||||||
else {
|
} else {
|
||||||
if (digit)
|
if (digit) {
|
||||||
n = i - '0' + NMARKS;
|
n = i - '0' + NMARKS;
|
||||||
else
|
} else {
|
||||||
n = i - 'A';
|
n = i - 'A';
|
||||||
|
}
|
||||||
namedfm[n].fmark.mark.lnum = 0;
|
namedfm[n].fmark.mark.lnum = 0;
|
||||||
xfree(namedfm[n].fname);
|
xfree(namedfm[n].fname);
|
||||||
namedfm[n].fname = NULL;
|
namedfm[n].fname = NULL;
|
||||||
@@ -1127,7 +1127,7 @@ void cleanup_jumplist(void)
|
|||||||
&& curwin->w_jumplist[i].fmark.mark.lnum
|
&& curwin->w_jumplist[i].fmark.mark.lnum
|
||||||
== curwin->w_jumplist[from].fmark.mark.lnum)
|
== curwin->w_jumplist[from].fmark.mark.lnum)
|
||||||
break;
|
break;
|
||||||
if (i >= curwin->w_jumplistlen) { // no duplicate
|
if (i >= curwin->w_jumplistlen) { // no duplicate
|
||||||
if (to != from) {
|
if (to != from) {
|
||||||
// Not using curwin->w_jumplist[to++] = curwin->w_jumplist[from] because
|
// Not using curwin->w_jumplist[to++] = curwin->w_jumplist[from] because
|
||||||
// this way valgrind complains about overlapping source and destination
|
// this way valgrind complains about overlapping source and destination
|
||||||
|
@@ -2441,9 +2441,8 @@ did_set_string_option (
|
|||||||
verbose_stop();
|
verbose_stop();
|
||||||
if (*p_vfile != NUL && verbose_open() == FAIL)
|
if (*p_vfile != NUL && verbose_open() == FAIL)
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
}
|
|
||||||
/* 'shada' */
|
/* 'shada' */
|
||||||
else if (varp == &p_shada) {
|
} else if (varp == &p_shada) {
|
||||||
for (s = p_shada; *s; ) {
|
for (s = p_shada; *s; ) {
|
||||||
/* Check it's a valid character */
|
/* Check it's a valid character */
|
||||||
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
|
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
|
||||||
|
Reference in New Issue
Block a user