1
0
forked from aniani/vim

patch 9.0.1237: 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 #11858)
This commit is contained in:
Yegappan Lakshmanan
2023-01-23 20:46:21 +00:00
committed by Bram Moolenaar
parent 9cbf791995
commit 6ec6666047
12 changed files with 1123 additions and 1124 deletions

View File

@@ -94,8 +94,9 @@ conceal_cursor_line(win_T *wp)
void
conceal_check_cursor_line(int was_concealed)
{
if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin) != was_concealed)
{
if (curwin->w_p_cole <= 0 || conceal_cursor_line(curwin) == was_concealed)
return;
int wcol = curwin->w_wcol;
need_cursor_line_redraw = TRUE;
@@ -108,7 +109,6 @@ conceal_check_cursor_line(int was_concealed)
if (!was_concealed)
curwin->w_wcol = wcol;
}
}
#endif
/*
@@ -906,15 +906,15 @@ draw_vsep_win(win_T *wp, int row)
int hl;
int c;
if (wp->w_vsep_width)
{
if (!wp->w_vsep_width)
return;
// draw the vertical separator right of this window
c = fillchar_vsep(&hl, wp);
screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
W_ENDCOL(wp), W_ENDCOL(wp) + 1,
c, ' ', hl);
}
}
/*
* Return TRUE if the status line of window "wp" is connected to the status
@@ -960,7 +960,6 @@ get_keymap_str(
if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP)
return FALSE;
{
#ifdef FEAT_EVAL
buf_T *old_curbuf = curbuf;
win_T *old_curwin = curwin;
@@ -989,7 +988,6 @@ get_keymap_str(
#ifdef FEAT_EVAL
vim_free(s);
#endif
}
return buf[0] != NUL;
}
@@ -1208,8 +1206,9 @@ screen_getbytes(int row, int col, char_u *bytes, int *attrp)
unsigned off;
// safety check
if (ScreenLines != NULL && row < screen_Rows && col < screen_Columns)
{
if (ScreenLines == NULL || row >= screen_Rows || col >= screen_Columns)
return;
off = LineOffset[row] + col;
*attrp = ScreenAttrs[off];
bytes[0] = ScreenLines[off];
@@ -1229,7 +1228,6 @@ screen_getbytes(int row, int col, char_u *bytes, int *attrp)
bytes[2] = NUL;
}
}
}
/*
* Return TRUE if composing characters for screen posn "off" differs from
@@ -1538,13 +1536,13 @@ screen_puts_len(
void
start_search_hl(void)
{
if (p_hls && !no_hlsearch)
{
if (!p_hls || no_hlsearch)
return;
end_search_hl(); // just in case it wasn't called before
last_pat_prog(&screen_search_hl.rm);
screen_search_hl.attr = HL_ATTR(HLF_L);
}
}
/*
* Clean up for 'hlsearch' highlighting.
@@ -1552,12 +1550,12 @@ start_search_hl(void)
void
end_search_hl(void)
{
if (screen_search_hl.rm.regprog != NULL)
{
if (screen_search_hl.rm.regprog == NULL)
return;
vim_regfree(screen_search_hl.rm.regprog);
screen_search_hl.rm.regprog = NULL;
}
}
#endif
static void
@@ -1566,12 +1564,13 @@ screen_start_highlight(int attr)
attrentry_T *aep = NULL;
screen_attr = attr;
if (full_screen
if (!full_screen
#ifdef MSWIN
&& termcap_active
|| !termcap_active
#endif
)
{
return;
#ifdef FEAT_GUI
if (gui.in_use)
{
@@ -1580,10 +1579,10 @@ screen_start_highlight(int attr)
// The GUI handles this internally.
sprintf(buf, "\033|%dh", attr);
OUT_STR(buf);
return;
}
else
#endif
{
if (attr > HL_ALL) // special HL attr.
{
if (IS_CTERM)
@@ -1713,8 +1712,6 @@ screen_start_highlight(int attr)
out_str(aep->ae_u.term.start);
}
}
}
}
}
void
@@ -1895,8 +1892,9 @@ screen_stop_highlight(void)
void
reset_cterm_colors(void)
{
if (IS_CTERM)
{
if (!IS_CTERM)
return;
// set Normal cterm colors
#ifdef FEAT_TERMGUICOLORS
if (p_tgc ? (cterm_normal_fg_gui_color != INVALCOLOR
@@ -1915,7 +1913,6 @@ reset_cterm_colors(void)
screen_attr = -1;
}
}
}
/*
* Put character ScreenLines["off"] on the screen at position "row" and "col",
@@ -2954,8 +2951,9 @@ windgoto(int row, int col)
// Can't use ScreenLines unless initialized
if (ScreenLines == NULL)
return;
if (col != screen_cur_col || row != screen_cur_row)
{
if (col == screen_cur_col && row == screen_cur_row)
return;
// Check for valid position.
if (row < 0) // window without text lines?
row = 0;
@@ -3171,7 +3169,6 @@ windgoto(int row, int col)
screen_cur_row = row;
screen_cur_col = col;
}
}
/*
* Set cursor to its position in the current window.
@@ -4222,14 +4219,14 @@ clearmode(void)
recording_mode(int attr)
{
msg_puts_attr(_("recording"), attr);
if (!shortmess(SHM_RECORDING))
{
if (shortmess(SHM_RECORDING))
return;
char s[4];
sprintf(s, " @%c", reg_recording);
msg_puts_attr(s, attr);
}
}
/*
* Draw the tab pages line at the top of the Vim window.

View File

@@ -56,8 +56,9 @@ estack_push(etype_T type, char_u *name, long lnum)
// If memory allocation fails then we'll pop more than we push, eventually
// at the top level it will be OK again.
if (ga_grow(&exestack, 1) == OK)
{
if (ga_grow(&exestack, 1) != OK)
return NULL;
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
entry->es_type = type;
entry->es_name = name;
@@ -68,8 +69,6 @@ estack_push(etype_T type, char_u *name, long lnum)
++exestack.ga_len;
return entry;
}
return NULL;
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
@@ -667,13 +666,13 @@ source_all_matches(char_u *pat)
char_u **files;
int i;
if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK)
{
if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) != OK)
return;
for (i = 0; i < num_files; ++i)
(void)do_source(files[i], FALSE, DOSO_NONE, NULL);
FreeWild(num_files, files);
}
}
/*
* Add the package directory to 'runtimepath'.
@@ -2616,12 +2615,14 @@ get_autoload_prefix(scriptitem_T *si)
char_u *
may_prefix_autoload(char_u *name)
{
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
{
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
return name;
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_autoload_prefix != NULL)
{
if (si->sn_autoload_prefix == NULL)
return name;
char_u *basename = name;
size_t len;
char_u *res;
@@ -2637,16 +2638,12 @@ may_prefix_autoload(char_u *name)
len = STRLEN(si->sn_autoload_prefix) + STRLEN(basename) + 2;
res = alloc(len);
if (res != NULL)
{
vim_snprintf((char *)res, len, "%s%s",
si->sn_autoload_prefix, basename);
if (res == NULL)
return NULL;
vim_snprintf((char *)res, len, "%s%s", si->sn_autoload_prefix, basename);
return res;
}
}
}
return name;
}
/*
* Return the autoload script name for a function or variable name.

View File

@@ -220,8 +220,9 @@ reverse_text(char_u *s)
*/
len = (unsigned)STRLEN(s);
rev = alloc(len + 1);
if (rev != NULL)
{
if (rev == NULL)
return NULL;
rev_i = len;
for (s_i = 0; s_i < len; ++s_i)
{
@@ -239,7 +240,6 @@ reverse_text(char_u *s)
}
rev[len] = NUL;
}
return rev;
}
#endif
@@ -247,8 +247,9 @@ reverse_text(char_u *s)
void
save_re_pat(int idx, char_u *pat, int magic)
{
if (spats[idx].pat != pat)
{
if (spats[idx].pat == pat)
return;
vim_free(spats[idx].pat);
spats[idx].pat = vim_strsave(pat);
spats[idx].magic = magic;
@@ -261,7 +262,6 @@ save_re_pat(int idx, char_u *pat, int magic)
set_no_hlsearch(FALSE);
#endif
}
}
/*
* Save the search patterns, so they can be restored later.
@@ -272,8 +272,9 @@ static int save_level = 0;
void
save_search_patterns(void)
{
if (save_level++ == 0)
{
if (save_level++ != 0)
return;
saved_spats[0] = spats[0];
if (spats[0].pat != NULL)
saved_spats[0].pat = vim_strsave(spats[0].pat);
@@ -289,13 +290,13 @@ save_search_patterns(void)
saved_spats_no_hlsearch = no_hlsearch;
#endif
}
}
void
restore_search_patterns(void)
{
if (--save_level == 0)
{
if (--save_level != 0)
return;
vim_free(spats[0].pat);
spats[0] = saved_spats[0];
#if defined(FEAT_EVAL)
@@ -310,7 +311,6 @@ restore_search_patterns(void)
set_no_hlsearch(saved_spats_no_hlsearch);
#endif
}
}
#if defined(EXITFREE) || defined(PROTO)
void
@@ -2791,14 +2791,23 @@ showmatch(
return;
if ((lpos = findmatch(NULL, NUL)) == NULL) // no match, so beep
vim_beep(BO_MATCH);
else if (lpos->lnum >= curwin->w_topline && lpos->lnum < curwin->w_botline)
{
vim_beep(BO_MATCH);
return;
}
if (lpos->lnum < curwin->w_topline || lpos->lnum >= curwin->w_botline)
return;
if (!curwin->w_p_wrap)
getvcol(curwin, lpos, NULL, &vcol, NULL);
if (curwin->w_p_wrap || (vcol >= curwin->w_leftcol
&& vcol < curwin->w_leftcol + curwin->w_width))
{
int col_visible = (curwin->w_p_wrap
|| (vcol >= curwin->w_leftcol
&& vcol < curwin->w_leftcol + curwin->w_width));
if (!col_visible)
return;
mpos = *lpos; // save the pos, update_screen() may change it
save_cursor = curwin->w_cursor;
save_so = *so;
@@ -2845,8 +2854,6 @@ showmatch(
ui_cursor_shape(); // may show different cursor shape
#endif
}
}
}
/*
* Check if the pattern is zero-width.
@@ -3101,8 +3108,9 @@ cmdline_search_stat(
update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,
timeout);
if (stat.cur > 0)
{
if (stat.cur <= 0)
return;
char t[SEARCH_STAT_BUF_LEN];
size_t len;
@@ -3155,7 +3163,6 @@ cmdline_search_stat(
give_warning(msgbuf, FALSE);
msg_hist_off = FALSE;
}
}
/*
* Add the search count information to "stat".

View File

@@ -200,8 +200,9 @@ ses_win_rec(FILE *fd, frame_T *fr)
frame_T *frc;
int count = 0;
if (fr->fr_layout != FR_LEAF)
{
if (fr->fr_layout == FR_LEAF)
return OK;
// Find first frame that's not skipped and then create a window for
// each following one (first frame is already there).
frc = ses_skipframe(fr->fr_child);
@@ -234,7 +235,7 @@ ses_win_rec(FILE *fd, frame_T *fr)
if (frc != NULL && put_line(fd, "wincmd w") == FAIL)
return FAIL;
}
}
return OK;
}
@@ -1068,12 +1069,12 @@ ex_loadview(exarg_T *eap)
char_u *fname;
fname = get_view_file(*eap->arg);
if (fname != NULL)
{
if (fname == NULL)
return;
do_source(fname, FALSE, DOSO_NONE, NULL);
vim_free(fname);
}
}
# if defined(FEAT_GUI_GNOME) \
|| (defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD)) \

View File

@@ -119,8 +119,9 @@ sign_group_unref(char_u *groupname)
signgroup_T *group;
hi = hash_find(&sg_table, groupname);
if (!HASHITEM_EMPTY(hi))
{
if (HASHITEM_EMPTY(hi))
return;
group = HI2SG(hi);
group->sg_refcount--;
if (group->sg_refcount == 0)
@@ -130,7 +131,6 @@ sign_group_unref(char_u *groupname)
vim_free(group);
}
}
}
/*
* Returns TRUE if 'sign' is in 'group'.
@@ -220,8 +220,9 @@ insert_sign(
sign_entry_T *newsign;
newsign = lalloc_id(sizeof(sign_entry_T), FALSE, aid_insert_sign);
if (newsign != NULL)
{
if (newsign == NULL)
return;
newsign->se_id = id;
newsign->se_lnum = lnum;
newsign->se_typenr = typenr;
@@ -262,7 +263,6 @@ insert_sign(
else
prev->se_next = newsign;
}
}
/*
* Insert a new sign sorted by line number and sign priority.

View File

@@ -54,15 +54,16 @@ get_sound_callback(typval_T *arg)
soundcb = ALLOC_ONE(soundcb_T);
if (soundcb == NULL)
free_callback(&callback);
else
{
free_callback(&callback);
return NULL;
}
soundcb->snd_next = first_callback;
first_callback = soundcb;
set_callback(&soundcb->snd_callback, &callback);
if (callback.cb_free_name)
vim_free(callback.cb_name);
}
return soundcb;
}
@@ -195,8 +196,9 @@ sound_play_common(typval_T *argvars, typval_T *rettv, int playfile)
if (context == NULL)
ca_context_create(&context);
if (context != NULL)
{
if (context == NULL)
return;
soundcb_T *soundcb = get_sound_callback(&argvars[1]);
int res = CA_ERROR_INVALID;
@@ -234,7 +236,6 @@ sound_play_common(typval_T *argvars, typval_T *rettv, int playfile)
}
rettv->vval.v_number = res == CA_SUCCESS ? sound_id : 0;
}
}
void
f_sound_playevent(typval_T *argvars, typval_T *rettv)
@@ -270,12 +271,11 @@ f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
void
f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
if (context != NULL)
{
if (context == NULL)
return;
ca_context_destroy(context);
context = NULL;
}
}
# if defined(EXITFREE) || defined(PROTO)
void

View File

@@ -1527,8 +1527,9 @@ spell_cat_line(char_u *buf, char_u *line, int maxlen)
while (vim_strchr((char_u *)"*#/\"\t", *p) != NULL)
p = skipwhite(p + 1);
if (*p != NUL)
{
if (*p == NUL)
return;
// Only worth concatenating if there is something else than spaces to
// concatenate.
n = (int)(p - line) + 1;
@@ -1538,7 +1539,6 @@ spell_cat_line(char_u *buf, char_u *line, int maxlen)
vim_strncpy(buf + n, p, maxlen - 1 - n);
}
}
}
/*
* Structure used for the cookie argument of do_in_runtimepath().
@@ -1803,8 +1803,9 @@ spell_load_cb(char_u *fname, void *cookie)
slang_T *slang;
slang = spell_load_file(fname, slp->sl_lang, NULL, FALSE);
if (slang != NULL)
{
if (slang == NULL)
return;
// When a previously loaded file has NOBREAK also use it for the
// ".add" files.
if (slp->sl_nobreak && slang->sl_add)
@@ -1814,7 +1815,6 @@ spell_load_cb(char_u *fname, void *cookie)
slp->sl_slang = slang;
}
}
/*
@@ -2444,14 +2444,14 @@ spell_delete_wordlist(void)
{
char_u fname[MAXPATHL];
if (int_wordlist != NULL)
{
if (int_wordlist == NULL)
return;
mch_remove(int_wordlist);
int_wordlist_spl(fname);
mch_remove(fname);
VIM_CLEAR(int_wordlist);
}
}
/*
* Free all languages.
@@ -2524,8 +2524,9 @@ open_spellbuf(void)
buf_T *buf;
buf = ALLOC_CLEAR_ONE(buf_T);
if (buf != NULL)
{
if (buf == NULL)
return NULL;
buf->b_spell = TRUE;
buf->b_p_swf = TRUE; // may create a swap file
#ifdef FEAT_CRYPT
@@ -2533,7 +2534,6 @@ open_spellbuf(void)
#endif
ml_open(buf);
ml_open_file(buf); // create swap file now
}
return buf;
}
@@ -2543,12 +2543,12 @@ open_spellbuf(void)
void
close_spellbuf(buf_T *buf)
{
if (buf != NULL)
{
if (buf == NULL)
return;
ml_close(buf, TRUE);
vim_free(buf);
}
}
/*
* Init the chartab used for spelling for ASCII.
@@ -4404,15 +4404,15 @@ did_set_spell_option(int is_spellfile)
errmsg = e_invalid_argument;
}
if (errmsg == NULL)
{
if (errmsg != NULL)
return errmsg;
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == curbuf && wp->w_p_spell)
{
errmsg = did_set_spelllang(wp);
break;
}
}
return errmsg;
}

View File

@@ -1561,12 +1561,12 @@ mb_str2wide(char_u *s)
int i = 0;
res = ALLOC_MULT(int, mb_charlen(s) + 1);
if (res != NULL)
{
if (res == NULL)
return NULL;
for (p = s; *p != NUL; )
res[i++] = mb_ptr2char_adv(&p);
res[i] = NUL;
}
return res;
}
@@ -1598,8 +1598,9 @@ spell_read_tree(
if (len >= LONG_MAX / (long)sizeof(int))
// Invalid length, multiply with sizeof(int) would overflow.
return SP_FORMERROR;
if (len > 0)
{
if (len <= 0)
return 0;
// Allocate the byte array.
bp = alloc(len);
if (bp == NULL)
@@ -1618,7 +1619,6 @@ spell_read_tree(
idx = read_tree_node(fd, bp, ip, len, 0, prefixtree, prefixcnt);
if (idx < 0)
return idx;
}
return 0;
}
@@ -2167,16 +2167,15 @@ spell_print_node(wordnode_T *node, int depth)
static void
spell_print_tree(wordnode_T *root)
{
if (root != NULL)
{
// Clear the "wn_u1.index" fields, used to remember what has been
// done.
if (root == NULL)
return;
// Clear the "wn_u1.index" fields, used to remember what has been done.
spell_clear_flags(root);
// Recursively print the tree.
spell_print_node(root, 0);
}
}
#endif // SPELL_PRINTTREE
/*
@@ -3429,8 +3428,9 @@ add_fromto(
fromto_T *ftp;
char_u word[MAXWLEN];
if (ga_grow(gap, 1) == OK)
{
if (ga_grow(gap, 1) != OK)
return;
ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
(void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN);
ftp->ft_from = getroom_save(spin, word);
@@ -3438,7 +3438,6 @@ add_fromto(
ftp->ft_to = getroom_save(spin, word);
++gap->ga_len;
}
}
/*
* Convert a boolean argument in a SAL line to TRUE or FALSE;
@@ -4700,8 +4699,9 @@ wordtree_compress(spellinfo_T *spin, wordnode_T *root, char *name)
// Skip the root itself, it's not actually used. The first sibling is the
// start of the tree.
if (root->wn_sibling != NULL)
{
if (root->wn_sibling == NULL)
return;
hash_init(&ht);
n = node_compress(spin, root->wn_sibling, &ht, &tot);
@@ -4725,7 +4725,6 @@ wordtree_compress(spellinfo_T *spin, wordnode_T *root, char *name)
#endif
hash_clear(&ht);
}
}
/*
* Compress a node, its siblings and its children, depth first.
@@ -5465,12 +5464,12 @@ ex_mkspell(exarg_T *eap)
}
// Expand all the remaining arguments (e.g., $VIMRUNTIME).
if (get_arglist_exp(arg, &fcount, &fnames, FALSE) == OK)
{
if (get_arglist_exp(arg, &fcount, &fnames, FALSE) != OK)
return;
mkspell(fcount, fnames, ascii, eap->forceit, FALSE);
FreeWild(fcount, fnames);
}
}
/*
* Create the .sug file.
@@ -6392,8 +6391,9 @@ init_spellfile(void)
int aspath = FALSE;
char_u *lstart = curbuf->b_s.b_p_spl;
if (*curwin->w_s->b_p_spl != NUL && curwin->w_s->b_langp.ga_len > 0)
{
if (*curwin->w_s->b_p_spl == NUL || curwin->w_s->b_langp.ga_len <= 0)
return;
buf = alloc(MAXPATHL);
if (buf == NULL)
return;
@@ -6456,7 +6456,6 @@ init_spellfile(void)
vim_free(buf);
}
}

View File

@@ -282,8 +282,9 @@ score_wordcount_adj(
int newscore;
hi = hash_find(&slang->sl_wordcount, word);
if (!HASHITEM_EMPTY(hi))
{
if (HASHITEM_EMPTY(hi))
return score;
wc = HI2WC(hi);
if (wc->wc_count < SCORE_THRES2)
bonus = SCORE_COMMON1;
@@ -299,8 +300,6 @@ score_wordcount_adj(
return 0;
return newscore;
}
return score;
}
/*
* Like captype() but for a KEEPCAP word add ONECAP if the word starts with a
@@ -316,8 +315,9 @@ badword_captype(char_u *word, char_u *end)
int first;
char_u *p;
if (flags & WF_KEEPCAP)
{
if (!(flags & WF_KEEPCAP))
return flags;
// Count the number of UPPER and lower case letters.
l = u = 0;
first = FALSE;
@@ -345,7 +345,7 @@ badword_captype(char_u *word, char_u *end)
if (u >= 2 && l >= 2) // maCARONI maCAroni
flags |= WF_MIXCAP;
}
return flags;
}
@@ -3692,13 +3692,12 @@ add_banned(
hash = hash_hash(word);
hi = hash_lookup(&su->su_banned, word, hash);
if (HASHITEM_EMPTY(hi))
{
if (!HASHITEM_EMPTY(hi)) // already present
return;
s = vim_strsave(word);
if (s != NULL)
hash_add_item(&su->su_banned, hi, s, hash);
}
}
/*
* Recompute the score for all suggestions if sound-folding is possible. This
@@ -3778,8 +3777,9 @@ cleanup_suggestions(
int maxscore,
int keep) // nr of suggestions to keep
{
if (gap->ga_len > 0)
{
if (gap->ga_len <= 0)
return maxscore;
// Sort the list.
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T),
sug_compare);
@@ -3797,7 +3797,6 @@ cleanup_suggestions(
if (keep >= 1)
return stp[keep - 1].st_score;
}
}
return maxscore;
}

View File

@@ -42,11 +42,11 @@ vim_strnsave(char_u *string, size_t len)
char_u *p;
p = alloc(len + 1);
if (p != NULL)
{
if (p == NULL)
return NULL;
STRNCPY(p, string, len);
p[len] = NUL;
}
return p;
}
@@ -94,8 +94,8 @@ vim_strsave_escaped_ext(
++length; // count an ordinary char
}
escaped_string = alloc(length);
if (escaped_string != NULL)
{
if (escaped_string == NULL)
return NULL;
p2 = escaped_string;
for (p = string; *p; p++)
{
@@ -111,7 +111,6 @@ vim_strsave_escaped_ext(
*p2++ = *p;
}
*p2 = NUL;
}
return escaped_string;
}
@@ -338,13 +337,13 @@ vim_strup(
char_u *p2;
int c;
if (p != NULL)
{
if (p == NULL)
return;
p2 = p;
while ((c = *p2) != NUL)
*p2++ = (c < 'a' || c > 'z') ? c : (c - 0x20);
}
}
#if defined(FEAT_EVAL) || defined(FEAT_SPELL) || defined(PROTO)
/*
@@ -760,15 +759,14 @@ concat_str(char_u *str1, char_u *str2)
size_t l = str1 == NULL ? 0 : STRLEN(str1);
dest = alloc(l + (str2 == NULL ? 0 : STRLEN(str2)) + 1L);
if (dest != NULL)
{
if (dest == NULL)
return NULL;
if (str1 == NULL)
*dest = NUL;
else
STRCPY(dest, str1);
if (str2 != NULL)
STRCPY(dest + l, str2);
}
return dest;
}
@@ -793,8 +791,9 @@ string_quote(char_u *str, int function)
++len;
}
s = r = alloc(len);
if (r != NULL)
{
if (r == NULL)
return NULL;
if (function)
{
STRCPY(r, "function('");
@@ -813,7 +812,6 @@ string_quote(char_u *str, int function)
if (function)
*r++ = ')';
*r++ = NUL;
}
return s;
}

View File

@@ -855,12 +855,11 @@ syn_sync(
static void
save_chartab(char_u *chartab)
{
if (syn_block->b_syn_isk != empty_option)
{
if (syn_block->b_syn_isk == empty_option)
return;
mch_memmove(chartab, syn_buf->b_chartab, (size_t)32);
mch_memmove(syn_buf->b_chartab, syn_win->w_s->b_syn_chartab,
(size_t)32);
}
mch_memmove(syn_buf->b_chartab, syn_win->w_s->b_syn_chartab, (size_t)32);
}
static void
@@ -880,8 +879,9 @@ syn_match_linecont(linenr_T lnum)
int r;
char_u buf_chartab[32]; // chartab array for syn iskyeyword
if (syn_block->b_syn_linecont_prog != NULL)
{
if (syn_block->b_syn_linecont_prog == NULL)
return FALSE;
// use syntax iskeyword option
save_chartab(buf_chartab);
regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
@@ -892,8 +892,6 @@ syn_match_linecont(linenr_T lnum)
restore_chartab(buf_chartab);
return r;
}
return FALSE;
}
/*
* Prepare the current state for the start of a line.
@@ -1030,15 +1028,15 @@ syn_stack_free_block(synblock_T *block)
{
synstate_T *p;
if (block->b_sst_array != NULL)
{
if (block->b_sst_array == NULL)
return;
FOR_ALL_SYNSTATES(block, p)
clear_syn_state(p);
VIM_CLEAR(block->b_sst_array);
block->b_sst_first = NULL;
block->b_sst_len = 0;
}
}
/*
* Free b_sst_array[] for buffer "buf".
* Used when syntax items changed to force resyncing everywhere.
@@ -5437,11 +5435,11 @@ syn_scl_namen2id(char_u *linep, int len)
int id = 0;
name = vim_strnsave(linep, len);
if (name != NULL)
{
if (name == NULL)
return 0;
id = syn_scl_name2id(name);
vim_free(name);
}
return id;
}
@@ -6256,8 +6254,9 @@ ex_syntax(exarg_T *eap)
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end)
;
subcmd_name = vim_strnsave(arg, subcmd_end - arg);
if (subcmd_name != NULL)
{
if (subcmd_name == NULL)
return;
if (eap->skip) // skip error messages for all subcommands
++emsg_skip;
for (i = 0; ; ++i)
@@ -6278,7 +6277,6 @@ ex_syntax(exarg_T *eap)
if (eap->skip)
--emsg_skip;
}
}
void
ex_ownsyntax(exarg_T *eap)
@@ -6384,12 +6382,15 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
include_link = 0;
include_default = 0;
if (*arg == NUL)
return;
// (part of) subcommand already typed
if (*arg != NUL)
{
p = skiptowhite(arg);
if (*p != NUL) // past first word
{
if (*p == NUL)
return;
// past first word
xp->xp_pattern = skipwhite(p);
if (*skiptowhite(xp->xp_pattern) != NUL)
xp->xp_context = EXPAND_NOTHING;
@@ -6414,8 +6415,6 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
else
xp->xp_context = EXPAND_NOTHING;
}
}
}
/*
* Function given to ExpandGeneric() to obtain the list syntax names for

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1237,
/**/
1236,
/**/