forked from aniani/vim
patch 9.0.0386: some code blocks are nested too deep
Problem: Some code blocks are nested too deep. Solution: Bail out earlier. (Yegappan Lakshmanan, closes #11058)
This commit is contained in:
committed by
Bram Moolenaar
parent
c47b16a470
commit
b1f471ee20
68
src/alloc.c
68
src/alloc.c
@@ -87,17 +87,17 @@ vim_mem_profile_dump(void)
|
|||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < MEM_SIZES - 1; i++)
|
for (i = 0; i < MEM_SIZES - 1; i++)
|
||||||
{
|
{
|
||||||
if (mem_allocs[i] || mem_frees[i])
|
if (mem_allocs[i] == 0 && mem_frees[i] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mem_frees[i] > mem_allocs[i])
|
||||||
|
printf("\r\n%s", _("ERROR: "));
|
||||||
|
printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]);
|
||||||
|
j++;
|
||||||
|
if (j > 3)
|
||||||
{
|
{
|
||||||
if (mem_frees[i] > mem_allocs[i])
|
j = 0;
|
||||||
printf("\r\n%s", _("ERROR: "));
|
printf("\r\n");
|
||||||
printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]);
|
|
||||||
j++;
|
|
||||||
if (j > 3)
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
printf("\r\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,22 +332,22 @@ mem_realloc(void *ptr, size_t size)
|
|||||||
void
|
void
|
||||||
do_outofmem_msg(size_t size)
|
do_outofmem_msg(size_t size)
|
||||||
{
|
{
|
||||||
if (!did_outofmem_msg)
|
if (did_outofmem_msg)
|
||||||
{
|
return;
|
||||||
// Don't hide this message
|
|
||||||
emsg_silent = 0;
|
|
||||||
|
|
||||||
// Must come first to avoid coming back here when printing the error
|
// Don't hide this message
|
||||||
// message fails, e.g. when setting v:errmsg.
|
emsg_silent = 0;
|
||||||
did_outofmem_msg = TRUE;
|
|
||||||
|
|
||||||
semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size);
|
// Must come first to avoid coming back here when printing the error
|
||||||
|
// message fails, e.g. when setting v:errmsg.
|
||||||
|
did_outofmem_msg = TRUE;
|
||||||
|
|
||||||
if (starting == NO_SCREEN)
|
semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size);
|
||||||
// Not even finished with initializations and already out of
|
|
||||||
// memory? Then nothing is going to work, exit.
|
if (starting == NO_SCREEN)
|
||||||
mch_exit(123);
|
// Not even finished with initializations and already out of
|
||||||
}
|
// memory? Then nothing is going to work, exit.
|
||||||
|
mch_exit(123);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXITFREE) || defined(PROTO)
|
#if defined(EXITFREE) || defined(PROTO)
|
||||||
@@ -780,20 +780,20 @@ ga_concat_strings(garray_T *gap, char *sep)
|
|||||||
len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len;
|
len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len;
|
||||||
|
|
||||||
s = alloc(len + 1);
|
s = alloc(len + 1);
|
||||||
if (s != NULL)
|
if (s == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*s = NUL;
|
||||||
|
p = s;
|
||||||
|
for (i = 0; i < gap->ga_len; ++i)
|
||||||
{
|
{
|
||||||
*s = NUL;
|
if (p != s)
|
||||||
p = s;
|
|
||||||
for (i = 0; i < gap->ga_len; ++i)
|
|
||||||
{
|
{
|
||||||
if (p != s)
|
STRCPY(p, sep);
|
||||||
{
|
p += sep_len;
|
||||||
STRCPY(p, sep);
|
|
||||||
p += sep_len;
|
|
||||||
}
|
|
||||||
STRCPY(p, ((char_u **)(gap->ga_data))[i]);
|
|
||||||
p += STRLEN(p);
|
|
||||||
}
|
}
|
||||||
|
STRCPY(p, ((char_u **)(gap->ga_data))[i]);
|
||||||
|
p += STRLEN(p);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
238
src/arglist.c
238
src/arglist.c
@@ -105,25 +105,25 @@ alist_expand(int *fnum_list, int fnum_len)
|
|||||||
char_u *save_p_su = p_su;
|
char_u *save_p_su = p_su;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
old_arg_files = ALLOC_MULT(char_u *, GARGCOUNT);
|
||||||
|
if (old_arg_files == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// Don't use 'suffixes' here. This should work like the shell did the
|
// Don't use 'suffixes' here. This should work like the shell did the
|
||||||
// expansion. Also, the vimrc file isn't read yet, thus the user
|
// expansion. Also, the vimrc file isn't read yet, thus the user
|
||||||
// can't set the options.
|
// can't set the options.
|
||||||
p_su = empty_option;
|
p_su = empty_option;
|
||||||
old_arg_files = ALLOC_MULT(char_u *, GARGCOUNT);
|
for (i = 0; i < GARGCOUNT; ++i)
|
||||||
if (old_arg_files != NULL)
|
old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname);
|
||||||
|
old_arg_count = GARGCOUNT;
|
||||||
|
if (expand_wildcards(old_arg_count, old_arg_files,
|
||||||
|
&new_arg_file_count, &new_arg_files,
|
||||||
|
EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK
|
||||||
|
&& new_arg_file_count > 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < GARGCOUNT; ++i)
|
alist_set(&global_alist, new_arg_file_count, new_arg_files,
|
||||||
old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname);
|
TRUE, fnum_list, fnum_len);
|
||||||
old_arg_count = GARGCOUNT;
|
FreeWild(old_arg_count, old_arg_files);
|
||||||
if (expand_wildcards(old_arg_count, old_arg_files,
|
|
||||||
&new_arg_file_count, &new_arg_files,
|
|
||||||
EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK
|
|
||||||
&& new_arg_file_count > 0)
|
|
||||||
{
|
|
||||||
alist_set(&global_alist, new_arg_file_count, new_arg_files,
|
|
||||||
TRUE, fnum_list, fnum_len);
|
|
||||||
FreeWild(old_arg_count, old_arg_files);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p_su = save_p_su;
|
p_su = save_p_su;
|
||||||
}
|
}
|
||||||
@@ -383,6 +383,57 @@ alist_add_list(
|
|||||||
vim_free(files[i]);
|
vim_free(files[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete the file names in 'alist_ga' from the argument list.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
arglist_del_files(garray_T *alist_ga)
|
||||||
|
{
|
||||||
|
regmatch_T regmatch;
|
||||||
|
int didone;
|
||||||
|
int i;
|
||||||
|
char_u *p;
|
||||||
|
int match;
|
||||||
|
|
||||||
|
// Delete the items: use each item as a regexp and find a match in the
|
||||||
|
// argument list.
|
||||||
|
regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set
|
||||||
|
for (i = 0; i < alist_ga->ga_len && !got_int; ++i)
|
||||||
|
{
|
||||||
|
p = ((char_u **)alist_ga->ga_data)[i];
|
||||||
|
p = file_pat_to_reg_pat(p, NULL, NULL, FALSE);
|
||||||
|
if (p == NULL)
|
||||||
|
break;
|
||||||
|
regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0);
|
||||||
|
if (regmatch.regprog == NULL)
|
||||||
|
{
|
||||||
|
vim_free(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
didone = FALSE;
|
||||||
|
for (match = 0; match < ARGCOUNT; ++match)
|
||||||
|
if (vim_regexec(®match, alist_name(&ARGLIST[match]),
|
||||||
|
(colnr_T)0))
|
||||||
|
{
|
||||||
|
didone = TRUE;
|
||||||
|
vim_free(ARGLIST[match].ae_fname);
|
||||||
|
mch_memmove(ARGLIST + match, ARGLIST + match + 1,
|
||||||
|
(ARGCOUNT - match - 1) * sizeof(aentry_T));
|
||||||
|
--ALIST(curwin)->al_ga.ga_len;
|
||||||
|
if (curwin->w_arg_idx > match)
|
||||||
|
--curwin->w_arg_idx;
|
||||||
|
--match;
|
||||||
|
}
|
||||||
|
|
||||||
|
vim_regfree(regmatch.regprog);
|
||||||
|
vim_free(p);
|
||||||
|
if (!didone)
|
||||||
|
semsg(_(e_no_match_str_2), ((char_u **)alist_ga->ga_data)[i]);
|
||||||
|
}
|
||||||
|
ga_clear(alist_ga);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "what" == AL_SET: Redefine the argument list to 'str'.
|
* "what" == AL_SET: Redefine the argument list to 'str'.
|
||||||
* "what" == AL_ADD: add files in 'str' to the argument list after "after".
|
* "what" == AL_ADD: add files in 'str' to the argument list after "after".
|
||||||
@@ -401,8 +452,6 @@ do_arglist(
|
|||||||
int exp_count;
|
int exp_count;
|
||||||
char_u **exp_files;
|
char_u **exp_files;
|
||||||
int i;
|
int i;
|
||||||
char_u *p;
|
|
||||||
int match;
|
|
||||||
int arg_escaped = TRUE;
|
int arg_escaped = TRUE;
|
||||||
|
|
||||||
if (check_arglist_locked() == FAIL)
|
if (check_arglist_locked() == FAIL)
|
||||||
@@ -422,48 +471,7 @@ do_arglist(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
if (what == AL_DEL)
|
if (what == AL_DEL)
|
||||||
{
|
arglist_del_files(&new_ga);
|
||||||
regmatch_T regmatch;
|
|
||||||
int didone;
|
|
||||||
|
|
||||||
// Delete the items: use each item as a regexp and find a match in the
|
|
||||||
// argument list.
|
|
||||||
regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set
|
|
||||||
for (i = 0; i < new_ga.ga_len && !got_int; ++i)
|
|
||||||
{
|
|
||||||
p = ((char_u **)new_ga.ga_data)[i];
|
|
||||||
p = file_pat_to_reg_pat(p, NULL, NULL, FALSE);
|
|
||||||
if (p == NULL)
|
|
||||||
break;
|
|
||||||
regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0);
|
|
||||||
if (regmatch.regprog == NULL)
|
|
||||||
{
|
|
||||||
vim_free(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
didone = FALSE;
|
|
||||||
for (match = 0; match < ARGCOUNT; ++match)
|
|
||||||
if (vim_regexec(®match, alist_name(&ARGLIST[match]),
|
|
||||||
(colnr_T)0))
|
|
||||||
{
|
|
||||||
didone = TRUE;
|
|
||||||
vim_free(ARGLIST[match].ae_fname);
|
|
||||||
mch_memmove(ARGLIST + match, ARGLIST + match + 1,
|
|
||||||
(ARGCOUNT - match - 1) * sizeof(aentry_T));
|
|
||||||
--ALIST(curwin)->al_ga.ga_len;
|
|
||||||
if (curwin->w_arg_idx > match)
|
|
||||||
--curwin->w_arg_idx;
|
|
||||||
--match;
|
|
||||||
}
|
|
||||||
|
|
||||||
vim_regfree(regmatch.regprog);
|
|
||||||
vim_free(p);
|
|
||||||
if (!didone)
|
|
||||||
semsg(_(e_no_match_str_2), ((char_u **)new_ga.ga_data)[i]);
|
|
||||||
}
|
|
||||||
ga_clear(&new_ga);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data,
|
i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data,
|
||||||
@@ -576,39 +584,42 @@ ex_args(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
else if (eap->cmdidx == CMD_args)
|
else if (eap->cmdidx == CMD_args)
|
||||||
{
|
{
|
||||||
|
char_u **items;
|
||||||
|
|
||||||
// ":args": list arguments.
|
// ":args": list arguments.
|
||||||
if (ARGCOUNT > 0)
|
if (ARGCOUNT <= 0)
|
||||||
{
|
return;
|
||||||
char_u **items = ALLOC_MULT(char_u *, ARGCOUNT);
|
|
||||||
|
|
||||||
if (items != NULL)
|
items = ALLOC_MULT(char_u *, ARGCOUNT);
|
||||||
{
|
if (items == NULL)
|
||||||
// Overwrite the command, for a short list there is no
|
return;
|
||||||
// scrolling required and no wait_return().
|
|
||||||
gotocmdline(TRUE);
|
|
||||||
|
|
||||||
for (i = 0; i < ARGCOUNT; ++i)
|
// Overwrite the command, for a short list there is no scrolling
|
||||||
items[i] = alist_name(&ARGLIST[i]);
|
// required and no wait_return().
|
||||||
list_in_columns(items, ARGCOUNT, curwin->w_arg_idx);
|
gotocmdline(TRUE);
|
||||||
vim_free(items);
|
|
||||||
}
|
for (i = 0; i < ARGCOUNT; ++i)
|
||||||
}
|
items[i] = alist_name(&ARGLIST[i]);
|
||||||
|
list_in_columns(items, ARGCOUNT, curwin->w_arg_idx);
|
||||||
|
vim_free(items);
|
||||||
}
|
}
|
||||||
else if (eap->cmdidx == CMD_arglocal)
|
else if (eap->cmdidx == CMD_arglocal)
|
||||||
{
|
{
|
||||||
garray_T *gap = &curwin->w_alist->al_ga;
|
garray_T *gap = &curwin->w_alist->al_ga;
|
||||||
|
|
||||||
// ":argslocal": make a local copy of the global argument list.
|
// ":argslocal": make a local copy of the global argument list.
|
||||||
if (GA_GROW_OK(gap, GARGCOUNT))
|
if (GA_GROW_FAILS(gap, GARGCOUNT))
|
||||||
for (i = 0; i < GARGCOUNT; ++i)
|
return;
|
||||||
if (GARGLIST[i].ae_fname != NULL)
|
|
||||||
{
|
for (i = 0; i < GARGCOUNT; ++i)
|
||||||
AARGLIST(curwin->w_alist)[gap->ga_len].ae_fname =
|
if (GARGLIST[i].ae_fname != NULL)
|
||||||
vim_strsave(GARGLIST[i].ae_fname);
|
{
|
||||||
AARGLIST(curwin->w_alist)[gap->ga_len].ae_fnum =
|
AARGLIST(curwin->w_alist)[gap->ga_len].ae_fname =
|
||||||
GARGLIST[i].ae_fnum;
|
vim_strsave(GARGLIST[i].ae_fname);
|
||||||
++gap->ga_len;
|
AARGLIST(curwin->w_alist)[gap->ga_len].ae_fnum =
|
||||||
}
|
GARGLIST[i].ae_fnum;
|
||||||
|
++gap->ga_len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,40 +1385,41 @@ f_argv(typval_T *argvars, typval_T *rettv)
|
|||||||
&& check_for_opt_number_arg(argvars, 1) == FAIL)))
|
&& check_for_opt_number_arg(argvars, 1) == FAIL)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (argvars[0].v_type != VAR_UNKNOWN)
|
if (argvars[0].v_type == VAR_UNKNOWN)
|
||||||
{
|
{
|
||||||
if (argvars[1].v_type == VAR_UNKNOWN)
|
get_arglist_as_rettv(ARGLIST, ARGCOUNT, rettv);
|
||||||
{
|
return;
|
||||||
arglist = ARGLIST;
|
}
|
||||||
argcount = ARGCOUNT;
|
|
||||||
}
|
|
||||||
else if (argvars[1].v_type == VAR_NUMBER
|
|
||||||
&& tv_get_number(&argvars[1]) == -1)
|
|
||||||
{
|
|
||||||
arglist = GARGLIST;
|
|
||||||
argcount = GARGCOUNT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
win_T *wp = find_win_by_nr_or_id(&argvars[1]);
|
|
||||||
|
|
||||||
if (wp != NULL)
|
if (argvars[1].v_type == VAR_UNKNOWN)
|
||||||
{
|
{
|
||||||
// Use the argument list of the specified window
|
arglist = ARGLIST;
|
||||||
arglist = WARGLIST(wp);
|
argcount = ARGCOUNT;
|
||||||
argcount = WARGCOUNT(wp);
|
}
|
||||||
}
|
else if (argvars[1].v_type == VAR_NUMBER
|
||||||
}
|
&& tv_get_number(&argvars[1]) == -1)
|
||||||
|
{
|
||||||
rettv->v_type = VAR_STRING;
|
arglist = GARGLIST;
|
||||||
rettv->vval.v_string = NULL;
|
argcount = GARGCOUNT;
|
||||||
idx = tv_get_number_chk(&argvars[0], NULL);
|
|
||||||
if (arglist != NULL && idx >= 0 && idx < argcount)
|
|
||||||
rettv->vval.v_string = vim_strsave(alist_name(&arglist[idx]));
|
|
||||||
else if (idx == -1)
|
|
||||||
get_arglist_as_rettv(arglist, argcount, rettv);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
get_arglist_as_rettv(ARGLIST, ARGCOUNT, rettv);
|
{
|
||||||
|
win_T *wp = find_win_by_nr_or_id(&argvars[1]);
|
||||||
|
|
||||||
|
if (wp != NULL)
|
||||||
|
{
|
||||||
|
// Use the argument list of the specified window
|
||||||
|
arglist = WARGLIST(wp);
|
||||||
|
argcount = WARGCOUNT(wp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rettv->v_type = VAR_STRING;
|
||||||
|
rettv->vval.v_string = NULL;
|
||||||
|
idx = tv_get_number_chk(&argvars[0], NULL);
|
||||||
|
if (arglist != NULL && idx >= 0 && idx < argcount)
|
||||||
|
rettv->vval.v_string = vim_strsave(alist_name(&arglist[idx]));
|
||||||
|
else if (idx == -1)
|
||||||
|
get_arglist_as_rettv(arglist, argcount, rettv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
386,
|
||||||
/**/
|
/**/
|
||||||
385,
|
385,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user