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:
Felipe Oliveira Carvalho 2014-05-08 15:03:25 -03:00 committed by Thiago de Arruda
parent b4efff6523
commit 5209d2271b
9 changed files with 21 additions and 21 deletions

View File

@ -18397,7 +18397,7 @@ char_u *get_user_func_name(expand_T *xp, int idx)
cat_func_name(IObuff, fp);
if (xp->xp_context != EXPAND_USER_FUNC) {
STRCAT(IObuff, "(");
if (!fp->uf_varargs && fp->uf_args.ga_len == 0)
if (!fp->uf_varargs && GA_EMPTY(&fp->uf_args))
STRCAT(IObuff, ")");
}
return IObuff;

View File

@ -594,7 +594,7 @@ void ex_breakdel(exarg_T *eap)
}
/* If all breakpoints were removed clear the array. */
if (gap->ga_len == 0)
if (GA_EMPTY(gap))
ga_clear(gap);
}
}
@ -607,7 +607,7 @@ void ex_breaklist(exarg_T *eap)
struct debuggy *bp;
int i;
if (dbg_breakp.ga_len == 0)
if (GA_EMPTY(&dbg_breakp))
MSG(_("No breakpoints defined"));
else
for (i = 0; i < dbg_breakp.ga_len; ++i) {
@ -670,7 +670,7 @@ debuggy_find (
int prev_got_int;
/* Return quickly when there are no breakpoints. */
if (gap->ga_len == 0)
if (GA_EMPTY(gap))
return (linenr_T)0;
/* Replace K_SNR in function name with "<SNR>". */

View File

@ -4187,7 +4187,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
}
free(matches);
}
if (ga.ga_len == 0)
if (GA_EMPTY(&ga))
return FAIL;
/* Sort and remove duplicates which can happen when specifying multiple

View File

@ -1013,7 +1013,7 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
ga_init(to, from->ga_itemsize, from->ga_growsize);
if (from->ga_len == 0)
if (GA_EMPTY(from))
return;
ga_grow(to, from->ga_len);
@ -1302,7 +1302,7 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
fold_T *nfp;
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 */
deleteFoldRecurse(&fp->fd_nested);
--gap->ga_len;

View File

@ -893,7 +893,7 @@ expand_in_path (
ga_init(&path_ga, (int)sizeof(char_u *), 1);
expand_path_option(curdir, &path_ga);
free(curdir);
if (path_ga.ga_len == 0)
if (GA_EMPTY(&path_ga))
return 0;
paths = ga_concat_strings(&path_ga);

View File

@ -5021,7 +5021,7 @@ regmatch (
/*
* If the regstack is empty or something failed we are done.
*/
if (regstack.ga_len == 0 || status == RA_FAIL) {
if (GA_EMPTY(&regstack) || status == RA_FAIL) {
if (scan == NULL) {
/*
* We get here only if there's trouble -- normally "case END" is

View File

@ -997,7 +997,7 @@ spell_check (
return 1;
// 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;
memset(&mi, 0, sizeof(matchinf_T));
@ -1947,7 +1947,7 @@ spell_valid_case (
static int no_spell_checking(win_T *wp)
{
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"));
return TRUE;
}
@ -4557,16 +4557,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
spell_message(spin, IObuff);
// 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.
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.
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.
do_mapline = spin->si_map.ga_len == 0;
do_mapline = GA_EMPTY(&spin->si_map);
// Allocate and init the afffile_T structure.
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;
// Don't write the section if there are no items.
if (gap->ga_len == 0)
if (GA_EMPTY(gap))
continue;
// 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,
TRUE, need_cap, TRUE);
if (sug.su_ga.ga_len == 0)
if (GA_EMPTY(&sug.su_ga))
MSG(_("Sorry, no suggestions"));
else if (count > 0) {
if (count > sug.su_ga.ga_len)
@ -11680,7 +11680,7 @@ add_suggestion (
// the first "the" to itself.
return;
if (gap->ga_len == 0)
if (GA_EMPTY(gap))
i = -1;
else {
// Check if the word is already there. Also check the length that is

View File

@ -2376,12 +2376,12 @@ static void check_state_ends(void)
pop_current_state();
if (current_state.ga_len == 0)
if (GA_EMPTY(&current_state))
break;
if (had_extend && keepend_level >= 0) {
syn_update_ends(FALSE);
if (current_state.ga_len == 0)
if (GA_EMPTY(&current_state))
break;
}

View File

@ -2419,7 +2419,7 @@ void ex_undolist(exarg_T *eap)
}
}
if (ga.ga_len == 0)
if (GA_EMPTY(&ga))
MSG(_("Nothing to undo"));
else {
sort_strings((char_u **)ga.ga_data, ga.ga_len);