mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Replace ga->ga_len == 0 checks with GA_EMPTY(ga)
Used Coccinelle to perform the changes @@ expression E; @@ <... ( // E.ga_len == 0 is isomorphic to !E.ga_len - E.ga_len == 0 + GA_EMPTY(&E) | - E->ga_len == 0 + GA_EMPTY(E) ) ...>
This commit is contained in:
parent
b4efff6523
commit
5209d2271b
@ -18397,7 +18397,7 @@ char_u *get_user_func_name(expand_T *xp, int idx)
|
|||||||
cat_func_name(IObuff, fp);
|
cat_func_name(IObuff, fp);
|
||||||
if (xp->xp_context != EXPAND_USER_FUNC) {
|
if (xp->xp_context != EXPAND_USER_FUNC) {
|
||||||
STRCAT(IObuff, "(");
|
STRCAT(IObuff, "(");
|
||||||
if (!fp->uf_varargs && fp->uf_args.ga_len == 0)
|
if (!fp->uf_varargs && GA_EMPTY(&fp->uf_args))
|
||||||
STRCAT(IObuff, ")");
|
STRCAT(IObuff, ")");
|
||||||
}
|
}
|
||||||
return IObuff;
|
return IObuff;
|
||||||
|
@ -594,7 +594,7 @@ void ex_breakdel(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If all breakpoints were removed clear the array. */
|
/* If all breakpoints were removed clear the array. */
|
||||||
if (gap->ga_len == 0)
|
if (GA_EMPTY(gap))
|
||||||
ga_clear(gap);
|
ga_clear(gap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -607,7 +607,7 @@ void ex_breaklist(exarg_T *eap)
|
|||||||
struct debuggy *bp;
|
struct debuggy *bp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (dbg_breakp.ga_len == 0)
|
if (GA_EMPTY(&dbg_breakp))
|
||||||
MSG(_("No breakpoints defined"));
|
MSG(_("No breakpoints defined"));
|
||||||
else
|
else
|
||||||
for (i = 0; i < dbg_breakp.ga_len; ++i) {
|
for (i = 0; i < dbg_breakp.ga_len; ++i) {
|
||||||
@ -670,7 +670,7 @@ debuggy_find (
|
|||||||
int prev_got_int;
|
int prev_got_int;
|
||||||
|
|
||||||
/* Return quickly when there are no breakpoints. */
|
/* Return quickly when there are no breakpoints. */
|
||||||
if (gap->ga_len == 0)
|
if (GA_EMPTY(gap))
|
||||||
return (linenr_T)0;
|
return (linenr_T)0;
|
||||||
|
|
||||||
/* Replace K_SNR in function name with "<SNR>". */
|
/* Replace K_SNR in function name with "<SNR>". */
|
||||||
|
@ -4187,7 +4187,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
|
|||||||
}
|
}
|
||||||
free(matches);
|
free(matches);
|
||||||
}
|
}
|
||||||
if (ga.ga_len == 0)
|
if (GA_EMPTY(&ga))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* Sort and remove duplicates which can happen when specifying multiple
|
/* Sort and remove duplicates which can happen when specifying multiple
|
||||||
|
@ -1013,7 +1013,7 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
|
|||||||
|
|
||||||
ga_init(to, from->ga_itemsize, from->ga_growsize);
|
ga_init(to, from->ga_itemsize, from->ga_growsize);
|
||||||
|
|
||||||
if (from->ga_len == 0)
|
if (GA_EMPTY(from))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ga_grow(to, from->ga_len);
|
ga_grow(to, from->ga_len);
|
||||||
@ -1302,7 +1302,7 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
|
|||||||
fold_T *nfp;
|
fold_T *nfp;
|
||||||
|
|
||||||
fp = (fold_T *)gap->ga_data + idx;
|
fp = (fold_T *)gap->ga_data + idx;
|
||||||
if (recursive || fp->fd_nested.ga_len == 0) {
|
if (recursive || GA_EMPTY(&fp->fd_nested)) {
|
||||||
/* recursively delete the contained folds */
|
/* recursively delete the contained folds */
|
||||||
deleteFoldRecurse(&fp->fd_nested);
|
deleteFoldRecurse(&fp->fd_nested);
|
||||||
--gap->ga_len;
|
--gap->ga_len;
|
||||||
|
@ -893,7 +893,7 @@ expand_in_path (
|
|||||||
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
||||||
expand_path_option(curdir, &path_ga);
|
expand_path_option(curdir, &path_ga);
|
||||||
free(curdir);
|
free(curdir);
|
||||||
if (path_ga.ga_len == 0)
|
if (GA_EMPTY(&path_ga))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
paths = ga_concat_strings(&path_ga);
|
paths = ga_concat_strings(&path_ga);
|
||||||
|
@ -5021,7 +5021,7 @@ regmatch (
|
|||||||
/*
|
/*
|
||||||
* If the regstack is empty or something failed we are done.
|
* If the regstack is empty or something failed we are done.
|
||||||
*/
|
*/
|
||||||
if (regstack.ga_len == 0 || status == RA_FAIL) {
|
if (GA_EMPTY(®stack) || status == RA_FAIL) {
|
||||||
if (scan == NULL) {
|
if (scan == NULL) {
|
||||||
/*
|
/*
|
||||||
* We get here only if there's trouble -- normally "case END" is
|
* We get here only if there's trouble -- normally "case END" is
|
||||||
|
@ -997,7 +997,7 @@ spell_check (
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Return here when loading language files failed.
|
// Return here when loading language files failed.
|
||||||
if (wp->w_s->b_langp.ga_len == 0)
|
if (GA_EMPTY(&wp->w_s->b_langp))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
memset(&mi, 0, sizeof(matchinf_T));
|
memset(&mi, 0, sizeof(matchinf_T));
|
||||||
@ -1947,7 +1947,7 @@ spell_valid_case (
|
|||||||
static int no_spell_checking(win_T *wp)
|
static int no_spell_checking(win_T *wp)
|
||||||
{
|
{
|
||||||
if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
|
if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
|
||||||
|| wp->w_s->b_langp.ga_len == 0) {
|
|| GA_EMPTY(&wp->w_s->b_langp)) {
|
||||||
EMSG(_("E756: Spell checking is not enabled"));
|
EMSG(_("E756: Spell checking is not enabled"));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -4557,16 +4557,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
spell_message(spin, IObuff);
|
spell_message(spin, IObuff);
|
||||||
|
|
||||||
// Only do REP lines when not done in another .aff file already.
|
// Only do REP lines when not done in another .aff file already.
|
||||||
do_rep = spin->si_rep.ga_len == 0;
|
do_rep = GA_EMPTY(&spin->si_rep);
|
||||||
|
|
||||||
// Only do REPSAL lines when not done in another .aff file already.
|
// Only do REPSAL lines when not done in another .aff file already.
|
||||||
do_repsal = spin->si_repsal.ga_len == 0;
|
do_repsal = GA_EMPTY(&spin->si_repsal);
|
||||||
|
|
||||||
// Only do SAL lines when not done in another .aff file already.
|
// Only do SAL lines when not done in another .aff file already.
|
||||||
do_sal = spin->si_sal.ga_len == 0;
|
do_sal = GA_EMPTY(&spin->si_sal);
|
||||||
|
|
||||||
// Only do MAP lines when not done in another .aff file already.
|
// Only do MAP lines when not done in another .aff file already.
|
||||||
do_mapline = spin->si_map.ga_len == 0;
|
do_mapline = GA_EMPTY(&spin->si_map);
|
||||||
|
|
||||||
// Allocate and init the afffile_T structure.
|
// Allocate and init the afffile_T structure.
|
||||||
aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);
|
aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);
|
||||||
@ -6938,7 +6938,7 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
|
|||||||
gap = &spin->si_repsal;
|
gap = &spin->si_repsal;
|
||||||
|
|
||||||
// Don't write the section if there are no items.
|
// Don't write the section if there are no items.
|
||||||
if (gap->ga_len == 0)
|
if (GA_EMPTY(gap))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Sort the REP/REPSAL items.
|
// Sort the REP/REPSAL items.
|
||||||
@ -8691,7 +8691,7 @@ void spell_suggest(int count)
|
|||||||
spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,
|
spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,
|
||||||
TRUE, need_cap, TRUE);
|
TRUE, need_cap, TRUE);
|
||||||
|
|
||||||
if (sug.su_ga.ga_len == 0)
|
if (GA_EMPTY(&sug.su_ga))
|
||||||
MSG(_("Sorry, no suggestions"));
|
MSG(_("Sorry, no suggestions"));
|
||||||
else if (count > 0) {
|
else if (count > 0) {
|
||||||
if (count > sug.su_ga.ga_len)
|
if (count > sug.su_ga.ga_len)
|
||||||
@ -11680,7 +11680,7 @@ add_suggestion (
|
|||||||
// the first "the" to itself.
|
// the first "the" to itself.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gap->ga_len == 0)
|
if (GA_EMPTY(gap))
|
||||||
i = -1;
|
i = -1;
|
||||||
else {
|
else {
|
||||||
// Check if the word is already there. Also check the length that is
|
// Check if the word is already there. Also check the length that is
|
||||||
|
@ -2376,12 +2376,12 @@ static void check_state_ends(void)
|
|||||||
|
|
||||||
pop_current_state();
|
pop_current_state();
|
||||||
|
|
||||||
if (current_state.ga_len == 0)
|
if (GA_EMPTY(¤t_state))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (had_extend && keepend_level >= 0) {
|
if (had_extend && keepend_level >= 0) {
|
||||||
syn_update_ends(FALSE);
|
syn_update_ends(FALSE);
|
||||||
if (current_state.ga_len == 0)
|
if (GA_EMPTY(¤t_state))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2419,7 +2419,7 @@ void ex_undolist(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ga.ga_len == 0)
|
if (GA_EMPTY(&ga))
|
||||||
MSG(_("Nothing to undo"));
|
MSG(_("Nothing to undo"));
|
||||||
else {
|
else {
|
||||||
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
||||||
|
Loading…
Reference in New Issue
Block a user