mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.0.1196: 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 #11813)
This commit is contained in:
committed by
Bram Moolenaar
parent
378e6c03f9
commit
e857598896
100
src/job.c
100
src/job.c
@@ -793,11 +793,11 @@ job_free_job(job_T *job)
|
|||||||
static void
|
static void
|
||||||
job_free(job_T *job)
|
job_free(job_T *job)
|
||||||
{
|
{
|
||||||
if (!in_free_unref_items)
|
if (in_free_unref_items)
|
||||||
{
|
return;
|
||||||
job_free_contents(job);
|
|
||||||
job_free_job(job);
|
job_free_contents(job);
|
||||||
}
|
job_free_job(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
static job_T *jobs_to_free = NULL;
|
static job_T *jobs_to_free = NULL;
|
||||||
@@ -1087,28 +1087,28 @@ set_ref_in_job(int copyID)
|
|||||||
void
|
void
|
||||||
job_unref(job_T *job)
|
job_unref(job_T *job)
|
||||||
{
|
{
|
||||||
if (job != NULL && --job->jv_refcount <= 0)
|
if (job == NULL || --job->jv_refcount > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Do not free the job if there is a channel where the close callback
|
||||||
|
// may get the job info.
|
||||||
|
if (job_channel_still_useful(job))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Do not free the job when it has not ended yet and there is a
|
||||||
|
// "stoponexit" flag or an exit callback.
|
||||||
|
if (!job_need_end_check(job))
|
||||||
{
|
{
|
||||||
// Do not free the job if there is a channel where the close callback
|
job_free(job);
|
||||||
// may get the job info.
|
}
|
||||||
if (!job_channel_still_useful(job))
|
else if (job->jv_channel != NULL)
|
||||||
{
|
{
|
||||||
// Do not free the job when it has not ended yet and there is a
|
// Do remove the link to the channel, otherwise it hangs
|
||||||
// "stoponexit" flag or an exit callback.
|
// around until Vim exits. See job_free() for refcount.
|
||||||
if (!job_need_end_check(job))
|
ch_log(job->jv_channel, "detaching channel from job");
|
||||||
{
|
job->jv_channel->ch_job = NULL;
|
||||||
job_free(job);
|
channel_unref(job->jv_channel);
|
||||||
}
|
job->jv_channel = NULL;
|
||||||
else if (job->jv_channel != NULL)
|
|
||||||
{
|
|
||||||
// Do remove the link to the channel, otherwise it hangs
|
|
||||||
// around until Vim exits. See job_free() for refcount.
|
|
||||||
ch_log(job->jv_channel, "detaching channel from job");
|
|
||||||
job->jv_channel->ch_job = NULL;
|
|
||||||
channel_unref(job->jv_channel);
|
|
||||||
job->jv_channel = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1157,18 +1157,18 @@ job_alloc(void)
|
|||||||
job_T *job;
|
job_T *job;
|
||||||
|
|
||||||
job = ALLOC_CLEAR_ONE(job_T);
|
job = ALLOC_CLEAR_ONE(job_T);
|
||||||
if (job != NULL)
|
if (job == NULL)
|
||||||
{
|
return NULL;
|
||||||
job->jv_refcount = 1;
|
|
||||||
job->jv_stoponexit = vim_strsave((char_u *)"term");
|
|
||||||
|
|
||||||
if (first_job != NULL)
|
job->jv_refcount = 1;
|
||||||
{
|
job->jv_stoponexit = vim_strsave((char_u *)"term");
|
||||||
first_job->jv_prev = job;
|
|
||||||
job->jv_next = first_job;
|
if (first_job != NULL)
|
||||||
}
|
{
|
||||||
first_job = job;
|
first_job->jv_prev = job;
|
||||||
|
job->jv_next = first_job;
|
||||||
}
|
}
|
||||||
|
first_job = job;
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1803,13 +1803,13 @@ f_job_getchannel(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
job = get_job_arg(&argvars[0]);
|
job = get_job_arg(&argvars[0]);
|
||||||
if (job != NULL)
|
if (job == NULL)
|
||||||
{
|
return;
|
||||||
rettv->v_type = VAR_CHANNEL;
|
|
||||||
rettv->vval.v_channel = job->jv_channel;
|
rettv->v_type = VAR_CHANNEL;
|
||||||
if (job->jv_channel != NULL)
|
rettv->vval.v_channel = job->jv_channel;
|
||||||
++job->jv_channel->ch_refcount;
|
if (job->jv_channel != NULL)
|
||||||
}
|
++job->jv_channel->ch_refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1855,13 +1855,13 @@ job_info(job_T *job, dict_T *dict)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
l = list_alloc();
|
l = list_alloc();
|
||||||
if (l != NULL)
|
if (l == NULL)
|
||||||
{
|
return;
|
||||||
dict_add_list(dict, "cmd", l);
|
|
||||||
if (job->jv_argv != NULL)
|
dict_add_list(dict, "cmd", l);
|
||||||
for (i = 0; job->jv_argv[i] != NULL; i++)
|
if (job->jv_argv != NULL)
|
||||||
list_append_string(l, (char_u *)job->jv_argv[i], -1);
|
for (i = 0; job->jv_argv[i] != NULL; i++)
|
||||||
}
|
list_append_string(l, (char_u *)job->jv_argv[i], -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
222
src/list.c
222
src/list.c
@@ -124,27 +124,27 @@ list_alloc_with_items(int count)
|
|||||||
|
|
||||||
list_init(l);
|
list_init(l);
|
||||||
|
|
||||||
if (count > 0)
|
if (count <= 0)
|
||||||
{
|
return l;
|
||||||
listitem_T *li = (listitem_T *)(l + 1);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
l->lv_len = count;
|
listitem_T *li = (listitem_T *)(l + 1);
|
||||||
l->lv_with_items = count;
|
int i;
|
||||||
l->lv_first = li;
|
|
||||||
l->lv_u.mat.lv_last = li + count - 1;
|
l->lv_len = count;
|
||||||
for (i = 0; i < count; ++i)
|
l->lv_with_items = count;
|
||||||
{
|
l->lv_first = li;
|
||||||
if (i == 0)
|
l->lv_u.mat.lv_last = li + count - 1;
|
||||||
li->li_prev = NULL;
|
for (i = 0; i < count; ++i)
|
||||||
else
|
{
|
||||||
li->li_prev = li - 1;
|
if (i == 0)
|
||||||
if (i == count - 1)
|
li->li_prev = NULL;
|
||||||
li->li_next = NULL;
|
else
|
||||||
else
|
li->li_prev = li - 1;
|
||||||
li->li_next = li + 1;
|
if (i == count - 1)
|
||||||
++li;
|
li->li_next = NULL;
|
||||||
}
|
else
|
||||||
|
li->li_next = li + 1;
|
||||||
|
++li;
|
||||||
}
|
}
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
@@ -297,11 +297,11 @@ list_free_items(int copyID)
|
|||||||
void
|
void
|
||||||
list_free(list_T *l)
|
list_free(list_T *l)
|
||||||
{
|
{
|
||||||
if (!in_free_unref_items)
|
if (in_free_unref_items)
|
||||||
{
|
return;
|
||||||
list_free_contents(l);
|
|
||||||
list_free_list(l);
|
list_free_contents(l);
|
||||||
}
|
list_free_list(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -540,13 +540,13 @@ list_find_index(list_T *l, long *idx)
|
|||||||
{
|
{
|
||||||
listitem_T *li = list_find(l, *idx);
|
listitem_T *li = list_find(l, *idx);
|
||||||
|
|
||||||
if (li == NULL)
|
if (li != NULL)
|
||||||
|
return li;
|
||||||
|
|
||||||
|
if (*idx < 0)
|
||||||
{
|
{
|
||||||
if (*idx < 0)
|
*idx = 0;
|
||||||
{
|
li = list_find(l, *idx);
|
||||||
*idx = 0;
|
|
||||||
li = list_find(l, *idx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return li;
|
return li;
|
||||||
}
|
}
|
||||||
@@ -772,21 +772,21 @@ check_range_index_one(list_T *l, long *n1, int can_append, int quiet)
|
|||||||
long orig_n1 = *n1;
|
long orig_n1 = *n1;
|
||||||
listitem_T *li = list_find_index(l, n1);
|
listitem_T *li = list_find_index(l, n1);
|
||||||
|
|
||||||
|
if (li != NULL)
|
||||||
|
return li;
|
||||||
|
|
||||||
|
// Vim9: Allow for adding an item at the end.
|
||||||
|
if (can_append && in_vim9script()
|
||||||
|
&& *n1 == l->lv_len && l->lv_lock == 0)
|
||||||
|
{
|
||||||
|
list_append_number(l, 0);
|
||||||
|
li = list_find_index(l, n1);
|
||||||
|
}
|
||||||
if (li == NULL)
|
if (li == NULL)
|
||||||
{
|
{
|
||||||
// Vim9: Allow for adding an item at the end.
|
if (!quiet)
|
||||||
if (can_append && in_vim9script()
|
semsg(_(e_list_index_out_of_range_nr), orig_n1);
|
||||||
&& *n1 == l->lv_len && l->lv_lock == 0)
|
return NULL;
|
||||||
{
|
|
||||||
list_append_number(l, 0);
|
|
||||||
li = list_find_index(l, n1);
|
|
||||||
}
|
|
||||||
if (li == NULL)
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
semsg(_(e_list_index_out_of_range_nr), orig_n1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return li;
|
return li;
|
||||||
}
|
}
|
||||||
@@ -1286,45 +1286,45 @@ list_copy(list_T *orig, int deep, int top, int copyID)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
copy = list_alloc();
|
copy = list_alloc();
|
||||||
if (copy != NULL)
|
if (copy == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (orig->lv_type == NULL || top || deep)
|
||||||
|
copy->lv_type = NULL;
|
||||||
|
else
|
||||||
|
copy->lv_type = alloc_type(orig->lv_type);
|
||||||
|
if (copyID != 0)
|
||||||
{
|
{
|
||||||
if (orig->lv_type == NULL || top || deep)
|
// Do this before adding the items, because one of the items may
|
||||||
copy->lv_type = NULL;
|
// refer back to this list.
|
||||||
else
|
orig->lv_copyID = copyID;
|
||||||
copy->lv_type = alloc_type(orig->lv_type);
|
orig->lv_copylist = copy;
|
||||||
if (copyID != 0)
|
}
|
||||||
|
CHECK_LIST_MATERIALIZE(orig);
|
||||||
|
for (item = orig->lv_first; item != NULL && !got_int;
|
||||||
|
item = item->li_next)
|
||||||
|
{
|
||||||
|
ni = listitem_alloc();
|
||||||
|
if (ni == NULL)
|
||||||
|
break;
|
||||||
|
if (deep)
|
||||||
{
|
{
|
||||||
// Do this before adding the items, because one of the items may
|
if (item_copy(&item->li_tv, &ni->li_tv,
|
||||||
// refer back to this list.
|
deep, FALSE, copyID) == FAIL)
|
||||||
orig->lv_copyID = copyID;
|
|
||||||
orig->lv_copylist = copy;
|
|
||||||
}
|
|
||||||
CHECK_LIST_MATERIALIZE(orig);
|
|
||||||
for (item = orig->lv_first; item != NULL && !got_int;
|
|
||||||
item = item->li_next)
|
|
||||||
{
|
|
||||||
ni = listitem_alloc();
|
|
||||||
if (ni == NULL)
|
|
||||||
break;
|
|
||||||
if (deep)
|
|
||||||
{
|
{
|
||||||
if (item_copy(&item->li_tv, &ni->li_tv,
|
vim_free(ni);
|
||||||
deep, FALSE, copyID) == FAIL)
|
break;
|
||||||
{
|
|
||||||
vim_free(ni);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
copy_tv(&item->li_tv, &ni->li_tv);
|
|
||||||
list_append(copy, ni);
|
|
||||||
}
|
|
||||||
++copy->lv_refcount;
|
|
||||||
if (item != NULL)
|
|
||||||
{
|
|
||||||
list_unref(copy);
|
|
||||||
copy = NULL;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
copy_tv(&item->li_tv, &ni->li_tv);
|
||||||
|
list_append(copy, ni);
|
||||||
|
}
|
||||||
|
++copy->lv_refcount;
|
||||||
|
if (item != NULL)
|
||||||
|
{
|
||||||
|
list_unref(copy);
|
||||||
|
copy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
@@ -1491,17 +1491,17 @@ list_join(
|
|||||||
retval = list_join_inner(gap, l, sep, echo_style, restore_copyID,
|
retval = list_join_inner(gap, l, sep, echo_style, restore_copyID,
|
||||||
copyID, &join_ga);
|
copyID, &join_ga);
|
||||||
|
|
||||||
|
if (join_ga.ga_data == NULL)
|
||||||
|
return retval;
|
||||||
|
|
||||||
// Dispose each item in join_ga.
|
// Dispose each item in join_ga.
|
||||||
if (join_ga.ga_data != NULL)
|
p = (join_T *)join_ga.ga_data;
|
||||||
|
for (i = 0; i < join_ga.ga_len; ++i)
|
||||||
{
|
{
|
||||||
p = (join_T *)join_ga.ga_data;
|
vim_free(p->tofree);
|
||||||
for (i = 0; i < join_ga.ga_len; ++i)
|
++p;
|
||||||
{
|
|
||||||
vim_free(p->tofree);
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
ga_clear(&join_ga);
|
|
||||||
}
|
}
|
||||||
|
ga_clear(&join_ga);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -2560,36 +2560,36 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
|
|||||||
// message. Avoid a misleading error message for an empty string that
|
// message. Avoid a misleading error message for an empty string that
|
||||||
// was not passed as argument.
|
// was not passed as argument.
|
||||||
expr = &argvars[1];
|
expr = &argvars[1];
|
||||||
if (expr->v_type != VAR_UNKNOWN)
|
if (expr->v_type == VAR_UNKNOWN)
|
||||||
{
|
return;
|
||||||
typval_T save_val;
|
|
||||||
typval_T save_key;
|
|
||||||
|
|
||||||
prepare_vimvar(VV_VAL, &save_val);
|
typval_T save_val;
|
||||||
prepare_vimvar(VV_KEY, &save_key);
|
typval_T save_key;
|
||||||
|
|
||||||
// We reset "did_emsg" to be able to detect whether an error
|
prepare_vimvar(VV_VAL, &save_val);
|
||||||
// occurred during evaluation of the expression.
|
prepare_vimvar(VV_KEY, &save_key);
|
||||||
save_did_emsg = did_emsg;
|
|
||||||
did_emsg = FALSE;
|
|
||||||
|
|
||||||
if (argvars[0].v_type == VAR_DICT)
|
// We reset "did_emsg" to be able to detect whether an error
|
||||||
dict_filter_map(argvars[0].vval.v_dict, filtermap, type, func_name,
|
// occurred during evaluation of the expression.
|
||||||
arg_errmsg, expr, rettv);
|
save_did_emsg = did_emsg;
|
||||||
else if (argvars[0].v_type == VAR_BLOB)
|
did_emsg = FALSE;
|
||||||
blob_filter_map(argvars[0].vval.v_blob, filtermap, expr, rettv);
|
|
||||||
else if (argvars[0].v_type == VAR_STRING)
|
|
||||||
string_filter_map(tv_get_string(&argvars[0]), filtermap, expr,
|
|
||||||
rettv);
|
|
||||||
else // argvars[0].v_type == VAR_LIST
|
|
||||||
list_filter_map(argvars[0].vval.v_list, filtermap, type, func_name,
|
|
||||||
arg_errmsg, expr, rettv);
|
|
||||||
|
|
||||||
restore_vimvar(VV_KEY, &save_key);
|
if (argvars[0].v_type == VAR_DICT)
|
||||||
restore_vimvar(VV_VAL, &save_val);
|
dict_filter_map(argvars[0].vval.v_dict, filtermap, type, func_name,
|
||||||
|
arg_errmsg, expr, rettv);
|
||||||
|
else if (argvars[0].v_type == VAR_BLOB)
|
||||||
|
blob_filter_map(argvars[0].vval.v_blob, filtermap, expr, rettv);
|
||||||
|
else if (argvars[0].v_type == VAR_STRING)
|
||||||
|
string_filter_map(tv_get_string(&argvars[0]), filtermap, expr,
|
||||||
|
rettv);
|
||||||
|
else // argvars[0].v_type == VAR_LIST
|
||||||
|
list_filter_map(argvars[0].vval.v_list, filtermap, type, func_name,
|
||||||
|
arg_errmsg, expr, rettv);
|
||||||
|
|
||||||
did_emsg |= save_did_emsg;
|
restore_vimvar(VV_KEY, &save_key);
|
||||||
}
|
restore_vimvar(VV_VAL, &save_val);
|
||||||
|
|
||||||
|
did_emsg |= save_did_emsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
47
src/locale.c
47
src/locale.c
@@ -151,20 +151,20 @@ get_mess_env(void)
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
p = mch_getenv((char_u *)"LC_ALL");
|
p = mch_getenv((char_u *)"LC_ALL");
|
||||||
if (p == NULL || *p == NUL)
|
if (p != NULL && *p != NUL)
|
||||||
{
|
return p;
|
||||||
p = mch_getenv((char_u *)"LC_MESSAGES");
|
|
||||||
if (p == NULL || *p == NUL)
|
p = mch_getenv((char_u *)"LC_MESSAGES");
|
||||||
{
|
if (p != NULL && *p != NUL)
|
||||||
p = mch_getenv((char_u *)"LANG");
|
return p;
|
||||||
if (p != NULL && VIM_ISDIGIT(*p))
|
|
||||||
p = NULL; // ignore something like "1043"
|
p = mch_getenv((char_u *)"LANG");
|
||||||
|
if (p != NULL && VIM_ISDIGIT(*p))
|
||||||
|
p = NULL; // ignore something like "1043"
|
||||||
# ifdef HAVE_GET_LOCALE_VAL
|
# ifdef HAVE_GET_LOCALE_VAL
|
||||||
if (p == NULL || *p == NUL)
|
if (p == NULL || *p == NUL)
|
||||||
p = get_locale_val(LC_CTYPE);
|
p = get_locale_val(LC_CTYPE);
|
||||||
# endif
|
# endif
|
||||||
}
|
|
||||||
}
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -504,11 +504,11 @@ find_locales(void)
|
|||||||
static void
|
static void
|
||||||
init_locales(void)
|
init_locales(void)
|
||||||
{
|
{
|
||||||
if (!did_init_locales)
|
if (did_init_locales)
|
||||||
{
|
return;
|
||||||
did_init_locales = TRUE;
|
|
||||||
locales = find_locales();
|
did_init_locales = TRUE;
|
||||||
}
|
locales = find_locales();
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(EXITFREE) || defined(PROTO)
|
# if defined(EXITFREE) || defined(PROTO)
|
||||||
@@ -516,12 +516,13 @@ init_locales(void)
|
|||||||
free_locales(void)
|
free_locales(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (locales != NULL)
|
|
||||||
{
|
if (locales == NULL)
|
||||||
for (i = 0; locales[i] != NULL; i++)
|
return;
|
||||||
vim_free(locales[i]);
|
|
||||||
VIM_CLEAR(locales);
|
for (i = 0; locales[i] != NULL; i++)
|
||||||
}
|
vim_free(locales[i]);
|
||||||
|
VIM_CLEAR(locales);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
49
src/main.c
49
src/main.c
@@ -3099,23 +3099,23 @@ exe_pre_commands(mparm_T *parmp)
|
|||||||
int i;
|
int i;
|
||||||
ESTACK_CHECK_DECLARATION
|
ESTACK_CHECK_DECLARATION
|
||||||
|
|
||||||
if (cnt > 0)
|
if (cnt <= 0)
|
||||||
{
|
return;
|
||||||
curwin->w_cursor.lnum = 0; // just in case..
|
|
||||||
estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
|
curwin->w_cursor.lnum = 0; // just in case..
|
||||||
ESTACK_CHECK_SETUP
|
estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
|
||||||
|
ESTACK_CHECK_SETUP
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = SID_CMDARG;
|
current_sctx.sc_sid = SID_CMDARG;
|
||||||
# endif
|
# endif
|
||||||
for (i = 0; i < cnt; ++i)
|
for (i = 0; i < cnt; ++i)
|
||||||
do_cmdline_cmd(cmds[i]);
|
do_cmdline_cmd(cmds[i]);
|
||||||
ESTACK_CHECK_NOW
|
ESTACK_CHECK_NOW
|
||||||
estack_pop();
|
estack_pop();
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = 0;
|
current_sctx.sc_sid = 0;
|
||||||
# endif
|
# endif
|
||||||
TIME_MSG("--cmd commands");
|
TIME_MSG("--cmd commands");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3369,28 +3369,27 @@ process_env(
|
|||||||
|
|
||||||
ESTACK_CHECK_DECLARATION
|
ESTACK_CHECK_DECLARATION
|
||||||
|
|
||||||
if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL)
|
if ((initstr = mch_getenv(env)) == NULL || *initstr == NUL)
|
||||||
{
|
return FAIL;
|
||||||
if (is_viminit)
|
|
||||||
vimrc_found(NULL, NULL);
|
if (is_viminit)
|
||||||
estack_push(ETYPE_ENV, env, 0);
|
vimrc_found(NULL, NULL);
|
||||||
ESTACK_CHECK_SETUP
|
estack_push(ETYPE_ENV, env, 0);
|
||||||
|
ESTACK_CHECK_SETUP
|
||||||
save_current_sctx = current_sctx;
|
save_current_sctx = current_sctx;
|
||||||
current_sctx.sc_version = 1;
|
current_sctx.sc_version = 1;
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = SID_ENV;
|
current_sctx.sc_sid = SID_ENV;
|
||||||
current_sctx.sc_seq = 0;
|
current_sctx.sc_seq = 0;
|
||||||
current_sctx.sc_lnum = 0;
|
current_sctx.sc_lnum = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_cmdline_cmd(initstr);
|
do_cmdline_cmd(initstr);
|
||||||
|
|
||||||
ESTACK_CHECK_NOW
|
ESTACK_CHECK_NOW
|
||||||
estack_pop();
|
estack_pop();
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN)
|
#if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN)
|
||||||
|
55
src/map.c
55
src/map.c
@@ -67,11 +67,11 @@ is_maphash_valid(void)
|
|||||||
static void
|
static void
|
||||||
validate_maphash(void)
|
validate_maphash(void)
|
||||||
{
|
{
|
||||||
if (!maphash_valid)
|
if (maphash_valid)
|
||||||
{
|
return;
|
||||||
CLEAR_FIELD(maphash);
|
|
||||||
maphash_valid = TRUE;
|
CLEAR_FIELD(maphash);
|
||||||
}
|
maphash_valid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -581,8 +581,8 @@ do_map(
|
|||||||
// needs to be freed later (*keys_buf and *arg_buf).
|
// needs to be freed later (*keys_buf and *arg_buf).
|
||||||
// replace_termcodes() also removes CTRL-Vs and sometimes backslashes.
|
// replace_termcodes() also removes CTRL-Vs and sometimes backslashes.
|
||||||
// If something like <C-H> is simplified to 0x08 then mark it as simplified
|
// If something like <C-H> is simplified to 0x08 then mark it as simplified
|
||||||
// and also add a n entry with a modifier, which will work when
|
// and also add an entry with a modifier, which will work when using a key
|
||||||
// modifyOtherKeys is working.
|
// protocol.
|
||||||
if (haskey)
|
if (haskey)
|
||||||
{
|
{
|
||||||
char_u *new_keys;
|
char_u *new_keys;
|
||||||
@@ -1843,32 +1843,33 @@ vim_strsave_escape_csi(char_u *p)
|
|||||||
// illegal utf-8 byte:
|
// illegal utf-8 byte:
|
||||||
// 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER
|
// 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER
|
||||||
res = alloc(STRLEN(p) * 4 + 1);
|
res = alloc(STRLEN(p) * 4 + 1);
|
||||||
if (res != NULL)
|
if (res == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
d = res;
|
||||||
|
for (s = p; *s != NUL; )
|
||||||
{
|
{
|
||||||
d = res;
|
if ((s[0] == K_SPECIAL
|
||||||
for (s = p; *s != NUL; )
|
|
||||||
{
|
|
||||||
if ((s[0] == K_SPECIAL
|
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
|| (gui.in_use && s[0] == CSI)
|
|| (gui.in_use && s[0] == CSI)
|
||||||
#endif
|
#endif
|
||||||
) && s[1] != NUL && s[2] != NUL)
|
) && s[1] != NUL && s[2] != NUL)
|
||||||
{
|
{
|
||||||
// Copy special key unmodified.
|
// Copy special key unmodified.
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add character, possibly multi-byte to destination, escaping
|
// Add character, possibly multi-byte to destination, escaping
|
||||||
// CSI and K_SPECIAL. Be careful, it can be an illegal byte!
|
// CSI and K_SPECIAL. Be careful, it can be an illegal byte!
|
||||||
d = add_char2buf(PTR2CHAR(s), d);
|
d = add_char2buf(PTR2CHAR(s), d);
|
||||||
s += MB_CPTR2LEN(s);
|
s += MB_CPTR2LEN(s);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*d = NUL;
|
|
||||||
}
|
}
|
||||||
|
*d = NUL;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
48
src/mark.c
48
src/mark.c
@@ -485,34 +485,34 @@ fname2fnum(xfmark_T *fm)
|
|||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
if (fm->fname != NULL)
|
if (fm->fname == NULL)
|
||||||
{
|
return;
|
||||||
/*
|
|
||||||
* First expand "~/" in the file name to the home directory.
|
/*
|
||||||
* Don't expand the whole name, it may contain other '~' chars.
|
* First expand "~/" in the file name to the home directory.
|
||||||
*/
|
* Don't expand the whole name, it may contain other '~' chars.
|
||||||
if (fm->fname[0] == '~' && (fm->fname[1] == '/'
|
*/
|
||||||
|
if (fm->fname[0] == '~' && (fm->fname[1] == '/'
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
|| fm->fname[1] == '\\'
|
|| fm->fname[1] == '\\'
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
expand_env((char_u *)"~/", NameBuff, MAXPATHL);
|
expand_env((char_u *)"~/", NameBuff, MAXPATHL);
|
||||||
len = (int)STRLEN(NameBuff);
|
len = (int)STRLEN(NameBuff);
|
||||||
vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1);
|
vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1);
|
||||||
}
|
|
||||||
else
|
|
||||||
vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1);
|
|
||||||
|
|
||||||
// Try to shorten the file name.
|
|
||||||
mch_dirname(IObuff, IOSIZE);
|
|
||||||
p = shorten_fname(NameBuff, IObuff);
|
|
||||||
|
|
||||||
// buflist_new() will call fmarks_check_names()
|
|
||||||
(void)buflist_new(NameBuff, p, (linenr_T)1, 0);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1);
|
||||||
|
|
||||||
|
// Try to shorten the file name.
|
||||||
|
mch_dirname(IObuff, IOSIZE);
|
||||||
|
p = shorten_fname(NameBuff, IObuff);
|
||||||
|
|
||||||
|
// buflist_new() will call fmarks_check_names()
|
||||||
|
(void)buflist_new(NameBuff, p, (linenr_T)1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
54
src/match.c
54
src/match.c
@@ -978,14 +978,14 @@ matchadd_dict_arg(typval_T *tv, char_u **conceal_char, win_T **win)
|
|||||||
if (dict_has_key(tv->vval.v_dict, "conceal"))
|
if (dict_has_key(tv->vval.v_dict, "conceal"))
|
||||||
*conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE);
|
*conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE);
|
||||||
|
|
||||||
if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL)
|
if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) == NULL)
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
*win = find_win_by_nr_or_id(&di->di_tv);
|
||||||
|
if (*win == NULL)
|
||||||
{
|
{
|
||||||
*win = find_win_by_nr_or_id(&di->di_tv);
|
emsg(_(e_invalid_window_number));
|
||||||
if (*win == NULL)
|
return FAIL;
|
||||||
{
|
|
||||||
emsg(_(e_invalid_window_number));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -1330,32 +1330,32 @@ f_matchaddpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
|||||||
void
|
void
|
||||||
f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
|
f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
{
|
{
|
||||||
if (rettv_list_alloc(rettv) == OK)
|
if (rettv_list_alloc(rettv) != OK)
|
||||||
{
|
return;
|
||||||
|
|
||||||
# ifdef FEAT_SEARCH_EXTRA
|
# ifdef FEAT_SEARCH_EXTRA
|
||||||
int id;
|
int id;
|
||||||
matchitem_T *m;
|
matchitem_T *m;
|
||||||
|
|
||||||
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id = (int)tv_get_number(&argvars[0]);
|
id = (int)tv_get_number(&argvars[0]);
|
||||||
if (id >= 1 && id <= 3)
|
if (id >= 1 && id <= 3)
|
||||||
|
{
|
||||||
|
if ((m = get_match(curwin, id)) != NULL)
|
||||||
{
|
{
|
||||||
if ((m = get_match(curwin, id)) != NULL)
|
list_append_string(rettv->vval.v_list,
|
||||||
{
|
syn_id2name(m->mit_hlg_id), -1);
|
||||||
list_append_string(rettv->vval.v_list,
|
list_append_string(rettv->vval.v_list, m->mit_pattern, -1);
|
||||||
syn_id2name(m->mit_hlg_id), -1);
|
}
|
||||||
list_append_string(rettv->vval.v_list, m->mit_pattern, -1);
|
else
|
||||||
}
|
{
|
||||||
else
|
list_append_string(rettv->vval.v_list, NULL, -1);
|
||||||
{
|
list_append_string(rettv->vval.v_list, NULL, -1);
|
||||||
list_append_string(rettv->vval.v_list, NULL, -1);
|
|
||||||
list_append_string(rettv->vval.v_list, NULL, -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
138
src/mbyte.c
138
src/mbyte.c
@@ -809,17 +809,17 @@ bomb_size(void)
|
|||||||
void
|
void
|
||||||
remove_bom(char_u *s)
|
remove_bom(char_u *s)
|
||||||
{
|
{
|
||||||
if (enc_utf8)
|
if (!enc_utf8)
|
||||||
{
|
return;
|
||||||
char_u *p = s;
|
|
||||||
|
|
||||||
while ((p = vim_strbyte(p, 0xef)) != NULL)
|
char_u *p = s;
|
||||||
{
|
|
||||||
if (p[1] == 0xbb && p[2] == 0xbf)
|
while ((p = vim_strbyte(p, 0xef)) != NULL)
|
||||||
STRMOVE(p, p + 3);
|
{
|
||||||
else
|
if (p[1] == 0xbb && p[2] == 0xbf)
|
||||||
++p;
|
STRMOVE(p, p + 3);
|
||||||
}
|
else
|
||||||
|
++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -4590,56 +4590,56 @@ enc_canonize(char_u *enc)
|
|||||||
|
|
||||||
// copy "enc" to allocated memory, with room for two '-'
|
// copy "enc" to allocated memory, with room for two '-'
|
||||||
r = alloc(STRLEN(enc) + 3);
|
r = alloc(STRLEN(enc) + 3);
|
||||||
if (r != NULL)
|
if (r == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Make it all lower case and replace '_' with '-'.
|
||||||
|
p = r;
|
||||||
|
for (s = enc; *s != NUL; ++s)
|
||||||
{
|
{
|
||||||
// Make it all lower case and replace '_' with '-'.
|
if (*s == '_')
|
||||||
p = r;
|
*p++ = '-';
|
||||||
for (s = enc; *s != NUL; ++s)
|
else
|
||||||
{
|
*p++ = TOLOWER_ASC(*s);
|
||||||
if (*s == '_')
|
}
|
||||||
*p++ = '-';
|
*p = NUL;
|
||||||
else
|
|
||||||
*p++ = TOLOWER_ASC(*s);
|
|
||||||
}
|
|
||||||
*p = NUL;
|
|
||||||
|
|
||||||
// Skip "2byte-" and "8bit-".
|
// Skip "2byte-" and "8bit-".
|
||||||
p = enc_skip(r);
|
p = enc_skip(r);
|
||||||
|
|
||||||
// Change "microsoft-cp" to "cp". Used in some spell files.
|
// Change "microsoft-cp" to "cp". Used in some spell files.
|
||||||
if (STRNCMP(p, "microsoft-cp", 12) == 0)
|
if (STRNCMP(p, "microsoft-cp", 12) == 0)
|
||||||
STRMOVE(p, p + 10);
|
STRMOVE(p, p + 10);
|
||||||
|
|
||||||
// "iso8859" -> "iso-8859"
|
// "iso8859" -> "iso-8859"
|
||||||
if (STRNCMP(p, "iso8859", 7) == 0)
|
if (STRNCMP(p, "iso8859", 7) == 0)
|
||||||
{
|
{
|
||||||
STRMOVE(p + 4, p + 3);
|
STRMOVE(p + 4, p + 3);
|
||||||
p[3] = '-';
|
p[3] = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// "iso-8859n" -> "iso-8859-n"
|
// "iso-8859n" -> "iso-8859-n"
|
||||||
if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8]))
|
if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8]))
|
||||||
{
|
{
|
||||||
STRMOVE(p + 9, p + 8);
|
STRMOVE(p + 9, p + 8);
|
||||||
p[8] = '-';
|
p[8] = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// "latin-N" -> "latinN"
|
// "latin-N" -> "latinN"
|
||||||
if (STRNCMP(p, "latin-", 6) == 0)
|
if (STRNCMP(p, "latin-", 6) == 0)
|
||||||
STRMOVE(p + 5, p + 6);
|
STRMOVE(p + 5, p + 6);
|
||||||
|
|
||||||
if (enc_canon_search(p) >= 0)
|
if (enc_canon_search(p) >= 0)
|
||||||
{
|
{
|
||||||
// canonical name can be used unmodified
|
// canonical name can be used unmodified
|
||||||
if (p != r)
|
if (p != r)
|
||||||
STRMOVE(r, p);
|
STRMOVE(r, p);
|
||||||
}
|
}
|
||||||
else if ((i = enc_alias_search(p)) >= 0)
|
else if ((i = enc_alias_search(p)) >= 0)
|
||||||
{
|
{
|
||||||
// alias recognized, get canonical name
|
// alias recognized, get canonical name
|
||||||
vim_free(r);
|
vim_free(r);
|
||||||
r = vim_strsave((char_u *)enc_canon_table[i].name);
|
r = vim_strsave((char_u *)enc_canon_table[i].name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -5269,26 +5269,26 @@ convert_input_safe(
|
|||||||
|
|
||||||
d = string_convert_ext(&input_conv, ptr, &dlen,
|
d = string_convert_ext(&input_conv, ptr, &dlen,
|
||||||
restp == NULL ? NULL : &unconvertlen);
|
restp == NULL ? NULL : &unconvertlen);
|
||||||
if (d != NULL)
|
if (d == NULL)
|
||||||
|
return dlen;
|
||||||
|
|
||||||
|
if (dlen <= maxlen)
|
||||||
{
|
{
|
||||||
if (dlen <= maxlen)
|
if (unconvertlen > 0)
|
||||||
{
|
{
|
||||||
if (unconvertlen > 0)
|
// Move the unconverted characters to allocated memory.
|
||||||
{
|
*restp = alloc(unconvertlen);
|
||||||
// Move the unconverted characters to allocated memory.
|
if (*restp != NULL)
|
||||||
*restp = alloc(unconvertlen);
|
mch_memmove(*restp, ptr + len - unconvertlen, unconvertlen);
|
||||||
if (*restp != NULL)
|
*restlenp = unconvertlen;
|
||||||
mch_memmove(*restp, ptr + len - unconvertlen, unconvertlen);
|
|
||||||
*restlenp = unconvertlen;
|
|
||||||
}
|
|
||||||
mch_memmove(ptr, d, dlen);
|
|
||||||
}
|
}
|
||||||
else
|
mch_memmove(ptr, d, dlen);
|
||||||
// result is too long, keep the unconverted text (the caller must
|
|
||||||
// have done something wrong!)
|
|
||||||
dlen = len;
|
|
||||||
vim_free(d);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
// result is too long, keep the unconverted text (the caller must
|
||||||
|
// have done something wrong!)
|
||||||
|
dlen = len;
|
||||||
|
vim_free(d);
|
||||||
return dlen;
|
return dlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -879,16 +879,16 @@ mf_alloc_bhdr(memfile_T *mfp, int page_count)
|
|||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
|
|
||||||
if ((hp = ALLOC_ONE(bhdr_T)) != NULL)
|
if ((hp = ALLOC_ONE(bhdr_T)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ((hp->bh_data = alloc((size_t)mfp->mf_page_size * page_count))
|
||||||
|
== NULL)
|
||||||
{
|
{
|
||||||
if ((hp->bh_data = alloc((size_t)mfp->mf_page_size * page_count))
|
vim_free(hp); // not enough memory
|
||||||
== NULL)
|
return NULL;
|
||||||
{
|
|
||||||
vim_free(hp); // not enough memory
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
hp->bh_page_count = page_count;
|
|
||||||
}
|
}
|
||||||
|
hp->bh_page_count = page_count;
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,12 +1209,12 @@ mf_set_ffname(memfile_T *mfp)
|
|||||||
void
|
void
|
||||||
mf_fullname(memfile_T *mfp)
|
mf_fullname(memfile_T *mfp)
|
||||||
{
|
{
|
||||||
if (mfp != NULL && mfp->mf_fname != NULL && mfp->mf_ffname != NULL)
|
if (mfp == NULL || mfp->mf_fname == NULL || mfp->mf_ffname == NULL)
|
||||||
{
|
return;
|
||||||
vim_free(mfp->mf_fname);
|
|
||||||
mfp->mf_fname = mfp->mf_ffname;
|
vim_free(mfp->mf_fname);
|
||||||
mfp->mf_ffname = NULL;
|
mfp->mf_fname = mfp->mf_ffname;
|
||||||
}
|
mfp->mf_ffname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -422,21 +422,21 @@ error:
|
|||||||
static void
|
static void
|
||||||
ml_set_mfp_crypt(buf_T *buf)
|
ml_set_mfp_crypt(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (*buf->b_p_key != NUL)
|
if (*buf->b_p_key == NUL)
|
||||||
{
|
return;
|
||||||
int method_nr = crypt_get_method_nr(buf);
|
|
||||||
|
|
||||||
if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD)
|
int method_nr = crypt_get_method_nr(buf);
|
||||||
{
|
|
||||||
// Generate a seed and store it in the memfile.
|
if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD)
|
||||||
sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0);
|
{
|
||||||
}
|
// Generate a seed and store it in the memfile.
|
||||||
#ifdef FEAT_SODIUM
|
sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0);
|
||||||
else if (method_nr == CRYPT_M_SOD)
|
|
||||||
crypt_sodium_randombytes_buf(buf->b_ml.ml_mfp->mf_seed,
|
|
||||||
MF_SEED_LEN);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#ifdef FEAT_SODIUM
|
||||||
|
else if (method_nr == CRYPT_M_SOD)
|
||||||
|
crypt_sodium_randombytes_buf(buf->b_ml.ml_mfp->mf_seed,
|
||||||
|
MF_SEED_LEN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2090,22 +2090,22 @@ make_percent_swname(char_u *dir, char_u *name)
|
|||||||
char_u *d = NULL, *s, *f;
|
char_u *d = NULL, *s, *f;
|
||||||
|
|
||||||
f = fix_fname(name != NULL ? name : (char_u *)"");
|
f = fix_fname(name != NULL ? name : (char_u *)"");
|
||||||
if (f != NULL)
|
if (f == NULL)
|
||||||
{
|
return NULL;
|
||||||
s = alloc(STRLEN(f) + 1);
|
|
||||||
if (s != NULL)
|
|
||||||
{
|
|
||||||
STRCPY(s, f);
|
|
||||||
for (d = s; *d != NUL; MB_PTR_ADV(d))
|
|
||||||
if (vim_ispathsep(*d))
|
|
||||||
*d = '%';
|
|
||||||
|
|
||||||
dir[STRLEN(dir) - 1] = NUL; // remove one trailing slash
|
s = alloc(STRLEN(f) + 1);
|
||||||
d = concat_fnames(dir, s, TRUE);
|
if (s != NULL)
|
||||||
vim_free(s);
|
{
|
||||||
}
|
STRCPY(s, f);
|
||||||
vim_free(f);
|
for (d = s; *d != NUL; MB_PTR_ADV(d))
|
||||||
|
if (vim_ispathsep(*d))
|
||||||
|
*d = '%';
|
||||||
|
|
||||||
|
dir[STRLEN(dir) - 1] = NUL; // remove one trailing slash
|
||||||
|
d = concat_fnames(dir, s, TRUE);
|
||||||
|
vim_free(s);
|
||||||
}
|
}
|
||||||
|
vim_free(f);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5473,24 +5473,24 @@ ml_decrypt_data(
|
|||||||
int text_len;
|
int text_len;
|
||||||
cryptstate_T *state;
|
cryptstate_T *state;
|
||||||
|
|
||||||
if (dp->db_id == DATA_ID)
|
if (dp->db_id != DATA_ID)
|
||||||
{
|
return;
|
||||||
head_end = (char_u *)(&dp->db_index[dp->db_line_count]);
|
|
||||||
text_start = (char_u *)dp + dp->db_txt_start;
|
|
||||||
text_len = dp->db_txt_end - dp->db_txt_start;
|
|
||||||
|
|
||||||
if (head_end > text_start || dp->db_txt_start > size
|
head_end = (char_u *)(&dp->db_index[dp->db_line_count]);
|
||||||
|| dp->db_txt_end > size)
|
text_start = (char_u *)dp + dp->db_txt_start;
|
||||||
return; // data was messed up
|
text_len = dp->db_txt_end - dp->db_txt_start;
|
||||||
|
|
||||||
state = ml_crypt_prepare(mfp, offset, TRUE);
|
if (head_end > text_start || dp->db_txt_start > size
|
||||||
if (state != NULL)
|
|| dp->db_txt_end > size)
|
||||||
{
|
return; // data was messed up
|
||||||
// Decrypt the text in place.
|
|
||||||
crypt_decode_inplace(state, text_start, text_len, FALSE);
|
state = ml_crypt_prepare(mfp, offset, TRUE);
|
||||||
crypt_free_state(state);
|
if (state == NULL)
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
|
// Decrypt the text in place.
|
||||||
|
crypt_decode_inplace(state, text_start, text_len, FALSE);
|
||||||
|
crypt_free_state(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
106
src/menu.c
106
src/menu.c
@@ -1763,12 +1763,12 @@ popup_mode_name(char_u *name, int idx)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
p = vim_strnsave(name, len + mode_chars_len);
|
p = vim_strnsave(name, len + mode_chars_len);
|
||||||
if (p != NULL)
|
if (p == NULL)
|
||||||
{
|
return NULL;
|
||||||
mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4));
|
|
||||||
for (i = 0; i < mode_chars_len; ++i)
|
mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4));
|
||||||
p[5 + i] = menu_mode_chars[idx][i];
|
for (i = 0; i < mode_chars_len; ++i)
|
||||||
}
|
p[5 + i] = menu_mode_chars[idx][i];
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2008,24 +2008,24 @@ show_popupmenu(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Only show a popup when it is defined and has entries
|
// Only show a popup when it is defined and has entries
|
||||||
if (menu != NULL && menu->children != NULL)
|
if (menu == NULL || menu->children == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
# if defined(FEAT_GUI)
|
# if defined(FEAT_GUI)
|
||||||
if (gui.in_use)
|
if (gui.in_use)
|
||||||
{
|
{
|
||||||
// Update the menus now, in case the MenuPopup autocommand did
|
// Update the menus now, in case the MenuPopup autocommand did
|
||||||
// anything.
|
// anything.
|
||||||
gui_update_menus(0);
|
gui_update_menus(0);
|
||||||
gui_mch_show_popupmenu(menu);
|
gui_mch_show_popupmenu(menu);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
|
# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
# if defined(FEAT_TERM_POPUP_MENU)
|
# if defined(FEAT_TERM_POPUP_MENU)
|
||||||
pum_show_popupmenu(menu);
|
pum_show_popupmenu(menu);
|
||||||
# endif
|
# endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2255,39 +2255,39 @@ gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx)
|
|||||||
vimmenu_T menuarg;
|
vimmenu_T menuarg;
|
||||||
|
|
||||||
tbuf = alloc(5 + (unsigned int)STRLEN(tearpath));
|
tbuf = alloc(5 + (unsigned int)STRLEN(tearpath));
|
||||||
if (tbuf != NULL)
|
if (tbuf == NULL)
|
||||||
{
|
return;
|
||||||
tbuf[0] = K_SPECIAL;
|
|
||||||
tbuf[1] = K_SECOND(K_TEAROFF);
|
|
||||||
tbuf[2] = K_THIRD(K_TEAROFF);
|
|
||||||
STRCPY(tbuf + 3, tearpath);
|
|
||||||
STRCAT(tbuf + 3, "\r");
|
|
||||||
|
|
||||||
STRCAT(tearpath, ".");
|
tbuf[0] = K_SPECIAL;
|
||||||
STRCAT(tearpath, TEAR_STRING);
|
tbuf[1] = K_SECOND(K_TEAROFF);
|
||||||
|
tbuf[2] = K_THIRD(K_TEAROFF);
|
||||||
|
STRCPY(tbuf + 3, tearpath);
|
||||||
|
STRCAT(tbuf + 3, "\r");
|
||||||
|
|
||||||
// Priority of tear-off is always 1
|
STRCAT(tearpath, ".");
|
||||||
t = pri_tab[pri_idx + 1];
|
STRCAT(tearpath, TEAR_STRING);
|
||||||
pri_tab[pri_idx + 1] = 1;
|
|
||||||
|
// Priority of tear-off is always 1
|
||||||
|
t = pri_tab[pri_idx + 1];
|
||||||
|
pri_tab[pri_idx + 1] = 1;
|
||||||
|
|
||||||
#ifdef FEAT_TOOLBAR
|
#ifdef FEAT_TOOLBAR
|
||||||
menuarg.iconfile = NULL;
|
menuarg.iconfile = NULL;
|
||||||
menuarg.iconidx = -1;
|
menuarg.iconidx = -1;
|
||||||
menuarg.icon_builtin = FALSE;
|
menuarg.icon_builtin = FALSE;
|
||||||
#endif
|
#endif
|
||||||
menuarg.noremap[0] = REMAP_NONE;
|
menuarg.noremap[0] = REMAP_NONE;
|
||||||
menuarg.silent[0] = TRUE;
|
menuarg.silent[0] = TRUE;
|
||||||
|
|
||||||
menuarg.modes = MENU_ALL_MODES;
|
menuarg.modes = MENU_ALL_MODES;
|
||||||
add_menu_path(tearpath, &menuarg, pri_tab, tbuf, FALSE);
|
add_menu_path(tearpath, &menuarg, pri_tab, tbuf, FALSE);
|
||||||
|
|
||||||
menuarg.modes = MENU_TIP_MODE;
|
menuarg.modes = MENU_TIP_MODE;
|
||||||
add_menu_path(tearpath, &menuarg, pri_tab,
|
add_menu_path(tearpath, &menuarg, pri_tab,
|
||||||
(char_u *)_("Tear off this menu"), FALSE);
|
(char_u *)_("Tear off this menu"), FALSE);
|
||||||
|
|
||||||
pri_tab[pri_idx + 1] = t;
|
pri_tab[pri_idx + 1] = t;
|
||||||
vim_free(tbuf);
|
vim_free(tbuf);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2789,16 +2789,16 @@ menutrans_lookup(char_u *name, int len)
|
|||||||
name[len] = NUL;
|
name[len] = NUL;
|
||||||
dname = menu_text(name, NULL, NULL);
|
dname = menu_text(name, NULL, NULL);
|
||||||
name[len] = i;
|
name[len] = i;
|
||||||
if (dname != NULL)
|
if (dname == NULL)
|
||||||
{
|
return NULL;
|
||||||
for (i = 0; i < menutrans_ga.ga_len; ++i)
|
|
||||||
if (STRICMP(dname, tp[i].from_noamp) == 0)
|
for (i = 0; i < menutrans_ga.ga_len; ++i)
|
||||||
{
|
if (STRICMP(dname, tp[i].from_noamp) == 0)
|
||||||
vim_free(dname);
|
{
|
||||||
return tp[i].to;
|
vim_free(dname);
|
||||||
}
|
return tp[i].to;
|
||||||
vim_free(dname);
|
}
|
||||||
}
|
vim_free(dname);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
140
src/message.c
140
src/message.c
@@ -375,15 +375,13 @@ smsg(const char *s, ...)
|
|||||||
// give the raw message so the user at least gets a hint.
|
// give the raw message so the user at least gets a hint.
|
||||||
return msg((char *)s);
|
return msg((char *)s);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
|
|
||||||
va_start(arglist, s);
|
va_list arglist;
|
||||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
|
||||||
va_end(arglist);
|
va_start(arglist, s);
|
||||||
return msg((char *)IObuff);
|
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
||||||
}
|
va_end(arglist);
|
||||||
|
return msg((char *)IObuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -395,15 +393,13 @@ smsg_attr(int attr, const char *s, ...)
|
|||||||
// give the raw message so the user at least gets a hint.
|
// give the raw message so the user at least gets a hint.
|
||||||
return msg_attr((char *)s, attr);
|
return msg_attr((char *)s, attr);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
|
|
||||||
va_start(arglist, s);
|
va_list arglist;
|
||||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
|
||||||
va_end(arglist);
|
va_start(arglist, s);
|
||||||
return msg_attr((char *)IObuff, attr);
|
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
||||||
}
|
va_end(arglist);
|
||||||
|
return msg_attr((char *)IObuff, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -415,15 +411,13 @@ smsg_attr_keep(int attr, const char *s, ...)
|
|||||||
// give the raw message so the user at least gets a hint.
|
// give the raw message so the user at least gets a hint.
|
||||||
return msg_attr_keep((char *)s, attr, TRUE);
|
return msg_attr_keep((char *)s, attr, TRUE);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
|
|
||||||
va_start(arglist, s);
|
va_list arglist;
|
||||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
|
||||||
va_end(arglist);
|
va_start(arglist, s);
|
||||||
return msg_attr_keep((char *)IObuff, attr, TRUE);
|
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
|
||||||
}
|
va_end(arglist);
|
||||||
|
return msg_attr_keep((char *)IObuff, attr, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -834,16 +828,16 @@ semsg(const char *s, ...)
|
|||||||
void
|
void
|
||||||
iemsg(char *s)
|
iemsg(char *s)
|
||||||
{
|
{
|
||||||
if (!emsg_not_now())
|
if (emsg_not_now())
|
||||||
{
|
return;
|
||||||
emsg_core((char_u *)s);
|
|
||||||
|
emsg_core((char_u *)s);
|
||||||
#if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL)
|
#if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL)
|
||||||
set_vim_var_string(VV_ERRMSG, (char_u *)s, -1);
|
set_vim_var_string(VV_ERRMSG, (char_u *)s, -1);
|
||||||
msg_putchar('\n'); // avoid overwriting the error message
|
msg_putchar('\n'); // avoid overwriting the error message
|
||||||
out_flush();
|
out_flush();
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PROTO // manual proto with __attribute__
|
#ifndef PROTO // manual proto with __attribute__
|
||||||
@@ -856,29 +850,29 @@ iemsg(char *s)
|
|||||||
void
|
void
|
||||||
siemsg(const char *s, ...)
|
siemsg(const char *s, ...)
|
||||||
{
|
{
|
||||||
if (!emsg_not_now())
|
if (emsg_not_now())
|
||||||
{
|
return;
|
||||||
if (IObuff == NULL)
|
|
||||||
{
|
|
||||||
// Very early in initialisation and already something wrong, just
|
|
||||||
// give the raw message so the user at least gets a hint.
|
|
||||||
emsg_core((char_u *)s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, s);
|
if (IObuff == NULL)
|
||||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
|
{
|
||||||
va_end(ap);
|
// Very early in initialisation and already something wrong, just
|
||||||
emsg_core(IObuff);
|
// give the raw message so the user at least gets a hint.
|
||||||
}
|
emsg_core((char_u *)s);
|
||||||
# ifdef ABORT_ON_INTERNAL_ERROR
|
|
||||||
msg_putchar('\n'); // avoid overwriting the error message
|
|
||||||
out_flush();
|
|
||||||
abort();
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, s);
|
||||||
|
vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
|
||||||
|
va_end(ap);
|
||||||
|
emsg_core(IObuff);
|
||||||
|
}
|
||||||
|
# ifdef ABORT_ON_INTERNAL_ERROR
|
||||||
|
msg_putchar('\n'); // avoid overwriting the error message
|
||||||
|
out_flush();
|
||||||
|
abort();
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1006,28 +1000,28 @@ add_msg_hist(
|
|||||||
|
|
||||||
// allocate an entry and add the message at the end of the history
|
// allocate an entry and add the message at the end of the history
|
||||||
p = ALLOC_ONE(struct msg_hist);
|
p = ALLOC_ONE(struct msg_hist);
|
||||||
if (p != NULL)
|
if (p == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
len = (int)STRLEN(s);
|
||||||
|
// remove leading and trailing newlines
|
||||||
|
while (len > 0 && *s == '\n')
|
||||||
{
|
{
|
||||||
if (len < 0)
|
++s;
|
||||||
len = (int)STRLEN(s);
|
--len;
|
||||||
// remove leading and trailing newlines
|
|
||||||
while (len > 0 && *s == '\n')
|
|
||||||
{
|
|
||||||
++s;
|
|
||||||
--len;
|
|
||||||
}
|
|
||||||
while (len > 0 && s[len - 1] == '\n')
|
|
||||||
--len;
|
|
||||||
p->msg = vim_strnsave(s, len);
|
|
||||||
p->next = NULL;
|
|
||||||
p->attr = attr;
|
|
||||||
if (last_msg_hist != NULL)
|
|
||||||
last_msg_hist->next = p;
|
|
||||||
last_msg_hist = p;
|
|
||||||
if (first_msg_hist == NULL)
|
|
||||||
first_msg_hist = last_msg_hist;
|
|
||||||
++msg_hist_len;
|
|
||||||
}
|
}
|
||||||
|
while (len > 0 && s[len - 1] == '\n')
|
||||||
|
--len;
|
||||||
|
p->msg = vim_strnsave(s, len);
|
||||||
|
p->next = NULL;
|
||||||
|
p->attr = attr;
|
||||||
|
if (last_msg_hist != NULL)
|
||||||
|
last_msg_hist->next = p;
|
||||||
|
last_msg_hist = p;
|
||||||
|
if (first_msg_hist == NULL)
|
||||||
|
first_msg_hist = last_msg_hist;
|
||||||
|
++msg_hist_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
80
src/misc1.c
80
src/misc1.c
@@ -1119,59 +1119,59 @@ vim_beep(unsigned val)
|
|||||||
called_vim_beep = TRUE;
|
called_vim_beep = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (emsg_silent == 0 && !in_assert_fails)
|
if (emsg_silent != 0 || in_assert_fails)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
|
||||||
{
|
{
|
||||||
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
|
|
||||||
{
|
|
||||||
#ifdef ELAPSED_FUNC
|
#ifdef ELAPSED_FUNC
|
||||||
static int did_init = FALSE;
|
static int did_init = FALSE;
|
||||||
static elapsed_T start_tv;
|
static elapsed_T start_tv;
|
||||||
|
|
||||||
// Only beep once per half a second, otherwise a sequence of beeps
|
// Only beep once per half a second, otherwise a sequence of beeps
|
||||||
// would freeze Vim.
|
// would freeze Vim.
|
||||||
if (!did_init || ELAPSED_FUNC(start_tv) > 500)
|
if (!did_init || ELAPSED_FUNC(start_tv) > 500)
|
||||||
{
|
{
|
||||||
did_init = TRUE;
|
did_init = TRUE;
|
||||||
ELAPSED_INIT(start_tv);
|
ELAPSED_INIT(start_tv);
|
||||||
#endif
|
#endif
|
||||||
if (p_vb
|
if (p_vb
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
// While the GUI is starting up the termcap is set for
|
// While the GUI is starting up the termcap is set for
|
||||||
// the GUI but the output still goes to a terminal.
|
// the GUI but the output still goes to a terminal.
|
||||||
&& !(gui.in_use && gui.starting)
|
&& !(gui.in_use && gui.starting)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
out_str_cf(T_VB);
|
out_str_cf(T_VB);
|
||||||
#ifdef FEAT_VTP
|
#ifdef FEAT_VTP
|
||||||
// No restore color information, refresh the screen.
|
// No restore color information, refresh the screen.
|
||||||
if (has_vtp_working() != 0
|
if (has_vtp_working() != 0
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
# ifdef FEAT_TERMGUICOLORS
|
||||||
&& (p_tgc || (!p_tgc && t_colors >= 256))
|
&& (p_tgc || (!p_tgc && t_colors >= 256))
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
redraw_later(UPD_CLEAR);
|
redraw_later(UPD_CLEAR);
|
||||||
update_screen(0);
|
update_screen(0);
|
||||||
redrawcmd();
|
redrawcmd();
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
out_char(BELL);
|
|
||||||
#ifdef ELAPSED_FUNC
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out_char(BELL);
|
||||||
|
#ifdef ELAPSED_FUNC
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// When 'debug' contains "beep" produce a message. If we are sourcing
|
// When 'debug' contains "beep" produce a message. If we are sourcing
|
||||||
// a script or executing a function give the user a hint where the beep
|
// a script or executing a function give the user a hint where the beep
|
||||||
// comes from.
|
// comes from.
|
||||||
if (vim_strchr(p_debug, 'e') != NULL)
|
if (vim_strchr(p_debug, 'e') != NULL)
|
||||||
{
|
{
|
||||||
msg_source(HL_ATTR(HLF_W));
|
msg_source(HL_ATTR(HLF_W));
|
||||||
msg_attr(_("Beep!"), HL_ATTR(HLF_W));
|
msg_attr(_("Beep!"), HL_ATTR(HLF_W));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
80
src/misc2.c
80
src/misc2.c
@@ -1130,25 +1130,27 @@ simplify_key(int key, int *modifiers)
|
|||||||
int key0;
|
int key0;
|
||||||
int key1;
|
int key1;
|
||||||
|
|
||||||
if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT))
|
if (!(*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)))
|
||||||
|
return key;
|
||||||
|
|
||||||
|
// TAB is a special case
|
||||||
|
if (key == TAB && (*modifiers & MOD_MASK_SHIFT))
|
||||||
{
|
{
|
||||||
// TAB is a special case
|
*modifiers &= ~MOD_MASK_SHIFT;
|
||||||
if (key == TAB && (*modifiers & MOD_MASK_SHIFT))
|
return K_S_TAB;
|
||||||
|
}
|
||||||
|
key0 = KEY2TERMCAP0(key);
|
||||||
|
key1 = KEY2TERMCAP1(key);
|
||||||
|
for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE)
|
||||||
|
{
|
||||||
|
if (key0 == modifier_keys_table[i + 3]
|
||||||
|
&& key1 == modifier_keys_table[i + 4]
|
||||||
|
&& (*modifiers & modifier_keys_table[i]))
|
||||||
{
|
{
|
||||||
*modifiers &= ~MOD_MASK_SHIFT;
|
*modifiers &= ~modifier_keys_table[i];
|
||||||
return K_S_TAB;
|
return TERMCAP2KEY(modifier_keys_table[i + 1],
|
||||||
|
modifier_keys_table[i + 2]);
|
||||||
}
|
}
|
||||||
key0 = KEY2TERMCAP0(key);
|
|
||||||
key1 = KEY2TERMCAP1(key);
|
|
||||||
for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE)
|
|
||||||
if (key0 == modifier_keys_table[i + 3]
|
|
||||||
&& key1 == modifier_keys_table[i + 4]
|
|
||||||
&& (*modifiers & modifier_keys_table[i]))
|
|
||||||
{
|
|
||||||
*modifiers &= ~modifier_keys_table[i];
|
|
||||||
return TERMCAP2KEY(modifier_keys_table[i + 1],
|
|
||||||
modifier_keys_table[i + 2]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -1537,22 +1539,22 @@ find_special_key(
|
|||||||
int
|
int
|
||||||
may_adjust_key_for_ctrl(int modifiers, int key)
|
may_adjust_key_for_ctrl(int modifiers, int key)
|
||||||
{
|
{
|
||||||
if (modifiers & MOD_MASK_CTRL)
|
if (!(modifiers & MOD_MASK_CTRL))
|
||||||
|
return key;
|
||||||
|
|
||||||
|
if (ASCII_ISALPHA(key))
|
||||||
{
|
{
|
||||||
if (ASCII_ISALPHA(key))
|
|
||||||
{
|
|
||||||
#ifdef FEAT_TERMINAL
|
#ifdef FEAT_TERMINAL
|
||||||
check_no_reduce_keys(); // may update the no_reduce_keys flag
|
check_no_reduce_keys(); // may update the no_reduce_keys flag
|
||||||
#endif
|
#endif
|
||||||
return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key;
|
return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key;
|
||||||
}
|
|
||||||
if (key == '2')
|
|
||||||
return '@';
|
|
||||||
if (key == '6')
|
|
||||||
return '^';
|
|
||||||
if (key == '-')
|
|
||||||
return '_';
|
|
||||||
}
|
}
|
||||||
|
if (key == '2')
|
||||||
|
return '@';
|
||||||
|
if (key == '6')
|
||||||
|
return '^';
|
||||||
|
if (key == '-')
|
||||||
|
return '_';
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2820,21 +2822,21 @@ read_string(FILE *fd, int cnt)
|
|||||||
|
|
||||||
// allocate memory
|
// allocate memory
|
||||||
str = alloc(cnt + 1);
|
str = alloc(cnt + 1);
|
||||||
if (str != NULL)
|
if (str == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Read the string. Quit when running into the EOF.
|
||||||
|
for (i = 0; i < cnt; ++i)
|
||||||
{
|
{
|
||||||
// Read the string. Quit when running into the EOF.
|
c = getc(fd);
|
||||||
for (i = 0; i < cnt; ++i)
|
if (c == EOF)
|
||||||
{
|
{
|
||||||
c = getc(fd);
|
vim_free(str);
|
||||||
if (c == EOF)
|
return NULL;
|
||||||
{
|
|
||||||
vim_free(str);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
str[i] = c;
|
|
||||||
}
|
}
|
||||||
str[i] = NUL;
|
str[i] = c;
|
||||||
}
|
}
|
||||||
|
str[i] = NUL;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
119
src/move.c
119
src/move.c
@@ -244,15 +244,15 @@ skipcol_from_plines(win_T *wp, int plines_off)
|
|||||||
static void
|
static void
|
||||||
reset_skipcol(void)
|
reset_skipcol(void)
|
||||||
{
|
{
|
||||||
if (curwin->w_skipcol != 0)
|
if (curwin->w_skipcol == 0)
|
||||||
{
|
return;
|
||||||
curwin->w_skipcol = 0;
|
|
||||||
|
|
||||||
// Should use the least expensive way that displays all that changed.
|
curwin->w_skipcol = 0;
|
||||||
// UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw
|
|
||||||
// enough when the top line gets another screen line.
|
// Should use the least expensive way that displays all that changed.
|
||||||
redraw_later(UPD_SOME_VALID);
|
// UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw
|
||||||
}
|
// enough when the top line gets another screen line.
|
||||||
|
redraw_later(UPD_SOME_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -980,17 +980,18 @@ validate_virtcol(void)
|
|||||||
validate_virtcol_win(win_T *wp)
|
validate_virtcol_win(win_T *wp)
|
||||||
{
|
{
|
||||||
check_cursor_moved(wp);
|
check_cursor_moved(wp);
|
||||||
if (!(wp->w_valid & VALID_VIRTCOL))
|
|
||||||
{
|
if (wp->w_valid & VALID_VIRTCOL)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef FEAT_PROP_POPUP
|
#ifdef FEAT_PROP_POPUP
|
||||||
wp->w_virtcol_first_char = 0;
|
wp->w_virtcol_first_char = 0;
|
||||||
#endif
|
#endif
|
||||||
getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL);
|
getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL);
|
||||||
#ifdef FEAT_SYN_HL
|
#ifdef FEAT_SYN_HL
|
||||||
redraw_for_cursorcolumn(wp);
|
redraw_for_cursorcolumn(wp);
|
||||||
#endif
|
#endif
|
||||||
wp->w_valid |= VALID_VIRTCOL;
|
wp->w_valid |= VALID_VIRTCOL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1000,20 +1001,21 @@ validate_virtcol_win(win_T *wp)
|
|||||||
validate_cheight(void)
|
validate_cheight(void)
|
||||||
{
|
{
|
||||||
check_cursor_moved(curwin);
|
check_cursor_moved(curwin);
|
||||||
if (!(curwin->w_valid & VALID_CHEIGHT))
|
|
||||||
{
|
if (curwin->w_valid & VALID_CHEIGHT)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline)
|
if (curwin->w_cursor.lnum == curwin->w_topline)
|
||||||
curwin->w_cline_height = plines_nofill(curwin->w_cursor.lnum)
|
curwin->w_cline_height = plines_nofill(curwin->w_cursor.lnum)
|
||||||
+ curwin->w_topfill;
|
+ curwin->w_topfill;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
curwin->w_cline_height = plines(curwin->w_cursor.lnum);
|
curwin->w_cline_height = plines(curwin->w_cursor.lnum);
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
curwin->w_cline_folded = hasFolding(curwin->w_cursor.lnum, NULL, NULL);
|
curwin->w_cline_folded = hasFolding(curwin->w_cursor.lnum, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
curwin->w_valid |= VALID_CHEIGHT;
|
curwin->w_valid |= VALID_CHEIGHT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1027,30 +1029,31 @@ validate_cursor_col(void)
|
|||||||
int width;
|
int width;
|
||||||
|
|
||||||
validate_virtcol();
|
validate_virtcol();
|
||||||
if (!(curwin->w_valid & VALID_WCOL))
|
|
||||||
{
|
|
||||||
col = curwin->w_virtcol;
|
|
||||||
off = curwin_col_off();
|
|
||||||
col += off;
|
|
||||||
width = curwin->w_width - off + curwin_col_off2();
|
|
||||||
|
|
||||||
// long line wrapping, adjust curwin->w_wrow
|
if (curwin->w_valid & VALID_WCOL)
|
||||||
if (curwin->w_p_wrap
|
return;
|
||||||
&& col >= (colnr_T)curwin->w_width
|
|
||||||
&& width > 0)
|
|
||||||
// use same formula as what is used in curs_columns()
|
|
||||||
col -= ((col - curwin->w_width) / width + 1) * width;
|
|
||||||
if (col > (int)curwin->w_leftcol)
|
|
||||||
col -= curwin->w_leftcol;
|
|
||||||
else
|
|
||||||
col = 0;
|
|
||||||
curwin->w_wcol = col;
|
|
||||||
|
|
||||||
curwin->w_valid |= VALID_WCOL;
|
col = curwin->w_virtcol;
|
||||||
|
off = curwin_col_off();
|
||||||
|
col += off;
|
||||||
|
width = curwin->w_width - off + curwin_col_off2();
|
||||||
|
|
||||||
|
// long line wrapping, adjust curwin->w_wrow
|
||||||
|
if (curwin->w_p_wrap
|
||||||
|
&& col >= (colnr_T)curwin->w_width
|
||||||
|
&& width > 0)
|
||||||
|
// use same formula as what is used in curs_columns()
|
||||||
|
col -= ((col - curwin->w_width) / width + 1) * width;
|
||||||
|
if (col > (int)curwin->w_leftcol)
|
||||||
|
col -= curwin->w_leftcol;
|
||||||
|
else
|
||||||
|
col = 0;
|
||||||
|
curwin->w_wcol = col;
|
||||||
|
|
||||||
|
curwin->w_valid |= VALID_WCOL;
|
||||||
#ifdef FEAT_PROP_POPUP
|
#ifdef FEAT_PROP_POPUP
|
||||||
curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
|
curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1999,22 +2002,22 @@ check_topfill(
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (wp->w_topfill > 0)
|
if (wp->w_topfill <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
n = plines_win_nofill(wp, wp->w_topline, TRUE);
|
||||||
|
if (wp->w_topfill + n > wp->w_height)
|
||||||
{
|
{
|
||||||
n = plines_win_nofill(wp, wp->w_topline, TRUE);
|
if (down && wp->w_topline > 1)
|
||||||
if (wp->w_topfill + n > wp->w_height)
|
|
||||||
{
|
{
|
||||||
if (down && wp->w_topline > 1)
|
--wp->w_topline;
|
||||||
{
|
wp->w_topfill = 0;
|
||||||
--wp->w_topline;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wp->w_topfill = wp->w_height - n;
|
||||||
|
if (wp->w_topfill < 0)
|
||||||
wp->w_topfill = 0;
|
wp->w_topfill = 0;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wp->w_topfill = wp->w_height - n;
|
|
||||||
if (wp->w_topfill < 0)
|
|
||||||
wp->w_topfill = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1196,
|
||||||
/**/
|
/**/
|
||||||
1195,
|
1195,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user