mirror of
https://github.com/vim/vim.git
synced 2025-08-26 20:03:41 -04:00
patch 9.0.1246: code is indented more than necessary
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11887)
This commit is contained in:
parent
032713f829
commit
142ed77898
12
src/ui.c
12
src/ui.c
@ -83,8 +83,9 @@ ui_inchar_undo(char_u *s, int len)
|
|||||||
if (ta_str != NULL)
|
if (ta_str != NULL)
|
||||||
newlen += ta_len - ta_off;
|
newlen += ta_len - ta_off;
|
||||||
new = alloc(newlen);
|
new = alloc(newlen);
|
||||||
if (new != NULL)
|
if (new == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (ta_str != NULL)
|
if (ta_str != NULL)
|
||||||
{
|
{
|
||||||
mch_memmove(new, ta_str + ta_off, (size_t)(ta_len - ta_off));
|
mch_memmove(new, ta_str + ta_off, (size_t)(ta_len - ta_off));
|
||||||
@ -97,7 +98,6 @@ ui_inchar_undo(char_u *s, int len)
|
|||||||
ta_len = newlen;
|
ta_len = newlen;
|
||||||
ta_off = 0;
|
ta_off = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -815,8 +815,9 @@ set_input_buf(char_u *p, int overwrite)
|
|||||||
{
|
{
|
||||||
garray_T *gap = (garray_T *)p;
|
garray_T *gap = (garray_T *)p;
|
||||||
|
|
||||||
if (gap != NULL)
|
if (gap == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (gap->ga_data != NULL)
|
if (gap->ga_data != NULL)
|
||||||
{
|
{
|
||||||
if (overwrite || inbufcount + gap->ga_len >= INBUFLEN)
|
if (overwrite || inbufcount + gap->ga_len >= INBUFLEN)
|
||||||
@ -834,7 +835,6 @@ set_input_buf(char_u *p, int overwrite)
|
|||||||
}
|
}
|
||||||
vim_free(gap);
|
vim_free(gap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the given bytes to the input buffer
|
* Add the given bytes to the input buffer
|
||||||
|
18
src/undo.c
18
src/undo.c
@ -1164,8 +1164,9 @@ read_string_decrypt(bufinfo_T *bi, int len)
|
|||||||
{
|
{
|
||||||
char_u *ptr = alloc(len + 1);
|
char_u *ptr = alloc(len + 1);
|
||||||
|
|
||||||
if (ptr != NULL)
|
if (ptr == NULL)
|
||||||
{
|
return NULL;
|
||||||
|
|
||||||
if (len > 0 && undo_read(bi, ptr, len) == FAIL)
|
if (len > 0 && undo_read(bi, ptr, len) == FAIL)
|
||||||
{
|
{
|
||||||
vim_free(ptr);
|
vim_free(ptr);
|
||||||
@ -1178,7 +1179,6 @@ read_string_decrypt(bufinfo_T *bi, int len)
|
|||||||
if (bi->bi_state != NULL && bi->bi_buffer == NULL)
|
if (bi->bi_state != NULL && bi->bi_buffer == NULL)
|
||||||
crypt_decode_inplace(bi->bi_state, ptr, len, FALSE);
|
crypt_decode_inplace(bi->bi_state, ptr, len, FALSE);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3510,13 +3510,13 @@ u_saveline(linenr_T lnum)
|
|||||||
void
|
void
|
||||||
u_clearline(void)
|
u_clearline(void)
|
||||||
{
|
{
|
||||||
if (curbuf->b_u_line_ptr.ul_line != NULL)
|
if (curbuf->b_u_line_ptr.ul_line == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
VIM_CLEAR(curbuf->b_u_line_ptr.ul_line);
|
VIM_CLEAR(curbuf->b_u_line_ptr.ul_line);
|
||||||
curbuf->b_u_line_ptr.ul_len = 0;
|
curbuf->b_u_line_ptr.ul_len = 0;
|
||||||
curbuf->b_u_line_lnum = 0;
|
curbuf->b_u_line_lnum = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of the "U" command.
|
* Implementation of the "U" command.
|
||||||
@ -3726,8 +3726,9 @@ u_undofile_reset_and_delete(buf_T *buf)
|
|||||||
void
|
void
|
||||||
f_undotree(typval_T *argvars UNUSED, typval_T *rettv)
|
f_undotree(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
{
|
{
|
||||||
if (rettv_dict_alloc(rettv) == OK)
|
if (rettv_dict_alloc(rettv) == FAIL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
dict_T *dict = rettv->vval.v_dict;
|
dict_T *dict = rettv->vval.v_dict;
|
||||||
list_T *list;
|
list_T *list;
|
||||||
|
|
||||||
@ -3745,6 +3746,5 @@ f_undotree(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
dict_add_list(dict, "entries", list);
|
dict_add_list(dict, "entries", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -205,8 +205,9 @@ batfile_thisversion(char *path)
|
|||||||
int found = FALSE;
|
int found = FALSE;
|
||||||
|
|
||||||
fd = fopen(path, "r");
|
fd = fopen(path, "r");
|
||||||
if (fd != NULL)
|
if (fd == NULL)
|
||||||
{
|
return FALSE;
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), fd) != NULL)
|
while (fgets(line, sizeof(line), fd) != NULL)
|
||||||
{
|
{
|
||||||
if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
|
if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
|
||||||
@ -216,7 +217,6 @@ batfile_thisversion(char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,13 +261,13 @@ remove_if_exists(char *path, char *filename)
|
|||||||
sprintf(buf, "%s\\%s", path, filename);
|
sprintf(buf, "%s\\%s", path, filename);
|
||||||
|
|
||||||
fd = fopen(buf, "r");
|
fd = fopen(buf, "r");
|
||||||
if (fd != NULL)
|
if (fd == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
printf("removing %s\n", buf);
|
printf("removing %s\n", buf);
|
||||||
remove(buf);
|
remove(buf);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_icons(void)
|
remove_icons(void)
|
||||||
@ -287,8 +287,9 @@ remove_start_menu(void)
|
|||||||
int i;
|
int i;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (get_shell_folder_path(path, VIM_STARTMENU))
|
if (get_shell_folder_path(path, VIM_STARTMENU) == FAIL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
for (i = 1; i < TARGET_COUNT; ++i)
|
for (i = 1; i < TARGET_COUNT; ++i)
|
||||||
remove_if_exists(path, targets[i].lnkname);
|
remove_if_exists(path, targets[i].lnkname);
|
||||||
remove_if_exists(path, "uninstall.lnk");
|
remove_if_exists(path, "uninstall.lnk");
|
||||||
@ -303,7 +304,6 @@ remove_start_menu(void)
|
|||||||
rmdir(path);
|
rmdir(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_uninstall_key(void)
|
delete_uninstall_key(void)
|
||||||
|
@ -770,8 +770,9 @@ is_function_cmd(char_u **cmd)
|
|||||||
static void
|
static void
|
||||||
function_using_block_scopes(ufunc_T *fp, cstack_T *cstack)
|
function_using_block_scopes(ufunc_T *fp, cstack_T *cstack)
|
||||||
{
|
{
|
||||||
if (cstack != NULL && cstack->cs_idx >= 0)
|
if (cstack == NULL || cstack->cs_idx < 0)
|
||||||
{
|
return;
|
||||||
|
|
||||||
int count = cstack->cs_idx + 1;
|
int count = cstack->cs_idx + 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -789,7 +790,6 @@ function_using_block_scopes(ufunc_T *fp, cstack_T *cstack)
|
|||||||
for (i = 0; i <= cstack->cs_idx; ++i)
|
for (i = 0; i <= cstack->cs_idx; ++i)
|
||||||
cstack->cs_flags[i] |= CSF_FUNC_DEF;
|
cstack->cs_flags[i] |= CSF_FUNC_DEF;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the body of a function, put every line in "newlines".
|
* Read the body of a function, put every line in "newlines".
|
||||||
@ -2433,8 +2433,9 @@ func_remove(ufunc_T *fp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
hi = hash_find(&func_hashtab, UF2HIKEY(fp));
|
hi = hash_find(&func_hashtab, UF2HIKEY(fp));
|
||||||
if (!HASHITEM_EMPTY(hi))
|
if (HASHITEM_EMPTY(hi))
|
||||||
{
|
return FALSE;
|
||||||
|
|
||||||
// When there is a def-function index do not actually remove the
|
// When there is a def-function index do not actually remove the
|
||||||
// function, so we can find the index when defining the function again.
|
// function, so we can find the index when defining the function again.
|
||||||
// Do remove it when it's a copy.
|
// Do remove it when it's a copy.
|
||||||
@ -2447,8 +2448,6 @@ func_remove(ufunc_T *fp)
|
|||||||
fp->uf_flags |= FC_DELETED;
|
fp->uf_flags |= FC_DELETED;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
func_clear_items(ufunc_T *fp)
|
func_clear_items(ufunc_T *fp)
|
||||||
|
@ -57,8 +57,9 @@ char *longVersion = NULL;
|
|||||||
void
|
void
|
||||||
init_longVersion(void)
|
init_longVersion(void)
|
||||||
{
|
{
|
||||||
if (longVersion == NULL)
|
if (longVersion != NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
#ifdef BUILD_DATE
|
#ifdef BUILD_DATE
|
||||||
char *date_time = BUILD_DATE;
|
char *date_time = BUILD_DATE;
|
||||||
#else
|
#else
|
||||||
@ -77,7 +78,6 @@ init_longVersion(void)
|
|||||||
vim_snprintf(longVersion, len, msg,
|
vim_snprintf(longVersion, len, msg,
|
||||||
VIM_VERSION_LONG_ONLY, VIM_VERSION_DATE_ONLY, date_time);
|
VIM_VERSION_LONG_ONLY, VIM_VERSION_DATE_ONLY, date_time);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
char *longVersion = VIM_VERSION_LONG;
|
char *longVersion = VIM_VERSION_LONG;
|
||||||
@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
1246,
|
||||||
/**/
|
/**/
|
||||||
1245,
|
1245,
|
||||||
/**/
|
/**/
|
||||||
|
@ -3939,8 +3939,9 @@ delete_def_function_contents(dfunc_T *dfunc, int mark_deleted)
|
|||||||
void
|
void
|
||||||
unlink_def_function(ufunc_T *ufunc)
|
unlink_def_function(ufunc_T *ufunc)
|
||||||
{
|
{
|
||||||
if (ufunc->uf_dfunc_idx > 0)
|
if (ufunc->uf_dfunc_idx <= 0)
|
||||||
{
|
return;
|
||||||
|
|
||||||
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
|
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
|
||||||
+ ufunc->uf_dfunc_idx;
|
+ ufunc->uf_dfunc_idx;
|
||||||
|
|
||||||
@ -3951,7 +3952,6 @@ unlink_def_function(ufunc_T *ufunc)
|
|||||||
if (dfunc->df_ufunc == ufunc)
|
if (dfunc->df_ufunc == ufunc)
|
||||||
dfunc->df_ufunc = NULL;
|
dfunc->df_ufunc = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used when a user function refers to an existing dfunc.
|
* Used when a user function refers to an existing dfunc.
|
||||||
@ -3959,14 +3959,14 @@ unlink_def_function(ufunc_T *ufunc)
|
|||||||
void
|
void
|
||||||
link_def_function(ufunc_T *ufunc)
|
link_def_function(ufunc_T *ufunc)
|
||||||
{
|
{
|
||||||
if (ufunc->uf_dfunc_idx > 0)
|
if (ufunc->uf_dfunc_idx <= 0)
|
||||||
{
|
return;
|
||||||
|
|
||||||
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
|
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
|
||||||
+ ufunc->uf_dfunc_idx;
|
+ ufunc->uf_dfunc_idx;
|
||||||
|
|
||||||
++dfunc->df_refcount;
|
++dfunc->df_refcount;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(EXITFREE) || defined(PROTO)
|
#if defined(EXITFREE) || defined(PROTO)
|
||||||
/*
|
/*
|
||||||
|
@ -279,15 +279,15 @@ exe_newdict(int count, ectx_T *ectx)
|
|||||||
void
|
void
|
||||||
update_has_breakpoint(ufunc_T *ufunc)
|
update_has_breakpoint(ufunc_T *ufunc)
|
||||||
{
|
{
|
||||||
if (ufunc->uf_debug_tick != debug_tick)
|
if (ufunc->uf_debug_tick == debug_tick)
|
||||||
{
|
return;
|
||||||
|
|
||||||
linenr_T breakpoint;
|
linenr_T breakpoint;
|
||||||
|
|
||||||
ufunc->uf_debug_tick = debug_tick;
|
ufunc->uf_debug_tick = debug_tick;
|
||||||
breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, 0);
|
breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, 0);
|
||||||
ufunc->uf_has_breakpoint = breakpoint > 0;
|
ufunc->uf_has_breakpoint = breakpoint > 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static garray_T dict_stack = GA_EMPTY;
|
static garray_T dict_stack = GA_EMPTY;
|
||||||
|
|
||||||
@ -383,8 +383,9 @@ get_pt_outer(partial_T *pt)
|
|||||||
static int
|
static int
|
||||||
check_ufunc_arg_types(ufunc_T *ufunc, int argcount, int off, ectx_T *ectx)
|
check_ufunc_arg_types(ufunc_T *ufunc, int argcount, int off, ectx_T *ectx)
|
||||||
{
|
{
|
||||||
if (ufunc->uf_arg_types != NULL || ufunc->uf_va_type != NULL)
|
if (ufunc->uf_arg_types == NULL && ufunc->uf_va_type == NULL)
|
||||||
{
|
return OK;
|
||||||
|
|
||||||
typval_T *argv = STACK_TV_BOT(0) - argcount - off;
|
typval_T *argv = STACK_TV_BOT(0) - argcount - off;
|
||||||
|
|
||||||
// The function can change at runtime, check that the argument
|
// The function can change at runtime, check that the argument
|
||||||
@ -406,7 +407,6 @@ check_ufunc_arg_types(ufunc_T *ufunc, int argcount, int off, ectx_T *ectx)
|
|||||||
&argv[i], NULL, i + 1) == FAIL)
|
&argv[i], NULL, i + 1) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1527,8 +1527,9 @@ store_var(char_u *name, typval_T *tv)
|
|||||||
static int
|
static int
|
||||||
do_2string(typval_T *tv, int is_2string_any, int tolerant)
|
do_2string(typval_T *tv, int is_2string_any, int tolerant)
|
||||||
{
|
{
|
||||||
if (tv->v_type != VAR_STRING)
|
if (tv->v_type == VAR_STRING)
|
||||||
{
|
return OK;
|
||||||
|
|
||||||
char_u *str;
|
char_u *str;
|
||||||
|
|
||||||
if (is_2string_any)
|
if (is_2string_any)
|
||||||
@ -1584,7 +1585,6 @@ do_2string(typval_T *tv, int is_2string_any, int tolerant)
|
|||||||
clear_tv(tv);
|
clear_tv(tv);
|
||||||
tv->v_type = VAR_STRING;
|
tv->v_type = VAR_STRING;
|
||||||
tv->vval.v_string = str;
|
tv->vval.v_string = str;
|
||||||
}
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2306,8 +2306,9 @@ generate_store_lhs(cctx_T *cctx, lhs_T *lhs, int instr_count, int is_decl)
|
|||||||
lhs->lhs_opt_flags, lhs->lhs_vimvaridx,
|
lhs->lhs_opt_flags, lhs->lhs_vimvaridx,
|
||||||
lhs->lhs_type, lhs->lhs_name, lhs);
|
lhs->lhs_type, lhs->lhs_name, lhs);
|
||||||
|
|
||||||
if (lhs->lhs_lvar != NULL)
|
if (lhs->lhs_lvar == NULL)
|
||||||
{
|
return OK;
|
||||||
|
|
||||||
garray_T *instr = &cctx->ctx_instr;
|
garray_T *instr = &cctx->ctx_instr;
|
||||||
isn_T *isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1;
|
isn_T *isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1;
|
||||||
|
|
||||||
@ -2340,7 +2341,6 @@ generate_store_lhs(cctx_T *cctx, lhs_T *lhs, int instr_count, int is_decl)
|
|||||||
lhs->lhs_lvar->lv_from_outer, lhs->lhs_lvar->lv_loop_idx);
|
lhs->lhs_lvar->lv_from_outer, lhs->lhs_lvar->lv_loop_idx);
|
||||||
else
|
else
|
||||||
generate_STORE(cctx, ISN_STORE, lhs->lhs_lvar->lv_idx, NULL);
|
generate_STORE(cctx, ISN_STORE, lhs->lhs_lvar->lv_idx, NULL);
|
||||||
}
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,8 +1007,10 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
|
|||||||
// The typval is moved into the sallvar_T.
|
// The typval is moved into the sallvar_T.
|
||||||
script_hi = hash_find(script_ht, sv->sv_name);
|
script_hi = hash_find(script_ht, sv->sv_name);
|
||||||
all_hi = hash_find(all_ht, sv->sv_name);
|
all_hi = hash_find(all_ht, sv->sv_name);
|
||||||
if (!HASHITEM_EMPTY(script_hi) && !HASHITEM_EMPTY(all_hi))
|
|
||||||
{
|
if (HASHITEM_EMPTY(script_hi) || HASHITEM_EMPTY(all_hi))
|
||||||
|
return;
|
||||||
|
|
||||||
dictitem_T *di = HI2DI(script_hi);
|
dictitem_T *di = HI2DI(script_hi);
|
||||||
sallvar_T *sav = HI2SAV(all_hi);
|
sallvar_T *sav = HI2SAV(all_hi);
|
||||||
sallvar_T *sav_prev = NULL;
|
sallvar_T *sav_prev = NULL;
|
||||||
@ -1020,8 +1022,9 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
|
|||||||
sav_prev = sav;
|
sav_prev = sav;
|
||||||
sav = sav->sav_next;
|
sav = sav->sav_next;
|
||||||
}
|
}
|
||||||
if (sav != NULL)
|
if (sav == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (func_defined)
|
if (func_defined)
|
||||||
{
|
{
|
||||||
// move the typval from the dictitem to the sallvar
|
// move the typval from the dictitem to the sallvar
|
||||||
@ -1042,8 +1045,6 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
|
|||||||
}
|
}
|
||||||
delete_var(script_ht, script_hi);
|
delete_var(script_ht, script_hi);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the script-local variable that links to "dest".
|
* Find the script-local variable that links to "dest".
|
||||||
|
@ -37,11 +37,11 @@ get_type_ptr(garray_T *type_gap)
|
|||||||
if (ga_grow(type_gap, 1) == FAIL)
|
if (ga_grow(type_gap, 1) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
type = ALLOC_CLEAR_ONE(type_T);
|
type = ALLOC_CLEAR_ONE(type_T);
|
||||||
if (type != NULL)
|
if (type == NULL)
|
||||||
{
|
return NULL;
|
||||||
|
|
||||||
((type_T **)type_gap->ga_data)[type_gap->ga_len] = type;
|
((type_T **)type_gap->ga_data)[type_gap->ga_len] = type;
|
||||||
++type_gap->ga_len;
|
++type_gap->ga_len;
|
||||||
}
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,8 +628,9 @@ typval2type(typval_T *tv, int copyID, garray_T *type_gap, int flags)
|
|||||||
{
|
{
|
||||||
type_T *type = typval2type_int(tv, copyID, type_gap, flags);
|
type_T *type = typval2type_int(tv, copyID, type_gap, flags);
|
||||||
|
|
||||||
if (type != NULL)
|
if (type == NULL)
|
||||||
{
|
return NULL;
|
||||||
|
|
||||||
if (type != &t_bool && (tv->v_type == VAR_NUMBER
|
if (type != &t_bool && (tv->v_type == VAR_NUMBER
|
||||||
&& (tv->vval.v_number == 0 || tv->vval.v_number == 1)))
|
&& (tv->vval.v_number == 0 || tv->vval.v_number == 1)))
|
||||||
// Number 0 and 1 and expression with "&&" or "||" can also be used
|
// Number 0 and 1 and expression with "&&" or "||" can also be used
|
||||||
@ -638,7 +639,6 @@ typval2type(typval_T *tv, int copyID, garray_T *type_gap, int flags)
|
|||||||
else if (type != &t_float && tv->v_type == VAR_NUMBER)
|
else if (type != &t_float && tv->v_type == VAR_NUMBER)
|
||||||
// A number can also be used for float.
|
// A number can also be used for float.
|
||||||
type = &t_number_float;
|
type = &t_number_float;
|
||||||
}
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,8 +385,8 @@ removable(char_u *name)
|
|||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
name = home_replace_save(NULL, name);
|
name = home_replace_save(NULL, name);
|
||||||
if (name != NULL)
|
if (name == NULL)
|
||||||
{
|
return FALSE;
|
||||||
for (p = p_viminfo; *p; )
|
for (p = p_viminfo; *p; )
|
||||||
{
|
{
|
||||||
copy_option_part(&p, part, 51, ", ");
|
copy_option_part(&p, part, 51, ", ");
|
||||||
@ -401,7 +401,6 @@ removable(char_u *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vim_free(name);
|
vim_free(name);
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,25 +533,29 @@ read_viminfo_history(vir_T *virp, int writing)
|
|||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
long_u len;
|
long_u len;
|
||||||
char_u *val;
|
char_u *val = NULL;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
type = hist_char2type(virp->vir_line[0]);
|
type = hist_char2type(virp->vir_line[0]);
|
||||||
if (viminfo_hisidx[type] < viminfo_hislen[type])
|
if (viminfo_hisidx[type] >= viminfo_hislen[type])
|
||||||
{
|
goto done;
|
||||||
|
|
||||||
val = viminfo_readstring(virp, 1, TRUE);
|
val = viminfo_readstring(virp, 1, TRUE);
|
||||||
if (val != NULL && *val != NUL)
|
if (val == NULL || *val == NUL)
|
||||||
{
|
goto done;
|
||||||
|
|
||||||
int sep = (*val == ' ' ? NUL : *val);
|
int sep = (*val == ' ' ? NUL : *val);
|
||||||
|
|
||||||
if (!in_history(type, val + (type == HIST_SEARCH),
|
if (in_history(type, val + (type == HIST_SEARCH), viminfo_add_at_front,
|
||||||
viminfo_add_at_front, sep, writing))
|
sep, writing))
|
||||||
{
|
goto done;
|
||||||
|
|
||||||
// Need to re-allocate to append the separator byte.
|
// Need to re-allocate to append the separator byte.
|
||||||
len = STRLEN(val);
|
len = STRLEN(val);
|
||||||
p = alloc(len + 2);
|
p = alloc(len + 2);
|
||||||
if (p != NULL)
|
if (p == NULL)
|
||||||
{
|
goto done;
|
||||||
|
|
||||||
if (type == HIST_SEARCH)
|
if (type == HIST_SEARCH)
|
||||||
{
|
{
|
||||||
// Search entry: Move the separator from the first
|
// Search entry: Move the separator from the first
|
||||||
@ -572,11 +575,9 @@ read_viminfo_history(vir_T *virp, int writing)
|
|||||||
viminfo_history[type][viminfo_hisidx[type]].viminfo = TRUE;
|
viminfo_history[type][viminfo_hisidx[type]].viminfo = TRUE;
|
||||||
viminfo_history[type][viminfo_hisidx[type]].hisnum = 0;
|
viminfo_history[type][viminfo_hisidx[type]].hisnum = 0;
|
||||||
viminfo_hisidx[type]++;
|
viminfo_hisidx[type]++;
|
||||||
}
|
|
||||||
}
|
done:
|
||||||
}
|
|
||||||
vim_free(val);
|
vim_free(val);
|
||||||
}
|
|
||||||
return viminfo_readline(virp);
|
return viminfo_readline(virp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,18 +608,22 @@ handle_viminfo_history(
|
|||||||
type = vp[0].bv_nr;
|
type = vp[0].bv_nr;
|
||||||
if (type >= HIST_COUNT)
|
if (type >= HIST_COUNT)
|
||||||
return;
|
return;
|
||||||
if (viminfo_hisidx[type] < viminfo_hislen[type])
|
|
||||||
{
|
if (viminfo_hisidx[type] >= viminfo_hislen[type])
|
||||||
|
return;
|
||||||
|
|
||||||
val = vp[3].bv_string;
|
val = vp[3].bv_string;
|
||||||
if (val != NULL && *val != NUL)
|
if (val == NULL || *val == NUL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
int sep = type == HIST_SEARCH && vp[2].bv_type == BVAL_NR
|
int sep = type == HIST_SEARCH && vp[2].bv_type == BVAL_NR
|
||||||
? vp[2].bv_nr : NUL;
|
? vp[2].bv_nr : NUL;
|
||||||
int idx;
|
int idx;
|
||||||
int overwrite = FALSE;
|
int overwrite = FALSE;
|
||||||
|
|
||||||
if (!in_history(type, val, viminfo_add_at_front, sep, writing))
|
if (in_history(type, val, viminfo_add_at_front, sep, writing))
|
||||||
{
|
return;
|
||||||
|
|
||||||
// If lines were written by an older Vim we need to avoid
|
// If lines were written by an older Vim we need to avoid
|
||||||
// getting duplicates. See if the entry already exists.
|
// getting duplicates. See if the entry already exists.
|
||||||
for (idx = 0; idx < viminfo_hisidx[type]; ++idx)
|
for (idx = 0; idx < viminfo_hisidx[type]; ++idx)
|
||||||
@ -655,9 +660,6 @@ handle_viminfo_history(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Concatenate history lines from viminfo after the lines typed in this Vim.
|
* Concatenate history lines from viminfo after the lines typed in this Vim.
|
||||||
@ -943,8 +945,9 @@ write_viminfo_barlines(vir_T *virp, FILE *fp_out)
|
|||||||
int seen_useful = FALSE;
|
int seen_useful = FALSE;
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if (gap->ga_len > 0)
|
if (gap->ga_len <= 0)
|
||||||
{
|
return;
|
||||||
|
|
||||||
fputs(_("\n# Bar lines, copied verbatim:\n"), fp_out);
|
fputs(_("\n# Bar lines, copied verbatim:\n"), fp_out);
|
||||||
|
|
||||||
// Skip over continuation lines until seeing a useful line.
|
// Skip over continuation lines until seeing a useful line.
|
||||||
@ -958,7 +961,6 @@ write_viminfo_barlines(vir_T *virp, FILE *fp_out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse a viminfo line starting with '|'.
|
* Parse a viminfo line starting with '|'.
|
||||||
@ -1408,12 +1410,12 @@ write_viminfo_sub_string(FILE *fp)
|
|||||||
{
|
{
|
||||||
char_u *old_sub = get_old_sub();
|
char_u *old_sub = get_old_sub();
|
||||||
|
|
||||||
if (get_viminfo_parameter('/') != 0 && old_sub != NULL)
|
if (get_viminfo_parameter('/') == 0 || old_sub == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
fputs(_("\n# Last Substitute String:\n$"), fp);
|
fputs(_("\n# Last Substitute String:\n$"), fp);
|
||||||
viminfo_writestring(fp, old_sub);
|
viminfo_writestring(fp, old_sub);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions relating to reading/writing the search pattern from viminfo
|
* Functions relating to reading/writing the search pattern from viminfo
|
||||||
@ -1511,8 +1513,9 @@ wvsp_one(
|
|||||||
int sc) // dir char
|
int sc) // dir char
|
||||||
{
|
{
|
||||||
spat_T *spat = get_spat(idx);
|
spat_T *spat = get_spat(idx);
|
||||||
if (spat->pat != NULL)
|
if (spat->pat == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
fprintf(fp, _("\n# Last %sSearch Pattern:\n~"), s);
|
fprintf(fp, _("\n# Last %sSearch Pattern:\n~"), s);
|
||||||
// off.dir is not stored, it's reset to forward
|
// off.dir is not stored, it's reset to forward
|
||||||
fprintf(fp, "%c%c%c%c%ld%s%c",
|
fprintf(fp, "%c%c%c%c%ld%s%c",
|
||||||
@ -1525,13 +1528,13 @@ wvsp_one(
|
|||||||
sc);
|
sc);
|
||||||
viminfo_writestring(fp, spat->pat);
|
viminfo_writestring(fp, spat->pat);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_viminfo_search_pattern(FILE *fp)
|
write_viminfo_search_pattern(FILE *fp)
|
||||||
{
|
{
|
||||||
if (get_viminfo_parameter('/') != 0)
|
if (get_viminfo_parameter('/') == 0)
|
||||||
{
|
return;
|
||||||
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
fprintf(fp, "\n# hlsearch on (H) or off (h):\n~%c",
|
fprintf(fp, "\n# hlsearch on (H) or off (h):\n~%c",
|
||||||
(no_hlsearch || find_viminfo_parameter('h') != NULL) ? 'h' : 'H');
|
(no_hlsearch || find_viminfo_parameter('h') != NULL) ? 'h' : 'H');
|
||||||
@ -1539,7 +1542,6 @@ write_viminfo_search_pattern(FILE *fp)
|
|||||||
wvsp_one(fp, RE_SEARCH, "", '/');
|
wvsp_one(fp, RE_SEARCH, "", '/');
|
||||||
wvsp_one(fp, RE_SUBST, _("Substitute "), '&');
|
wvsp_one(fp, RE_SUBST, _("Substitute "), '&');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions relating to reading/writing registers from viminfo
|
* Functions relating to reading/writing registers from viminfo
|
||||||
@ -1565,8 +1567,9 @@ finish_viminfo_registers(void)
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (y_read_regs != NULL)
|
if (y_read_regs == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
for (i = 0; i < NUM_REGISTERS; ++i)
|
for (i = 0; i < NUM_REGISTERS; ++i)
|
||||||
if (y_read_regs[i].y_array != NULL)
|
if (y_read_regs[i].y_array != NULL)
|
||||||
{
|
{
|
||||||
@ -1576,7 +1579,6 @@ finish_viminfo_registers(void)
|
|||||||
}
|
}
|
||||||
VIM_CLEAR(y_read_regs);
|
VIM_CLEAR(y_read_regs);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_viminfo_register(vir_T *virp, int force)
|
read_viminfo_register(vir_T *virp, int force)
|
||||||
|
@ -149,12 +149,12 @@ MultiByteToWideChar_alloc(UINT cp, DWORD flags,
|
|||||||
*outlen = MultiByteToWideChar(cp, flags, in, inlen, 0, 0);
|
*outlen = MultiByteToWideChar(cp, flags, in, inlen, 0, 0);
|
||||||
// Add one word to avoid a zero-length alloc().
|
// Add one word to avoid a zero-length alloc().
|
||||||
*out = ALLOC_MULT(WCHAR, *outlen + 1);
|
*out = ALLOC_MULT(WCHAR, *outlen + 1);
|
||||||
if (*out != NULL)
|
if (*out == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
MultiByteToWideChar(cp, flags, in, inlen, *out, *outlen);
|
MultiByteToWideChar(cp, flags, in, inlen, *out, *outlen);
|
||||||
(*out)[*outlen] = 0;
|
(*out)[*outlen] = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call WideCharToMultiByte() and allocate memory for the result.
|
* Call WideCharToMultiByte() and allocate memory for the result.
|
||||||
@ -169,12 +169,11 @@ WideCharToMultiByte_alloc(UINT cp, DWORD flags,
|
|||||||
*outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef);
|
*outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef);
|
||||||
// Add one byte to avoid a zero-length alloc().
|
// Add one byte to avoid a zero-length alloc().
|
||||||
*out = alloc(*outlen + 1);
|
*out = alloc(*outlen + 1);
|
||||||
if (*out != NULL)
|
if (*out == NULL)
|
||||||
{
|
return;
|
||||||
WideCharToMultiByte(cp, flags, in, inlen, *out, *outlen, def, useddef);
|
WideCharToMultiByte(cp, flags, in, inlen, *out, *outlen, def, useddef);
|
||||||
(*out)[*outlen] = 0;
|
(*out)[*outlen] = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FEAT_CLIPBOARD
|
#ifdef FEAT_CLIPBOARD
|
||||||
@ -743,13 +742,12 @@ acp_to_enc(
|
|||||||
|
|
||||||
MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)str, str_size,
|
MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)str, str_size,
|
||||||
&widestr, outlen);
|
&widestr, outlen);
|
||||||
if (widestr != NULL)
|
if (widestr == NULL)
|
||||||
{
|
return;
|
||||||
++*outlen; // Include the 0 after the string
|
++*outlen; // Include the 0 after the string
|
||||||
*out = utf16_to_enc((short_u *)widestr, outlen);
|
*out = utf16_to_enc((short_u *)widestr, outlen);
|
||||||
vim_free(widestr);
|
vim_free(widestr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert from 'encoding' to the active codepage.
|
* Convert from 'encoding' to the active codepage.
|
||||||
@ -768,10 +766,9 @@ enc_to_acp(
|
|||||||
int len = str_size;
|
int len = str_size;
|
||||||
|
|
||||||
widestr = (WCHAR *)enc_to_utf16(str, &len);
|
widestr = (WCHAR *)enc_to_utf16(str, &len);
|
||||||
if (widestr != NULL)
|
if (widestr == NULL)
|
||||||
{
|
return;
|
||||||
WideCharToMultiByte_alloc(GetACP(), 0, widestr, len,
|
WideCharToMultiByte_alloc(GetACP(), 0, widestr, len,
|
||||||
(LPSTR *)out, outlen, 0, 0);
|
(LPSTR *)out, outlen, 0, 0);
|
||||||
vim_free(widestr);
|
vim_free(widestr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
42
src/window.c
42
src/window.c
@ -2469,8 +2469,9 @@ close_last_window_tabpage(
|
|||||||
int free_buf,
|
int free_buf,
|
||||||
tabpage_T *prev_curtab)
|
tabpage_T *prev_curtab)
|
||||||
{
|
{
|
||||||
if (ONE_WINDOW)
|
if (!ONE_WINDOW)
|
||||||
{
|
return FALSE;
|
||||||
|
|
||||||
buf_T *old_curbuf = curbuf;
|
buf_T *old_curbuf = curbuf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2499,8 +2500,6 @@ close_last_window_tabpage(
|
|||||||
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the buffer of "win" and unload it if "action" is DOBUF_UNLOAD.
|
* Close the buffer of "win" and unload it if "action" is DOBUF_UNLOAD.
|
||||||
@ -4205,15 +4204,14 @@ win_alloc_popup_win(void)
|
|||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
|
||||||
wp = win_alloc(NULL, TRUE);
|
wp = win_alloc(NULL, TRUE);
|
||||||
if (wp != NULL)
|
if (wp == NULL)
|
||||||
{
|
return NULL;
|
||||||
// We need to initialize options with something, using the current
|
// We need to initialize options with something, using the current
|
||||||
// window makes most sense.
|
// window makes most sense.
|
||||||
win_init_some(wp, curwin);
|
win_init_some(wp, curwin);
|
||||||
|
|
||||||
RESET_BINDING(wp);
|
RESET_BINDING(wp);
|
||||||
new_frame(wp);
|
new_frame(wp);
|
||||||
}
|
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4287,12 +4285,11 @@ new_frame(win_T *wp)
|
|||||||
frame_T *frp = ALLOC_CLEAR_ONE(frame_T);
|
frame_T *frp = ALLOC_CLEAR_ONE(frame_T);
|
||||||
|
|
||||||
wp->w_frame = frp;
|
wp->w_frame = frp;
|
||||||
if (frp != NULL)
|
if (frp == NULL)
|
||||||
{
|
return;
|
||||||
frp->fr_layout = FR_LEAF;
|
frp->fr_layout = FR_LEAF;
|
||||||
frp->fr_win = wp;
|
frp->fr_win = wp;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the window and frame size to the maximum.
|
* Initialize the window and frame size to the maximum.
|
||||||
@ -4489,14 +4486,13 @@ may_open_tabpage(void)
|
|||||||
int n = (cmdmod.cmod_tab == 0)
|
int n = (cmdmod.cmod_tab == 0)
|
||||||
? postponed_split_tab : cmdmod.cmod_tab;
|
? postponed_split_tab : cmdmod.cmod_tab;
|
||||||
|
|
||||||
if (n != 0)
|
if (n == 0)
|
||||||
{
|
return FAIL;
|
||||||
|
|
||||||
cmdmod.cmod_tab = 0; // reset it to avoid doing it twice
|
cmdmod.cmod_tab = 0; // reset it to avoid doing it twice
|
||||||
postponed_split_tab = 0;
|
postponed_split_tab = 0;
|
||||||
return win_new_tabpage(n);
|
return win_new_tabpage(n);
|
||||||
}
|
}
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create up to "maxcount" tabpages with empty windows.
|
* Create up to "maxcount" tabpages with empty windows.
|
||||||
@ -4880,13 +4876,12 @@ goto_tabpage_tp(
|
|||||||
int
|
int
|
||||||
goto_tabpage_lastused(void)
|
goto_tabpage_lastused(void)
|
||||||
{
|
{
|
||||||
if (valid_tabpage(lastused_tabpage))
|
if (!valid_tabpage(lastused_tabpage))
|
||||||
{
|
return FAIL;
|
||||||
|
|
||||||
goto_tabpage_tp(lastused_tabpage, TRUE, TRUE);
|
goto_tabpage_tp(lastused_tabpage, TRUE, TRUE);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enter window "wp" in tab page "tp".
|
* Enter window "wp" in tab page "tp".
|
||||||
@ -5907,8 +5902,9 @@ win_size_save(garray_T *gap)
|
|||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
|
||||||
ga_init2(gap, sizeof(int), 1);
|
ga_init2(gap, sizeof(int), 1);
|
||||||
if (ga_grow(gap, win_count() * 2 + 1) == OK)
|
if (ga_grow(gap, win_count() * 2 + 1) == FAIL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
// first entry is value of 'lines'
|
// first entry is value of 'lines'
|
||||||
((int *)gap->ga_data)[gap->ga_len++] = Rows;
|
((int *)gap->ga_data)[gap->ga_len++] = Rows;
|
||||||
|
|
||||||
@ -5919,7 +5915,6 @@ win_size_save(garray_T *gap)
|
|||||||
((int *)gap->ga_data)[gap->ga_len++] = wp->w_height;
|
((int *)gap->ga_data)[gap->ga_len++] = wp->w_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restore window sizes, but only if the number of windows is still the same
|
* Restore window sizes, but only if the number of windows is still the same
|
||||||
@ -7429,13 +7424,12 @@ clear_snapshot(tabpage_T *tp, int idx)
|
|||||||
static void
|
static void
|
||||||
clear_snapshot_rec(frame_T *fr)
|
clear_snapshot_rec(frame_T *fr)
|
||||||
{
|
{
|
||||||
if (fr != NULL)
|
if (fr == NULL)
|
||||||
{
|
return;
|
||||||
clear_snapshot_rec(fr->fr_next);
|
clear_snapshot_rec(fr->fr_next);
|
||||||
clear_snapshot_rec(fr->fr_child);
|
clear_snapshot_rec(fr->fr_child);
|
||||||
vim_free(fr);
|
vim_free(fr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traverse a snapshot to find the previous curwin.
|
* Traverse a snapshot to find the previous curwin.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user