1
0
forked from aniani/vim

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:
Yegappan Lakshmanan
2023-01-14 12:32:28 +00:00
committed by Bram Moolenaar
parent 378e6c03f9
commit e857598896
16 changed files with 678 additions and 676 deletions

View File

@@ -793,12 +793,12 @@ 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_contents(job);
job_free_job(job); job_free_job(job);
} }
}
static job_T *jobs_to_free = NULL; static job_T *jobs_to_free = NULL;
@@ -1087,12 +1087,14 @@ 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 // Do not free the job if there is a channel where the close callback
// may get the job info. // may get the job info.
if (!job_channel_still_useful(job)) if (job_channel_still_useful(job))
{ return;
// Do not free the job when it has not ended yet and there is a // Do not free the job when it has not ended yet and there is a
// "stoponexit" flag or an exit callback. // "stoponexit" flag or an exit callback.
if (!job_need_end_check(job)) if (!job_need_end_check(job))
@@ -1109,8 +1111,6 @@ job_unref(job_T *job)
job->jv_channel = NULL; job->jv_channel = NULL;
} }
} }
}
}
int int
free_unused_jobs_contents(int copyID, int mask) free_unused_jobs_contents(int copyID, int mask)
@@ -1157,8 +1157,9 @@ 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_refcount = 1;
job->jv_stoponexit = vim_strsave((char_u *)"term"); job->jv_stoponexit = vim_strsave((char_u *)"term");
@@ -1168,7 +1169,6 @@ job_alloc(void)
job->jv_next = first_job; job->jv_next = first_job;
} }
first_job = job; first_job = job;
}
return job; return job;
} }
@@ -1803,14 +1803,14 @@ 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->v_type = VAR_CHANNEL;
rettv->vval.v_channel = job->jv_channel; rettv->vval.v_channel = job->jv_channel;
if (job->jv_channel != NULL) if (job->jv_channel != NULL)
++job->jv_channel->ch_refcount; ++job->jv_channel->ch_refcount;
} }
}
/* /*
* Implementation of job_info(). * Implementation of job_info().
@@ -1855,14 +1855,14 @@ 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); dict_add_list(dict, "cmd", l);
if (job->jv_argv != NULL) if (job->jv_argv != NULL)
for (i = 0; job->jv_argv[i] != NULL; i++) for (i = 0; job->jv_argv[i] != NULL; i++)
list_append_string(l, (char_u *)job->jv_argv[i], -1); list_append_string(l, (char_u *)job->jv_argv[i], -1);
} }
}
/* /*
* Implementation of job_info() to return info for all jobs. * Implementation of job_info() to return info for all jobs.

View File

@@ -124,8 +124,9 @@ 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); listitem_T *li = (listitem_T *)(l + 1);
int i; int i;
@@ -145,7 +146,6 @@ list_alloc_with_items(int count)
li->li_next = li + 1; li->li_next = li + 1;
++li; ++li;
} }
}
return l; return l;
} }
@@ -297,12 +297,12 @@ 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_contents(l);
list_free_list(l); list_free_list(l);
} }
}
/* /*
* Allocate a list item. * Allocate a list item.
@@ -540,14 +540,14 @@ 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; *idx = 0;
li = list_find(l, *idx); li = list_find(l, *idx);
} }
}
return li; return li;
} }
@@ -772,8 +772,9 @@ 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) if (li != NULL)
{ return li;
// Vim9: Allow for adding an item at the end. // Vim9: Allow for adding an item at the end.
if (can_append && in_vim9script() if (can_append && in_vim9script()
&& *n1 == l->lv_len && l->lv_lock == 0) && *n1 == l->lv_len && l->lv_lock == 0)
@@ -787,7 +788,6 @@ check_range_index_one(list_T *l, long *n1, int can_append, int quiet)
semsg(_(e_list_index_out_of_range_nr), orig_n1); semsg(_(e_list_index_out_of_range_nr), orig_n1);
return NULL; return NULL;
} }
}
return li; return li;
} }
@@ -1286,8 +1286,9 @@ 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) if (orig->lv_type == NULL || top || deep)
copy->lv_type = NULL; copy->lv_type = NULL;
else else
@@ -1325,7 +1326,6 @@ list_copy(list_T *orig, int deep, int top, int copyID)
list_unref(copy); list_unref(copy);
copy = NULL; copy = NULL;
} }
}
return copy; return copy;
} }
@@ -1491,9 +1491,10 @@ 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; p = (join_T *)join_ga.ga_data;
for (i = 0; i < join_ga.ga_len; ++i) for (i = 0; i < join_ga.ga_len; ++i)
{ {
@@ -1501,7 +1502,6 @@ list_join(
++p; ++p;
} }
ga_clear(&join_ga); ga_clear(&join_ga);
}
return retval; return retval;
} }
@@ -2560,8 +2560,9 @@ 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_val;
typval_T save_key; typval_T save_key;
@@ -2590,7 +2591,6 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
did_emsg |= save_did_emsg; did_emsg |= save_did_emsg;
} }
}
/* /*
* "filter()" function * "filter()" function

View File

@@ -151,11 +151,13 @@ 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"); p = mch_getenv((char_u *)"LC_MESSAGES");
if (p == NULL || *p == NUL) if (p != NULL && *p != NUL)
{ return p;
p = mch_getenv((char_u *)"LANG"); p = mch_getenv((char_u *)"LANG");
if (p != NULL && VIM_ISDIGIT(*p)) if (p != NULL && VIM_ISDIGIT(*p))
p = NULL; // ignore something like "1043" p = NULL; // ignore something like "1043"
@@ -163,8 +165,6 @@ get_mess_env(void)
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,25 +504,26 @@ 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; did_init_locales = TRUE;
locales = find_locales(); locales = find_locales();
} }
}
# if defined(EXITFREE) || defined(PROTO) # if defined(EXITFREE) || defined(PROTO)
void void
free_locales(void) free_locales(void)
{ {
int i; int i;
if (locales != NULL)
{ if (locales == NULL)
return;
for (i = 0; locales[i] != NULL; i++) for (i = 0; locales[i] != NULL; i++)
vim_free(locales[i]); vim_free(locales[i]);
VIM_CLEAR(locales); VIM_CLEAR(locales);
} }
}
# endif # endif
/* /*

View File

@@ -3099,8 +3099,9 @@ 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.. curwin->w_cursor.lnum = 0; // just in case..
estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0); estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
ESTACK_CHECK_SETUP ESTACK_CHECK_SETUP
@@ -3116,7 +3117,6 @@ exe_pre_commands(mparm_T *parmp)
# endif # endif
TIME_MSG("--cmd commands"); TIME_MSG("--cmd commands");
} }
}
/* /*
* Execute "+", "-c" and "-S" arguments. * Execute "+", "-c" and "-S" arguments.
@@ -3369,8 +3369,9 @@ 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) if (is_viminit)
vimrc_found(NULL, NULL); vimrc_found(NULL, NULL);
estack_push(ETYPE_ENV, env, 0); estack_push(ETYPE_ENV, env, 0);
@@ -3390,8 +3391,6 @@ process_env(
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)
/* /*

View File

@@ -67,12 +67,12 @@ is_maphash_valid(void)
static void static void
validate_maphash(void) validate_maphash(void)
{ {
if (!maphash_valid) if (maphash_valid)
{ return;
CLEAR_FIELD(maphash); CLEAR_FIELD(maphash);
maphash_valid = TRUE; maphash_valid = TRUE;
} }
}
/* /*
* Delete one entry from the abbrlist or maphash[]. * Delete one entry from the abbrlist or maphash[].
@@ -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,8 +1843,9 @@ 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; d = res;
for (s = p; *s != NUL; ) for (s = p; *s != NUL; )
{ {
@@ -1868,7 +1869,7 @@ vim_strsave_escape_csi(char_u *p)
} }
} }
*d = NUL; *d = NUL;
}
return res; return res;
} }

View File

@@ -485,8 +485,9 @@ 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. * First expand "~/" in the file name to the home directory.
* Don't expand the whole name, it may contain other '~' chars. * Don't expand the whole name, it may contain other '~' chars.
@@ -513,7 +514,6 @@ fname2fnum(xfmark_T *fm)
// buflist_new() will call fmarks_check_names() // buflist_new() will call fmarks_check_names()
(void)buflist_new(NameBuff, p, (linenr_T)1, 0); (void)buflist_new(NameBuff, p, (linenr_T)1, 0);
} }
}
/* /*
* Check all file marks for a name that matches the file name in buf. * Check all file marks for a name that matches the file name in buf.

View File

@@ -978,15 +978,15 @@ 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); *win = find_win_by_nr_or_id(&di->di_tv);
if (*win == NULL) if (*win == NULL)
{ {
emsg(_(e_invalid_window_number)); emsg(_(e_invalid_window_number));
return FAIL; return FAIL;
} }
}
return OK; return OK;
} }
@@ -1330,8 +1330,9 @@ 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;
@@ -1356,7 +1357,6 @@ f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
} }
# endif # endif
} }
}
/* /*
* "matchdelete()" function * "matchdelete()" function

View File

@@ -809,8 +809,9 @@ 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; char_u *p = s;
while ((p = vim_strbyte(p, 0xef)) != NULL) while ((p = vim_strbyte(p, 0xef)) != NULL)
@@ -821,7 +822,6 @@ remove_bom(char_u *s)
++p; ++p;
} }
} }
}
#endif #endif
/* /*
@@ -4590,8 +4590,9 @@ 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 '-'. // Make it all lower case and replace '_' with '-'.
p = r; p = r;
for (s = enc; *s != NUL; ++s) for (s = enc; *s != NUL; ++s)
@@ -4640,7 +4641,6 @@ enc_canonize(char_u *enc)
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,8 +5269,9 @@ 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)
@@ -5288,7 +5289,6 @@ convert_input_safe(
// have done something wrong!) // have done something wrong!)
dlen = len; dlen = len;
vim_free(d); vim_free(d);
}
return dlen; return dlen;
} }

View File

@@ -879,8 +879,9 @@ 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)) if ((hp->bh_data = alloc((size_t)mfp->mf_page_size * page_count))
== NULL) == NULL)
{ {
@@ -888,7 +889,6 @@ mf_alloc_bhdr(memfile_T *mfp, int page_count)
return NULL; return NULL;
} }
hp->bh_page_count = page_count; hp->bh_page_count = page_count;
}
return hp; return hp;
} }
@@ -1209,13 +1209,13 @@ 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); vim_free(mfp->mf_fname);
mfp->mf_fname = mfp->mf_ffname; mfp->mf_fname = mfp->mf_ffname;
mfp->mf_ffname = NULL; mfp->mf_ffname = NULL;
} }
}
/* /*
* return TRUE if there are any translations pending for 'mfp' * return TRUE if there are any translations pending for 'mfp'

View File

@@ -422,8 +422,9 @@ 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); int method_nr = crypt_get_method_nr(buf);
if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD) if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD)
@@ -437,7 +438,6 @@ ml_set_mfp_crypt(buf_T *buf)
MF_SEED_LEN); MF_SEED_LEN);
#endif #endif
} }
}
/* /*
* Prepare encryption for "buf" with block 0 "b0p". * Prepare encryption for "buf" with block 0 "b0p".
@@ -2090,8 +2090,9 @@ 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); s = alloc(STRLEN(f) + 1);
if (s != NULL) if (s != NULL)
{ {
@@ -2105,7 +2106,6 @@ make_percent_swname(char_u *dir, char_u *name)
vim_free(s); vim_free(s);
} }
vim_free(f); vim_free(f);
}
return d; return d;
} }
#endif #endif
@@ -5473,8 +5473,9 @@ 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]); head_end = (char_u *)(&dp->db_index[dp->db_line_count]);
text_start = (char_u *)dp + dp->db_txt_start; text_start = (char_u *)dp + dp->db_txt_start;
text_len = dp->db_txt_end - dp->db_txt_start; text_len = dp->db_txt_end - dp->db_txt_start;
@@ -5484,14 +5485,13 @@ ml_decrypt_data(
return; // data was messed up return; // data was messed up
state = ml_crypt_prepare(mfp, offset, TRUE); state = ml_crypt_prepare(mfp, offset, TRUE);
if (state != NULL) if (state == NULL)
{ return;
// Decrypt the text in place. // Decrypt the text in place.
crypt_decode_inplace(state, text_start, text_len, FALSE); crypt_decode_inplace(state, text_start, text_len, FALSE);
crypt_free_state(state); crypt_free_state(state);
} }
}
}
/* /*
* Prepare for encryption/decryption, using the key, seed and offset. * Prepare for encryption/decryption, using the key, seed and offset.

View File

@@ -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)); mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4));
for (i = 0; i < mode_chars_len; ++i) for (i = 0; i < mode_chars_len; ++i)
p[5 + i] = menu_mode_chars[idx][i]; p[5 + i] = menu_mode_chars[idx][i];
}
return p; return p;
} }
@@ -2008,8 +2008,9 @@ 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)
{ {
@@ -2026,7 +2027,6 @@ show_popupmenu(void)
pum_show_popupmenu(menu); pum_show_popupmenu(menu);
# endif # endif
} }
}
#endif #endif
#if defined(FEAT_GUI) || defined(PROTO) #if defined(FEAT_GUI) || defined(PROTO)
@@ -2255,8 +2255,9 @@ 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[0] = K_SPECIAL;
tbuf[1] = K_SECOND(K_TEAROFF); tbuf[1] = K_SECOND(K_TEAROFF);
tbuf[2] = K_THIRD(K_TEAROFF); tbuf[2] = K_THIRD(K_TEAROFF);
@@ -2288,7 +2289,6 @@ gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx)
pri_tab[pri_idx + 1] = t; pri_tab[pri_idx + 1] = t;
vim_free(tbuf); vim_free(tbuf);
} }
}
/* /*
* Recursively destroy tearoff items * Recursively destroy tearoff items
@@ -2789,8 +2789,9 @@ 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) for (i = 0; i < menutrans_ga.ga_len; ++i)
if (STRICMP(dname, tp[i].from_noamp) == 0) if (STRICMP(dname, tp[i].from_noamp) == 0)
{ {
@@ -2798,7 +2799,6 @@ menutrans_lookup(char_u *name, int len)
return tp[i].to; return tp[i].to;
} }
vim_free(dname); vim_free(dname);
}
return NULL; return NULL;
} }

View File

@@ -375,8 +375,7 @@ 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_list arglist;
va_start(arglist, s); va_start(arglist, s);
@@ -384,7 +383,6 @@ smsg(const char *s, ...)
va_end(arglist); va_end(arglist);
return msg((char *)IObuff); return msg((char *)IObuff);
} }
}
int int
smsg_attr(int attr, const char *s, ...) smsg_attr(int attr, const char *s, ...)
@@ -395,8 +393,7 @@ 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_list arglist;
va_start(arglist, s); va_start(arglist, s);
@@ -404,7 +401,6 @@ smsg_attr(int attr, const char *s, ...)
va_end(arglist); va_end(arglist);
return msg_attr((char *)IObuff, attr); return msg_attr((char *)IObuff, attr);
} }
}
int int
smsg_attr_keep(int attr, const char *s, ...) smsg_attr_keep(int attr, const char *s, ...)
@@ -415,8 +411,7 @@ 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_list arglist;
va_start(arglist, s); va_start(arglist, s);
@@ -424,7 +419,6 @@ smsg_attr_keep(int attr, const char *s, ...)
va_end(arglist); va_end(arglist);
return msg_attr_keep((char *)IObuff, attr, TRUE); return msg_attr_keep((char *)IObuff, attr, TRUE);
} }
}
#endif #endif
@@ -834,8 +828,9 @@ 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);
@@ -844,7 +839,6 @@ iemsg(char *s)
abort(); abort();
#endif #endif
} }
}
#ifndef PROTO // manual proto with __attribute__ #ifndef PROTO // manual proto with __attribute__
/* /*
@@ -856,8 +850,9 @@ 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) if (IObuff == NULL)
{ {
// Very early in initialisation and already something wrong, just // Very early in initialisation and already something wrong, just
@@ -879,7 +874,6 @@ siemsg(const char *s, ...)
abort(); abort();
# endif # endif
} }
}
#endif #endif
/* /*
@@ -1006,8 +1000,9 @@ 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) if (len < 0)
len = (int)STRLEN(s); len = (int)STRLEN(s);
// remove leading and trailing newlines // remove leading and trailing newlines
@@ -1028,7 +1023,6 @@ add_msg_hist(
first_msg_hist = last_msg_hist; first_msg_hist = last_msg_hist;
++msg_hist_len; ++msg_hist_len;
} }
}
/* /*
* Delete the first (oldest) message from the history. * Delete the first (oldest) message from the history.

View File

@@ -1119,8 +1119,9 @@ 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
@@ -1173,7 +1174,6 @@ vim_beep(unsigned val)
msg_attr(_("Beep!"), HL_ATTR(HLF_W)); msg_attr(_("Beep!"), HL_ATTR(HLF_W));
} }
} }
}
/* /*
* To get the "real" home directory: * To get the "real" home directory:

View File

@@ -1130,8 +1130,9 @@ 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 // TAB is a special case
if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) if (key == TAB && (*modifiers & MOD_MASK_SHIFT))
{ {
@@ -1141,6 +1142,7 @@ simplify_key(int key, int *modifiers)
key0 = KEY2TERMCAP0(key); key0 = KEY2TERMCAP0(key);
key1 = KEY2TERMCAP1(key); key1 = KEY2TERMCAP1(key);
for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE)
{
if (key0 == modifier_keys_table[i + 3] if (key0 == modifier_keys_table[i + 3]
&& key1 == modifier_keys_table[i + 4] && key1 == modifier_keys_table[i + 4]
&& (*modifiers & modifier_keys_table[i])) && (*modifiers & modifier_keys_table[i]))
@@ -1537,8 +1539,9 @@ 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
@@ -1552,7 +1555,6 @@ may_adjust_key_for_ctrl(int modifiers, int key)
return '^'; return '^';
if (key == '-') if (key == '-')
return '_'; return '_';
}
return key; return key;
} }
@@ -2820,8 +2822,9 @@ 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. // Read the string. Quit when running into the EOF.
for (i = 0; i < cnt; ++i) for (i = 0; i < cnt; ++i)
{ {
@@ -2834,7 +2837,6 @@ read_string(FILE *fd, int cnt)
str[i] = c; str[i] = c;
} }
str[i] = NUL; str[i] = NUL;
}
return str; return str;
} }

View File

@@ -244,8 +244,9 @@ 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; curwin->w_skipcol = 0;
// Should use the least expensive way that displays all that changed. // Should use the least expensive way that displays all that changed.
@@ -253,7 +254,6 @@ reset_skipcol(void)
// enough when the top line gets another screen line. // enough when the top line gets another screen line.
redraw_later(UPD_SOME_VALID); redraw_later(UPD_SOME_VALID);
} }
}
/* /*
* Update curwin->w_topline and redraw if necessary. * Update curwin->w_topline and redraw if necessary.
@@ -980,8 +980,10 @@ 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
@@ -991,7 +993,6 @@ validate_virtcol_win(win_T *wp)
#endif #endif
wp->w_valid |= VALID_VIRTCOL; wp->w_valid |= VALID_VIRTCOL;
} }
}
/* /*
* Validate curwin->w_cline_height only. * Validate curwin->w_cline_height only.
@@ -1000,8 +1001,10 @@ 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)
@@ -1014,7 +1017,6 @@ validate_cheight(void)
#endif #endif
curwin->w_valid |= VALID_CHEIGHT; curwin->w_valid |= VALID_CHEIGHT;
} }
}
/* /*
* Validate w_wcol and w_virtcol only. * Validate w_wcol and w_virtcol only.
@@ -1027,8 +1029,10 @@ validate_cursor_col(void)
int width; int width;
validate_virtcol(); validate_virtcol();
if (!(curwin->w_valid & VALID_WCOL))
{ if (curwin->w_valid & VALID_WCOL)
return;
col = curwin->w_virtcol; col = curwin->w_virtcol;
off = curwin_col_off(); off = curwin_col_off();
col += off; col += off;
@@ -1051,7 +1055,6 @@ validate_cursor_col(void)
curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED; curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
#endif #endif
} }
}
/* /*
* Compute offset of a window, occupied by absolute or relative line number, * Compute offset of a window, occupied by absolute or relative line number,
@@ -1999,8 +2002,9 @@ 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); n = plines_win_nofill(wp, wp->w_topline, TRUE);
if (wp->w_topfill + n > wp->w_height) if (wp->w_topfill + n > wp->w_height)
{ {
@@ -2017,7 +2021,6 @@ check_topfill(
} }
} }
} }
}
/* /*
* Use as many filler lines as possible for w_topline. Make sure w_topline * Use as many filler lines as possible for w_topline. Make sure w_topline

View File

@@ -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,
/**/ /**/