summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-01-09 19:04:23 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-09 19:04:23 +0000
commit1cfb14aa972ccf3235ac67f07b7db1175b7c5384 (patch)
treeb746eda548993b9e0987d7c9c0c543ddddc5758f
parent765d82a657c5e42d5d7c88ae410e53f398c34c43 (diff)
downloadvim-git-1cfb14aa972ccf3235ac67f07b7db1175b7c5384.tar.gz
patch 9.0.1166: code is indented more than necessaryv9.0.1166
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11792)
-rw-r--r--src/autocmd.c24
-rw-r--r--src/buffer.c114
-rw-r--r--src/charset.c29
-rw-r--r--src/cindent.c107
-rw-r--r--src/clientserver.c28
-rw-r--r--src/cmdexpand.c29
-rw-r--r--src/debugger.c43
-rw-r--r--src/dict.c130
-rw-r--r--src/diff.c16
-rw-r--r--src/digraph.c39
-rw-r--r--src/edit.c12
-rw-r--r--src/evalfunc.c108
-rw-r--r--src/evalwindow.c60
-rw-r--r--src/ex_cmds.c96
-rw-r--r--src/ex_cmds2.c44
-rw-r--r--src/ex_getln.c16
-rw-r--r--src/filepath.c30
-rw-r--r--src/findfile.c41
-rw-r--r--src/fold.c2
-rw-r--r--src/hardcopy.c180
-rw-r--r--src/highlight.c638
-rw-r--r--src/version.c2
22 files changed, 907 insertions, 881 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 20c5afa74..c18d2a15a 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1063,18 +1063,18 @@ au_get_grouparg(char_u **argp)
for (p = arg; *p && !VIM_ISWHITE(*p) && *p != '|'; ++p)
;
- if (p > arg)
- {
- group_name = vim_strnsave(arg, p - arg);
- if (group_name == NULL) // out of memory
- return AUGROUP_ERROR;
- group = au_find_group(group_name);
- if (group == AUGROUP_ERROR)
- group = AUGROUP_ALL; // no match, use all groups
- else
- *argp = skipwhite(p); // match, skip over group name
- vim_free(group_name);
- }
+ if (p <= arg)
+ return AUGROUP_ALL;
+
+ group_name = vim_strnsave(arg, p - arg);
+ if (group_name == NULL) // out of memory
+ return AUGROUP_ERROR;
+ group = au_find_group(group_name);
+ if (group == AUGROUP_ERROR)
+ group = AUGROUP_ALL; // no match, use all groups
+ else
+ *argp = skipwhite(p); // match, skip over group name
+ vim_free(group_name);
return group;
}
diff --git a/src/buffer.c b/src/buffer.c
index 401682261..a3de68df2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -357,34 +357,34 @@ open_buffer(
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
#endif
- if (retval == OK)
+ if (retval != OK)
+ return retval;
+
+ // The autocommands may have changed the current buffer. Apply the
+ // modelines to the correct buffer, if it still exists and is loaded.
+ if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL)
{
- // The autocommands may have changed the current buffer. Apply the
- // modelines to the correct buffer, if it still exists and is loaded.
- if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL)
- {
- aco_save_T aco;
+ aco_save_T aco;
- // Go to the buffer that was opened, make sure it is in a window.
- // If not then skip it.
- aucmd_prepbuf(&aco, old_curbuf.br_buf);
- if (curbuf == old_curbuf.br_buf)
- {
- do_modelines(0);
- curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
+ // Go to the buffer that was opened, make sure it is in a window.
+ // If not then skip it.
+ aucmd_prepbuf(&aco, old_curbuf.br_buf);
+ if (curbuf == old_curbuf.br_buf)
+ {
+ do_modelines(0);
+ curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
- if ((flags & READ_NOWINENTER) == 0)
+ if ((flags & READ_NOWINENTER) == 0)
#ifdef FEAT_EVAL
- apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL,
- FALSE, curbuf, &retval);
+ apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL,
+ FALSE, curbuf, &retval);
#else
- apply_autocmds(EVENT_BUFWINENTER, NULL, NULL,
- FALSE, curbuf);
+ apply_autocmds(EVENT_BUFWINENTER, NULL, NULL,
+ FALSE, curbuf);
#endif
- // restore curwin/curbuf and a few other things
- aucmd_restbuf(&aco);
- }
+ // restore curwin/curbuf and a few other things
+ aucmd_restbuf(&aco);
}
}
@@ -1761,7 +1761,6 @@ do_bufdel(
}
}
-
return errormsg;
}
@@ -3019,20 +3018,20 @@ fname_match(
char_u *p;
// extra check for valid arguments
- if (name != NULL && rmp->regprog != NULL)
+ if (name == NULL || rmp->regprog == NULL)
+ return NULL;
+
+ // Ignore case when 'fileignorecase' or the argument is set.
+ rmp->rm_ic = p_fic || ignore_case;
+ if (vim_regexec(rmp, name, (colnr_T)0))
+ match = name;
+ else if (rmp->regprog != NULL)
{
- // Ignore case when 'fileignorecase' or the argument is set.
- rmp->rm_ic = p_fic || ignore_case;
- if (vim_regexec(rmp, name, (colnr_T)0))
+ // Replace $(HOME) with '~' and try matching again.
+ p = home_replace_save(NULL, name);
+ if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
match = name;
- else if (rmp->regprog != NULL)
- {
- // Replace $(HOME) with '~' and try matching again.
- p = home_replace_save(NULL, name);
- if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
- match = name;
- vim_free(p);
- }
+ vim_free(p);
}
return match;
@@ -3160,16 +3159,15 @@ wininfo_other_tab_diff(wininfo_T *wip)
{
win_T *wp;
- if (wip->wi_opt.wo_diff)
- {
- FOR_ALL_WINDOWS(wp)
- // return FALSE when it's a window in the current tab page, thus
- // the buffer was in diff mode here
- if (wip->wi_win == wp)
- return FALSE;
- return TRUE;
- }
- return FALSE;
+ if (!wip->wi_opt.wo_diff)
+ return FALSE;
+
+ FOR_ALL_WINDOWS(wp)
+ // return FALSE when it's a window in the current tab page, thus
+ // the buffer was in diff mode here
+ if (wip->wi_win == wp)
+ return FALSE;
+ return TRUE;
}
#endif
@@ -3198,27 +3196,27 @@ find_wininfo(
&& (!need_options || wip->wi_optset))
break;
+ if (wip != NULL)
+ return wip;
+
// If no wininfo for curwin, use the first in the list (that doesn't have
// 'diff' set and is in another tab page).
// If "need_options" is TRUE skip entries that don't have options set,
// unless the window is editing "buf", so we can copy from the window
// itself.
- if (wip == NULL)
- {
#ifdef FEAT_DIFF
- if (skip_diff_buffer)
- {
- FOR_ALL_BUF_WININFO(buf, wip)
- if (!wininfo_other_tab_diff(wip)
- && (!need_options || wip->wi_optset
- || (wip->wi_win != NULL
- && wip->wi_win->w_buffer == buf)))
- break;
- }
- else
-#endif
- wip = buf->b_wininfo;
+ if (skip_diff_buffer)
+ {
+ FOR_ALL_BUF_WININFO(buf, wip)
+ if (!wininfo_other_tab_diff(wip)
+ && (!need_options || wip->wi_optset
+ || (wip->wi_win != NULL
+ && wip->wi_win->w_buffer == buf)))
+ break;
}
+ else
+#endif
+ wip = buf->b_wininfo;
return wip;
}
diff --git a/src/charset.c b/src/charset.c
index 8d7b61a4a..0bad471e4 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -345,24 +345,25 @@ transstr(char_u *s)
}
else
res = alloc(vim_strsize(s) + 1);
- if (res != NULL)
+
+ if (res == NULL)
+ return NULL;
+
+ *res = NUL;
+ p = s;
+ while (*p != NUL)
{
- *res = NUL;
- p = s;
- while (*p != NUL)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
- if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
- {
- c = (*mb_ptr2char)(p);
- if (vim_isprintc(c))
- STRNCAT(res, p, l); // append printable multi-byte char
- else
- transchar_hex(res + STRLEN(res), c);
- p += l;
- }
+ c = (*mb_ptr2char)(p);
+ if (vim_isprintc(c))
+ STRNCAT(res, p, l); // append printable multi-byte char
else
- STRCAT(res, transchar_byte(*p++));
+ transchar_hex(res + STRLEN(res), c);
+ p += l;
}
+ else
+ STRCAT(res, transchar_byte(*p++));
}
return res;
}
diff --git a/src/cindent.c b/src/cindent.c
index 105e08cc8..bc71cc092 100644
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -46,21 +46,21 @@ cin_is_cinword(char_u *line)
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
cinw_buf = alloc(cinw_len);
- if (cinw_buf != NULL)
+ if (cinw_buf == NULL)
+ return FALSE;
+
+ line = skipwhite(line);
+ for (cinw = curbuf->b_p_cinw; *cinw; )
{
- line = skipwhite(line);
- for (cinw = curbuf->b_p_cinw; *cinw; )
+ len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
+ if (STRNCMP(line, cinw_buf, len) == 0
+ && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1])))
{
- len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
- if (STRNCMP(line, cinw_buf, len) == 0
- && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1])))
- {
- retval = TRUE;
- break;
- }
+ retval = TRUE;
+ break;
}
- vim_free(cinw_buf);
}
+ vim_free(cinw_buf);
return retval;
}
@@ -644,43 +644,42 @@ cin_islabel(void) // XXX
if (cin_isscopedecl(s))
return FALSE;
- if (cin_islabel_skip(&s))
- {
- // Only accept a label if the previous line is terminated or is a case
- // label.
- pos_T cursor_save;
- pos_T *trypos;
- char_u *line;
+ if (!cin_islabel_skip(&s))
+ return FALSE;
- cursor_save = curwin->w_cursor;
- while (curwin->w_cursor.lnum > 1)
- {
- --curwin->w_cursor.lnum;
+ // Only accept a label if the previous line is terminated or is a case
+ // label.
+ pos_T cursor_save;
+ pos_T *trypos;
+ char_u *line;
- // If we're in a comment or raw string now, skip to the start of
- // it.
- curwin->w_cursor.col = 0;
- if ((trypos = ind_find_start_CORS(NULL)) != NULL) // XXX
- curwin->w_cursor = *trypos;
+ cursor_save = curwin->w_cursor;
+ while (curwin->w_cursor.lnum > 1)
+ {
+ --curwin->w_cursor.lnum;
- line = ml_get_curline();
- if (cin_ispreproc(line)) // ignore #defines, #if, etc.
- continue;
- if (*(line = cin_skipcomment(line)) == NUL)
- continue;
+ // If we're in a comment or raw string now, skip to the start of
+ // it.
+ curwin->w_cursor.col = 0;
+ if ((trypos = ind_find_start_CORS(NULL)) != NULL) // XXX
+ curwin->w_cursor = *trypos;
+
+ line = ml_get_curline();
+ if (cin_ispreproc(line)) // ignore #defines, #if, etc.
+ continue;
+ if (*(line = cin_skipcomment(line)) == NUL)
+ continue;
- curwin->w_cursor = cursor_save;
- if (cin_isterminated(line, TRUE, FALSE)
- || cin_isscopedecl(line)
- || cin_iscase(line, TRUE)
- || (cin_islabel_skip(&line) && cin_nocode(line)))
- return TRUE;
- return FALSE;
- }
curwin->w_cursor = cursor_save;
- return TRUE; // label at start of file???
+ if (cin_isterminated(line, TRUE, FALSE)
+ || cin_isscopedecl(line)
+ || cin_iscase(line, TRUE)
+ || (cin_islabel_skip(&line) && cin_nocode(line)))
+ return TRUE;
+ return FALSE;
}
- return FALSE;
+ curwin->w_cursor = cursor_save;
+ return TRUE; // label at start of file???
}
/*
@@ -1688,18 +1687,18 @@ find_match_paren_after_brace (int ind_maxparen) // XXX
{
pos_T *trypos = find_match_paren(ind_maxparen);
- if (trypos != NULL)
- {
- pos_T *tryposBrace = find_start_brace();
-
- // If both an unmatched '(' and '{' is found. Ignore the '('
- // position if the '{' is further down.
- if (tryposBrace != NULL
- && (trypos->lnum != tryposBrace->lnum
- ? trypos->lnum < tryposBrace->lnum
- : trypos->col < tryposBrace->col))
- trypos = NULL;
- }
+ if (trypos == NULL)
+ return NULL;
+
+ pos_T *tryposBrace = find_start_brace();
+
+ // If both an unmatched '(' and '{' is found. Ignore the '('
+ // position if the '{' is further down.
+ if (tryposBrace != NULL
+ && (trypos->lnum != tryposBrace->lnum
+ ? trypos->lnum < tryposBrace->lnum
+ : trypos->col < tryposBrace->col))
+ trypos = NULL;
return trypos;
}
diff --git a/src/clientserver.c b/src/clientserver.c
index 2a091a6e9..dfbb8a8b0 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -157,22 +157,22 @@ serverConvert(
char_u *res = data;
*tofree = NULL;
- if (client_enc != NULL && p_enc != NULL)
- {
- vimconv_T vimconv;
+ if (client_enc == NULL || p_enc == NULL)
+ return res;
- vimconv.vc_type = CONV_NONE;
- if (convert_setup(&vimconv, client_enc, p_enc) != FAIL
- && vimconv.vc_type != CONV_NONE)
- {
- res = string_convert(&vimconv, data, NULL);
- if (res == NULL)
- res = data;
- else
- *tofree = res;
- }
- convert_setup(&vimconv, NULL, NULL);
+ vimconv_T vimconv;
+
+ vimconv.vc_type = CONV_NONE;
+ if (convert_setup(&vimconv, client_enc, p_enc) != FAIL
+ && vimconv.vc_type != CONV_NONE)
+ {
+ res = string_convert(&vimconv, data, NULL);
+ if (res == NULL)
+ res = data;
+ else
+ *tofree = res;
}
+ convert_setup(&vimconv, NULL, NULL);
return res;
}
#endif
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index cc34f296a..5a47f6a24 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -1850,21 +1850,22 @@ find_cmd_after_substitute_cmd(char_u *arg)
find_cmd_after_isearch_cmd(expand_T *xp, char_u *arg)
{
arg = skipwhite(skipdigits(arg)); // skip count
- if (*arg == '/') // Match regexp, not just whole words
+ if (*arg != '/')
+ return NULL;
+
+ // Match regexp, not just whole words
+ for (++arg; *arg && *arg != '/'; arg++)
+ if (*arg == '\\' && arg[1] != NUL)
+ arg++;
+ if (*arg)
{
- for (++arg; *arg && *arg != '/'; arg++)
- if (*arg == '\\' && arg[1] != NUL)
- arg++;
- if (*arg)
- {
- arg = skipwhite(arg + 1);
+ arg = skipwhite(arg + 1);
- // Check for trailing illegal characters
- if (*arg == NUL || vim_strchr((char_u *)"|\"\n", *arg) == NULL)
- xp->xp_context = EXPAND_NOTHING;
- else
- return arg;
- }
+ // Check for trailing illegal characters
+ if (*arg == NUL || vim_strchr((char_u *)"|\"\n", *arg) == NULL)
+ xp->xp_context = EXPAND_NOTHING;
+ else
+ return arg;
}
return NULL;
@@ -2780,7 +2781,7 @@ get_breakadd_arg(expand_T *xp UNUSED, int idx)
{
char *opts[] = {"expr", "file", "func", "here"};
- if (idx >=0 && idx <= 3)
+ if (idx >= 0 && idx <= 3)
{
// breakadd {expr, file, func, here}
if (breakpt_expand_what == EXP_BREAKPT_ADD)
diff --git a/src/debugger.c b/src/debugger.c
index 1352f4999..f627a9a4d 100644
--- a/src/debugger.c
+++ b/src/debugger.c
@@ -315,14 +315,14 @@ get_maxbacktrace_level(char_u *sname)
char *p, *q;
int maxbacktrace = 0;
- if (sname != NULL)
+ if (sname == NULL)
+ return 0;
+
+ p = (char *)sname;
+ while ((q = strstr(p, "..")) != NULL)
{
- p = (char *)sname;
- while ((q = strstr(p, "..")) != NULL)
- {
- p = q + 2;
- maxbacktrace++;
- }
+ p = q + 2;
+ maxbacktrace++;
}
return maxbacktrace;
}
@@ -486,21 +486,20 @@ dbg_check_skipped(exarg_T *eap)
{
int prev_got_int;
- if (debug_skipped)
- {
- // Save the value of got_int and reset it. We don't want a previous
- // interruption cause flushing the input buffer.
- prev_got_int = got_int;
- got_int = FALSE;
- debug_breakpoint_name = debug_skipped_name;
- // eap->skip is TRUE
- eap->skip = FALSE;
- (void)dbg_check_breakpoint(eap);
- eap->skip = TRUE;
- got_int |= prev_got_int;
- return TRUE;
- }
- return FALSE;
+ if (!debug_skipped)
+ return FALSE;
+
+ // Save the value of got_int and reset it. We don't want a previous
+ // interruption cause flushing the input buffer.
+ prev_got_int = got_int;
+ got_int = FALSE;
+ debug_breakpoint_name = debug_skipped_name;
+ // eap->skip is TRUE
+ eap->skip = FALSE;
+ (void)dbg_check_breakpoint(eap);
+ eap->skip = TRUE;
+ got_int |= prev_got_int;
+ return TRUE;
}
/*
diff --git a/src/dict.c b/src/dict.c
index d45fcff0a..6941845cd 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -30,21 +30,21 @@ dict_alloc(void)
dict_T *d;
d = ALLOC_CLEAR_ONE(dict_T);
- if (d != NULL)
- {
- // Add the dict to the list of dicts for garbage collection.
- if (first_dict != NULL)
- first_dict->dv_used_prev = d;
- d->dv_used_next = first_dict;
- d->dv_used_prev = NULL;
- first_dict = d;
-
- hash_init(&d->dv_hashtab);
- d->dv_lock = 0;
- d->dv_scope = 0;
- d->dv_refcount = 0;
- d->dv_copyID = 0;
- }
+ if (d == NULL)
+ return NULL;
+
+ // Add the dict to the list of dicts for garbage collection.
+ if (first_dict != NULL)
+ first_dict->dv_used_prev = d;
+ d->dv_used_next = first_dict;
+ d->dv_used_prev = NULL;
+ first_dict = d;
+
+ hash_init(&d->dv_hashtab);
+ d->dv_lock = 0;
+ d->dv_scope = 0;
+ d->dv_refcount = 0;
+ d->dv_copyID = 0;
return d;
}
@@ -228,13 +228,13 @@ dictitem_alloc(char_u *key)
size_t len = STRLEN(key);
di = alloc(offsetof(dictitem_T, di_key) + len + 1);
- if (di != NULL)
- {
- mch_memmove(di->di_key, key, len + 1);
- di->di_flags = DI_FLAGS_ALLOC;
- di->di_tv.v_lock = 0;
- di->di_tv.v_type = VAR_UNKNOWN;
- }
+ if (di == NULL)
+ return NULL;
+
+ mch_memmove(di->di_key, key, len + 1);
+ di->di_flags = DI_FLAGS_ALLOC;
+ di->di_tv.v_lock = 0;
+ di->di_tv.v_type = VAR_UNKNOWN;
return di;
}
@@ -248,12 +248,12 @@ dictitem_copy(dictitem_T *org)
size_t len = STRLEN(org->di_key);
di = alloc(offsetof(dictitem_T, di_key) + len + 1);
- if (di != NULL)
- {
- mch_memmove(di->di_key, org->di_key, len + 1);
- di->di_flags = DI_FLAGS_ALLOC;
- copy_tv(&org->di_tv, &di->di_tv);
- }
+ if (di == NULL)
+ return NULL;
+
+ mch_memmove(di->di_key, org->di_key, len + 1);
+ di->di_flags = DI_FLAGS_ALLOC;
+ copy_tv(&org->di_tv, &di->di_tv);
return di;
}
@@ -303,53 +303,53 @@ dict_copy(dict_T *orig, int deep, int top, int copyID)
return NULL;
copy = dict_alloc();
- if (copy != NULL)
+ if (copy == NULL)
+ return NULL;
+
+ if (copyID != 0)
{
- if (copyID != 0)
- {
- orig->dv_copyID = copyID;
- orig->dv_copydict = copy;
- }
- if (orig->dv_type == NULL || top || deep)
- copy->dv_type = NULL;
- else
- copy->dv_type = alloc_type(orig->dv_type);
+ orig->dv_copyID = copyID;
+ orig->dv_copydict = copy;
+ }
+ if (orig->dv_type == NULL || top || deep)
+ copy->dv_type = NULL;
+ else
+ copy->dv_type = alloc_type(orig->dv_type);
- todo = (int)orig->dv_hashtab.ht_used;
- for (hi = orig->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
+ todo = (int)orig->dv_hashtab.ht_used;
+ for (hi = orig->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
+ {
+ if (!HASHITEM_EMPTY(hi))
{
- if (!HASHITEM_EMPTY(hi))
- {
- --todo;
+ --todo;
- di = dictitem_alloc(hi->hi_key);
- if (di == NULL)
- break;
- if (deep)
- {
- if (item_copy(&HI2DI(hi)->di_tv, &di->di_tv,
- deep, FALSE, copyID) == FAIL)
- {
- vim_free(di);
- break;
- }
- }
- else
- copy_tv(&HI2DI(hi)->di_tv, &di->di_tv);
- if (dict_add(copy, di) == FAIL)
+ di = dictitem_alloc(hi->hi_key);
+ if (di == NULL)
+ break;
+ if (deep)
+ {
+ if (item_copy(&HI2DI(hi)->di_tv, &di->di_tv,
+ deep, FALSE, copyID) == FAIL)
{
- dictitem_free(di);
+ vim_free(di);
break;
}
}
+ else
+ copy_tv(&HI2DI(hi)->di_tv, &di->di_tv);
+ if (dict_add(copy, di) == FAIL)
+ {
+ dictitem_free(di);
+ break;
+ }
}
+ }
- ++copy->dv_refcount;
- if (todo > 0)
- {
- dict_unref(copy);
- copy = NULL;
- }
+ ++copy->dv_refcount;
+ if (todo > 0)
+ {
+ dict_unref(copy);
+ copy = NULL;
}
return copy;
diff --git a/src/diff.c b/src/diff.c
index 41cfefe5e..ec8c8f175 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -559,14 +559,14 @@ diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
diff_T *dnew;
dnew = ALLOC_ONE(diff_T);
- if (dnew != NULL)
- {
- dnew->df_next = dp;
- if (dprev == NULL)
- tp->tp_first_diff = dnew;
- else
- dprev->df_next = dnew;
- }
+ if (dnew == NULL)
+ return NULL;
+
+ dnew->df_next = dp;
+ if (dprev == NULL)
+ tp->tp_first_diff = dnew;
+ else
+ dprev->df_next = dnew;
return dnew;
}
diff --git a/src/digraph.c b/src/digraph.c
index 88643e35f..97a72e1d5 100644
--- a/src/digraph.c
+++ b/src/digraph.c
@@ -1533,29 +1533,30 @@ get_digraph(
c = plain_vgetc();
--no_mapping;
--allow_keys;
- if (c != ESC) // ESC cancels CTRL-K
+
+ if (c == ESC) // ESC cancels CTRL-K
+ return NUL;
+
+ if (IS_SPECIAL(c)) // insert special key code
+ return c;
+ if (cmdline)
{
- if (IS_SPECIAL(c)) // insert special key code
- return c;
- if (cmdline)
- {
- if (char2cells(c) == 1
+ if (char2cells(c) == 1
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
- && cmdline_star == 0
+ && cmdline_star == 0
#endif
- )
- putcmdline(c, TRUE);
- }
- else
- add_to_showcmd(c);
- ++no_mapping;
- ++allow_keys;
- cc = plain_vgetc();
- --no_mapping;
- --allow_keys;
- if (cc != ESC) // ESC cancels CTRL-K
- return digraph_get(c, cc, TRUE);
+ )
+ putcmdline(c, TRUE);
}
+ else
+ add_to_showcmd(c);
+ ++no_mapping;
+ ++allow_keys;
+ cc = plain_vgetc();
+ --no_mapping;
+ --allow_keys;
+ if (cc != ESC) // ESC cancels CTRL-K
+ return digraph_get(c, cc, TRUE);
return NUL;
}
diff --git a/src/edit.c b/src/edit.c
index 4a89fe13f..983f1aca6 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -2970,12 +2970,12 @@ get_last_insert_save(void)
if (last_insert == NULL)
return NULL;
s = vim_strsave(last_insert + last_insert_skip);
- if (s != NULL)
- {
- len = (int)STRLEN(s);
- if (len > 0 && s[len - 1] == ESC) // remove trailing ESC
- s[len - 1] = NUL;
- }
+ if (s == NULL)
+ return NULL;
+
+ len = (int)STRLEN(s);
+ if (len > 0 && s[len - 1] == ESC) // remove trailing ESC
+ s[len - 1] = NUL;
return s;
}
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 274d0bdaa..0184d6177 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -2950,22 +2950,22 @@ internal_func_check_arg_types(
{
argcheck_T *argchecks = global_functions[idx].f_argcheck;
- if (argchecks != NULL)
- {
- argcontext_T context;
+ if (argchecks == NULL)
+ return OK;
- context.arg_count = argcount;
- context.arg_types = types;
- context.arg_cctx = cctx;
- for (int i = 0; i < argcount; ++i)
- if (argchecks[i] != NULL)
- {
- context.arg_idx = i;
- if (argchecks[i](types[i].type_curr, types[i].type_decl,
- &context) == FAIL)
- return FAIL;
- }
- }
+ argcontext_T context;
+
+ context.arg_count = argcount;
+ context.arg_types = types;
+ context.arg_cctx = cctx;
+ for (int i = 0; i < argcount; ++i)
+ if (argchecks[i] != NULL)
+ {
+ context.arg_idx = i;
+ if (argchecks[i](types[i].type_curr, types[i].type_decl,
+ &context) == FAIL)
+ return FAIL;
+ }
return OK;
}
@@ -3475,14 +3475,14 @@ get_optional_window(typval_T *argvars, int idx)
{
win_T *win = curwin;
- if (argvars[idx].v_type != VAR_UNKNOWN)
+ if (argvars[idx].v_type == VAR_UNKNOWN)
+ return curwin;
+
+ win = find_win_by_nr_or_id(&argvars[idx]);
+ if (win == NULL)
{
- win = find_win_by_nr_or_id(&argvars[idx]);
- if (win == NULL)
- {
- emsg(_(e_invalid_window_number));
- return NULL;
- }
+ emsg(_(e_invalid_window_number));
+ return NULL;
}
return win;
}
@@ -8624,43 +8624,43 @@ get_search_arg(typval_T *varp, int *flagsp)
char_u nbuf[NUMBUFLEN];
int mask;
- if (varp->v_type != VAR_UNKNOWN)
+ if (varp->v_type == VAR_UNKNOWN)
+ return FORWARD;
+
+ flags = tv_get_string_buf_chk(varp, nbuf);
+ if (flags == NULL)
+ return 0; // type error; errmsg already given
+ while (*flags != NUL)
{
- flags = tv_get_string_buf_chk(varp, nbuf);
- if (flags == NULL)
- return 0; // type error; errmsg already given
- while (*flags != NUL)
+ switch (*flags)
{
- switch (*flags)
- {
- case 'b': dir = BACKWARD; break;
- case 'w': p_ws = TRUE; break;
- case 'W': p_ws = FALSE; break;
- default: mask = 0;
- if (flagsp != NULL)
- switch (*flags)
- {
- case 'c': mask = SP_START; break;
- case 'e': mask = SP_END; break;
- case 'm': mask = SP_RETCOUNT; break;
- case 'n': mask = SP_NOMOVE; break;
- case 'p': mask = SP_SUBPAT; break;
- case 'r': mask = SP_REPEAT; break;
- case 's': mask = SP_SETPCMARK; break;
- case 'z': mask = SP_COLUMN; break;
- }
- if (mask == 0)
+ case 'b': dir = BACKWARD; break;
+ case 'w': p_ws = TRUE; break;
+ case 'W': p_ws = FALSE; break;
+ default: mask = 0;
+ if (flagsp != NULL)
+ switch (*flags)
{
- semsg(_(e_invalid_argument_str), flags);
- dir = 0;
+ case 'c': mask = SP_START; break;
+ case 'e': mask = SP_END; break;
+ case 'm': mask = SP_RETCOUNT; break;
+ case 'n': mask = SP_NOMOVE; break;
+ case 'p': mask = SP_SUBPAT; break;
+ case 'r': mask = SP_REPEAT; break;
+ case 's': mask = SP_SETPCMARK; break;
+ case 'z': mask = SP_COLUMN; break;
}
- else
- *flagsp |= mask;
- }
- if (dir == 0)
- break;
- ++flags;
+ if (mask == 0)
+ {
+ semsg(_(e_invalid_argument_str), flags);
+ dir = 0;
+ }
+ else
+ *flagsp |= mask;
}
+ if (dir == 0)
+ break;
+ ++flags;
}
return dir;
}
diff --git a/src/evalwindow.c b/src/evalwindow.c
index 8b47b98fd..fde90f256 100644
--- a/src/evalwindow.c
+++ b/src/evalwindow.c
@@ -24,29 +24,29 @@ win_getid(typval_T *argvars)
if (argvars[0].v_type == VAR_UNKNOWN)
return curwin->w_id;
winnr = tv_get_number(&argvars[0]);
- if (winnr > 0)
+ if (winnr <= 0)
+ return 0;
+
+ if (argvars[1].v_type == VAR_UNKNOWN)
+ wp = firstwin;
+ else
{
- if (argvars[1].v_type == VAR_UNKNOWN)
+ tabpage_T *tp;
+ int tabnr = tv_get_number(&argvars[1]);
+
+ FOR_ALL_TABPAGES(tp)
+ if (--tabnr == 0)
+ break;
+ if (tp == NULL)
+ return -1;
+ if (tp == curtab)
wp = firstwin;
else
- {
- tabpage_T *tp;
- int tabnr = tv_get_number(&argvars[1]);
-
- FOR_ALL_TABPAGES(tp)
- if (--tabnr == 0)
- break;
- if (tp == NULL)
- return -1;
- if (tp == curtab)
- wp = firstwin;
- else
- wp = tp->tp_firstwin;
- }
- for ( ; wp != NULL; wp = wp->w_next)
- if (--winnr == 0)
- return wp->w_id;
+ wp = tp->tp_firstwin;
}
+ for ( ; wp != NULL; wp = wp->w_next)
+ if (--winnr == 0)
+ return wp->w_id;
return 0;
}
@@ -380,18 +380,20 @@ get_winnr(tabpage_T *tp, typval_T *argvar)
}
}
- if (nr > 0)
- for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
- wp != twin; wp = wp->w_next)
+ if (nr <= 0)
+ return 0;
+
+ for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
+ wp != twin; wp = wp->w_next)
+ {
+ if (wp == NULL)
{
- if (wp == NULL)
- {
- // didn't find it in this tabpage
- nr = 0;
- break;
- }
- ++nr;
+ // didn't find it in this tabpage
+ nr = 0;
+ break;
}
+ ++nr;
+ }
return nr;
}
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index faff4aada..32c72879c 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5279,67 +5279,67 @@ prepare_tagpreview(
need_mouse_correct = TRUE;
# endif
+ if (curwin->w_p_pvw)
+ return FALSE;
+
/*
* If there is already a preview window open, use that one.
*/
- if (!curwin->w_p_pvw)
- {
# ifdef FEAT_PROP_POPUP
- if (use_previewpopup && *p_pvp != NUL)
- {
- wp = popup_find_preview_window();
- if (wp != NULL)
- popup_set_wantpos_cursor(wp, wp->w_minwidth, NULL);
- }
- else if (use_popup != USEPOPUP_NONE)
+ if (use_previewpopup && *p_pvp != NUL)
+ {
+ wp = popup_find_preview_window();
+ if (wp != NULL)
+ popup_set_wantpos_cursor(wp, wp->w_minwidth, NULL);
+ }
+ else if (use_popup != USEPOPUP_NONE)
+ {
+ wp = popup_find_info_window();
+ if (wp != NULL)
{
- wp = popup_find_info_window();
- if (wp != NULL)
- {
- if (use_popup == USEPOPUP_NORMAL)
- popup_show(wp);
- else
- popup_hide(wp);
- // When the popup moves or resizes it may reveal part of
- // another window. TODO: can this be done more efficiently?
- redraw_all_later(UPD_NOT_VALID);
- }
+ if (use_popup == USEPOPUP_NORMAL)
+ popup_show(wp);
+ else
+ popup_hide(wp);
+ // When the popup moves or resizes it may reveal part of
+ // another window. TODO: can this be done more efficiently?
+ redraw_all_later(UPD_NOT_VALID);
}
- else
+ }
+ else
# endif
- {
- FOR_ALL_WINDOWS(wp)
- if (wp->w_p_pvw)
- break;
- }
- if (wp != NULL)
- win_enter(wp, undo_sync);
- else
- {
- /*
- * There is no preview window open yet. Create one.
- */
+ {
+ FOR_ALL_WINDOWS(wp)
+ if (wp->w_p_pvw)
+ break;
+ }
+ if (wp != NULL)
+ {
+ win_enter(wp, undo_sync);
+ return FALSE;
+ }
+
+ /*
+ * There is no preview window open yet. Create one.
+ */
# ifdef FEAT_PROP_POPUP
- if ((use_previewpopup && *p_pvp != NUL)
- || use_popup != USEPOPUP_NONE)
- return popup_create_preview_window(use_popup != USEPOPUP_NONE);
+ if ((use_previewpopup && *p_pvp != NUL)
+ || use_popup != USEPOPUP_NONE)
+ return popup_create_preview_window(use_popup != USEPOPUP_NONE);
# endif
- if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL)
- return FALSE;
- curwin->w_p_pvw = TRUE;
- curwin->w_p_wfh = TRUE;
- RESET_BINDING(curwin); // don't take over 'scrollbind'
- // and 'cursorbind'
+ if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL)
+ return FALSE;
+ curwin->w_p_pvw = TRUE;
+ curwin->w_p_wfh = TRUE;
+ RESET_BINDING(curwin); // don't take over 'scrollbind'
+ // and 'cursorbind'
# ifdef FEAT_DIFF
- curwin->w_p_diff = FALSE; // no 'diff'
+ curwin->w_p_diff = FALSE; // no 'diff'
# endif
# ifdef FEAT_FOLDING
- curwin->w_p_fdc = 0; // no 'foldcolumn'
+ curwin->w_p_fdc = 0; // no 'foldcolumn'
# endif
- return TRUE;
- }
- }
- return FALSE;
+ return TRUE;
}
#endif
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index c52c227de..567b839cd 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -828,40 +828,40 @@ requires_py_version(char_u *filename)
lines = 5;
file = mch_fopen((char *)filename, "r");
- if (file != NULL)
+ if (file == NULL)
+ return 0;
+
+ for (i = 0; i < lines; i++)
{
- for (i = 0; i < lines; i++)
+ if (vim_fgets(IObuff, IOSIZE, file))
+ break;
+ if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!')
{
- if (vim_fgets(IObuff, IOSIZE, file))
- break;
- if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!')
- {
- // Check shebang.
- if (strstr((char *)IObuff + 2, "python2") != NULL)
- {
- requires_py_version = 2;
- break;
- }
- if (strstr((char *)IObuff + 2, "python3") != NULL)
- {
- requires_py_version = 3;
- break;
- }
- }
- IObuff[21] = '\0';
- if (STRCMP("# requires python 2.x", IObuff) == 0)
+ // Check shebang.
+ if (strstr((char *)IObuff + 2, "python2") != NULL)
{
requires_py_version = 2;
break;
}
- if (STRCMP("# requires python 3.x", IObuff) == 0)
+ if (strstr((char *)IObuff + 2, "python3") != NULL)
{
requires_py_version = 3;
break;
}
}
- fclose(file);
+ IObuff[21] = '\0';
+ if (STRCMP("# requires python 2.x", IObuff) == 0)
+ {
+ requires_py_version = 2;
+ break;
+ }
+ if (STRCMP("# requires python 3.x", IObuff) == 0)
+ {
+ requires_py_version = 3;
+ break;
+ }
}
+ fclose(file);
return requires_py_version;
}
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 49331c417..2407bceb1 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4146,16 +4146,16 @@ get_cmdline_completion(void)
return NULL;
p = get_ccline_ptr();
- if (p != NULL && p->xpc != NULL)
- {
- char_u *cmd_compl;
+ if (p == NULL || p->xpc == NULL)
+ return NULL;
- set_expand_context(p->xpc);
+ char_u *cmd_compl;
- cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context);
- if (cmd_compl != NULL)
- return vim_strsave(cmd_compl);
- }
+ set_expand_context(p->xpc);
+
+ cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context);
+ if (cmd_compl != NULL)
+ return vim_strsave(cmd_compl);
return NULL;
}
diff --git a/src/filepath.c b/src/filepath.c
index 023c7322f..be1a5810a 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -3084,13 +3084,13 @@ concat_fnames(char_u *fname1, char_u *fname2, int sep)
char_u *dest;
dest = alloc(STRLEN(fname1) + STRLEN(fname2) + 3);
- if (dest != NULL)
- {
- STRCPY(dest, fname1);
- if (sep)
- add_pathsep(dest);
- STRCAT(dest, fname2);
- }
+ if (dest == NULL)
+ return NULL;
+
+ STRCPY(dest, fname1);
+ if (sep)
+ add_pathsep(dest);
+ STRCAT(dest, fname2);
return dest;
}
@@ -3122,14 +3122,14 @@ FullName_save(
return NULL;
buf = alloc(MAXPATHL);
- if (buf != NULL)
- {
- if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
- new_fname = vim_strsave(buf);
- else
- new_fname = vim_strsave(fname);
- vim_free(buf);
- }
+ if (buf == NULL)
+ return NULL;
+
+ if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
+ new_fname = vim_strsave(buf);
+ else
+ new_fname = vim_strsave(fname);
+ vim_free(buf);
return new_fname;
}
diff --git a/src/findfile.c b/src/findfile.c
index 017e1c662..ea07a89ed 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -1345,33 +1345,32 @@ ff_check_visited(
* New file/dir. Add it to the list of visited files/dirs.
*/
vp = alloc(sizeof(ff_visited_T) + STRLEN(ff_expand_buffer));
+ if (vp == NULL)
+ return OK;
- if (vp != NULL)
- {
#ifdef UNIX
- if (!url)
- {
- vp->ffv_dev_valid = TRUE;
- vp->ffv_ino = st.st_ino;
- vp->ffv_dev = st.st_dev;
- vp->ffv_fname[0] = NUL;
- }
- else
- {
- vp->ffv_dev_valid = FALSE;
+ if (!url)
+ {
+ vp->ffv_dev_valid = TRUE;
+ vp->ffv_ino = st.st_ino;
+ vp->ffv_dev = st.st_dev;
+ vp->ffv_fname[0] = NUL;
+ }
+ else
+ {
+ vp->ffv_dev_valid = FALSE;
#endif
- STRCPY(vp->ffv_fname, ff_expand_buffer);
+ STRCPY(vp->ffv_fname, ff_expand_buffer);
#ifdef UNIX
- }
+ }
#endif
- if (wc_path != NULL)
- vp->ffv_wc_path = vim_strsave(wc_path);
- else
- vp->ffv_wc_path = NULL;
+ if (wc_path != NULL)
+ vp->ffv_wc_path = vim_strsave(wc_path);
+ else
+ vp->ffv_wc_path = NULL;
- vp->ffv_next = *visited_list;
- *visited_list = vp;
- }
+ vp->ffv_next = *visited_list;
+ *visited_list = vp;
return OK;
}
diff --git a/src/fold.c b/src/fold.c
index 61bffb5d0..589727d98 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -516,7 +516,7 @@ foldCheckClose(void)
if (*p_fcl == NUL)
return;
- // can only be "all" right now
+ // 'foldclose' can only be "all" right now
checkupdate(curwin);
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
(int)curwin->w_p_fdl))
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 9d114c587..da3879b8c 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -334,35 +334,35 @@ prt_get_attr(
static void
prt_set_fg(long_u fg)
{
- if (fg != curr_fg)
- {
- curr_fg = fg;
- mch_print_set_fg(fg);
- }
+ if (fg == curr_fg)
+ return;
+
+ curr_fg = fg;
+ mch_print_set_fg(fg);
}
static void
prt_set_bg(long_u bg)
{
- if (bg != curr_bg)
- {
- curr_bg = bg;
- mch_print_set_bg(bg);
- }
+ if (bg == curr_bg)
+ return;
+
+ curr_bg = bg;
+ mch_print_set_bg(bg);
}
static void
prt_set_font(int bold, int italic, int underline)
{
- if (curr_bold != bold
- || curr_italic != italic
- || curr_underline != underline)
- {
- curr_underline = underline;
- curr_italic = italic;
- curr_bold = bold;
- mch_print_set_font(bold, italic, underline);
- }
+ if (curr_bold == bold
+ && curr_italic == italic
+ && curr_underline == underline)
+ return;
+
+ curr_underline = underline;
+ curr_italic = italic;
+ curr_bold = bold;
+ mch_print_set_font(bold, italic, underline);
}
/*
@@ -434,13 +434,15 @@ prt_get_unit(int idx)
int i;
static char *(units[4]) = PRT_UNIT_NAMES;
- if (printer_opts[idx].present)
- for (i = 0; i < 4; ++i)
- if (STRNICMP(printer_opts[idx].string, units[i], 2) == 0)
- {
- u = i;
- break;
- }
+ if (!printer_opts[idx].present)
+ return PRT_UNIT_NONE;
+
+ for (i = 0; i < 4; ++i)
+ if (STRNICMP(printer_opts[idx].string, units[i], 2) == 0)
+ {
+ u = i;
+ break;
+ }
return u;
}
@@ -1574,75 +1576,75 @@ prt_def_var(char *name, double value, int prec)
static void
prt_flush_buffer(void)
{
- if (prt_ps_buffer.ga_len > 0)
- {
- // Any background color must be drawn first
- if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE))
- {
- int r, g, b;
-
- if (prt_do_moveto)
- {
- prt_write_real(prt_pos_x_moveto, 2);
- prt_write_real(prt_pos_y_moveto, 2);
- prt_write_string("m\n");
- prt_do_moveto = FALSE;
- }
+ if (prt_ps_buffer.ga_len <= 0)
+ return;
- // Size of rect of background color on which text is printed
- prt_write_real(prt_text_run, 2);
- prt_write_real(prt_line_height, 2);
+ // Any background color must be drawn first
+ if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE))
+ {
+ int r, g, b;
- // Lastly add the color of the background
- r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
- g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
- b = prt_new_bgcol & 0xff;
- prt_write_real(r / 255.0, 3);
- prt_write_real(g / 255.0, 3);
- prt_write_real(b / 255.0, 3);
- prt_write_string("bg\n");
- }
- // Draw underlines before the text as it makes it slightly easier to
- // find the starting point.
- if (prt_do_underline)
+ if (prt_do_moveto)
{
- if (prt_do_moveto)
- {
- prt_write_real(prt_pos_x_moveto, 2);
- prt_write_real(prt_pos_y_moveto, 2);
- prt_write_string("m\n");
- prt_do_moveto = FALSE;
- }
-
- // Underline length of text run
- prt_write_real(prt_text_run, 2);
- prt_write_string("ul\n");
+ prt_write_real(prt_pos_x_moveto, 2);
+ prt_write_real(prt_pos_y_moveto, 2);
+ prt_write_string("m\n");
+ prt_do_moveto = FALSE;
}
- // Draw the text
- if (prt_out_mbyte)
- prt_write_string("<");
- else
- prt_write_string("(");
- prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
- if (prt_out_mbyte)
- prt_write_string(">");
- else
- prt_write_string(")");
- // Add a moveto if need be and use the appropriate show procedure
+
+ // Size of rect of background color on which text is printed
+ prt_write_real(prt_text_run, 2);
+ prt_write_real(prt_line_height, 2);
+
+ // Lastly add the color of the background
+ r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
+ g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
+ b = prt_new_bgcol & 0xff;
+ prt_write_real(r / 255.0, 3);
+ prt_write_real(g / 255.0, 3);
+ prt_write_real(b / 255.0, 3);
+ prt_write_string("bg\n");
+ }
+ // Draw underlines before the text as it makes it slightly easier to
+ // find the starting point.
+ if (prt_do_underline)
+ {
if (prt_do_moveto)
{
prt_write_real(prt_pos_x_moveto, 2);
prt_write_real(prt_pos_y_moveto, 2);
- // moveto and a show
- prt_write_string("ms\n");
+ prt_write_string("m\n");
prt_do_moveto = FALSE;
}
- else // Simple show
- prt_write_string("s\n");
- ga_clear(&prt_ps_buffer);
- ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz);
+ // Underline length of text run
+ prt_write_real(prt_text_run, 2);
+ prt_write_string("ul\n");
}
+ // Draw the text
+ if (prt_out_mbyte)
+ prt_write_string("<");
+ else
+ prt_write_string("(");
+ prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
+ if (prt_out_mbyte)
+ prt_write_string(">");
+ else
+ prt_write_string(")");
+ // Add a moveto if need be and use the appropriate show procedure
+ if (prt_do_moveto)
+ {
+ prt_write_real(prt_pos_x_moveto, 2);
+ prt_write_real(prt_pos_y_moveto, 2);
+ // moveto and a show
+ prt_write_string("ms\n");
+ prt_do_moveto = FALSE;
+ }
+ else // Simple show
+ prt_write_string("s\n");
+
+ ga_clear(&prt_ps_buffer);
+ ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz);
}
@@ -3447,12 +3449,12 @@ mch_print_set_bg(long_u bgcol)
void
mch_print_set_fg(long_u fgcol)
{
- if (fgcol != (long_u)prt_fgcol)
- {
- prt_fgcol = (int)fgcol;
- prt_attribute_change = TRUE;
- prt_need_fgcol = TRUE;
- }
+ if (fgcol == (long_u)prt_fgcol)
+ return;
+
+ prt_fgcol = (int)fgcol;
+ prt_attribute_change = TRUE;
+ prt_need_fgcol = TRUE;
}
# endif //FEAT_POSTSCRIPT
diff --git a/src/highlight.c b/src/highlight.c
index 41cb816da..79501d2b2 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -921,93 +921,113 @@ highlight_set_font(
#endif
/*
+ * Set the cterm foreground color for the Normal highlight group to "color" and
+ * the bold attribute to "bold".
+ */
+ static void
+hl_set_ctermfg_normal_group(int color, int bold)
+{
+ cterm_normal_fg_color = color + 1;
+ cterm_normal_fg_bold = bold;
+#ifdef FEAT_GUI
+ // Don't do this if the GUI is used.
+ if (!gui.in_use && !gui.starting)
+#endif
+ {
+ set_must_redraw(UPD_CLEAR);
+ if (termcap_active && color >= 0)
+ term_fg_color(color);
+ }
+}
+
+/*
* Set the cterm foreground color for the highlight group at 'idx' to 'color'.
- * Returns TRUE if the foreground color is set.
*/
static void
highlight_set_ctermfg(int idx, int color, int is_normal_group)
{
HL_TABLE()[idx].sg_cterm_fg = color + 1;
if (is_normal_group)
- {
- cterm_normal_fg_color = color + 1;
- cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD);
+ hl_set_ctermfg_normal_group(color,
+ (HL_TABLE()[idx].sg_cterm & HL_BOLD));
+}
+
+/*
+ * Set the cterm background color for the Normal highlight group to "color".
+ */
+ static void
+hl_set_ctermbg_normal_group(int color)
+{
+ cterm_normal_bg_color = color + 1;
#ifdef FEAT_GUI
- // Don't do this if the GUI is used.
- if (!gui.in_use && !gui.starting)
+ // Don't mess with 'background' if the GUI is used.
+ if (!gui.in_use && !gui.starting)
#endif
+ {
+ set_must_redraw(UPD_CLEAR);
+ if (color >= 0)
{
- set_must_redraw(UPD_CLEAR);
- if (termcap_active && color >= 0)
- term_fg_color(color);
+ int dark = -1;
+
+ if (termcap_active)
+ term_bg_color(color);
+ if (t_colors < 16)
+ dark = (color == 0 || color == 4);
+ // Limit the heuristic to the standard 16 colors
+ else if (color < 16)
+ dark = (color < 7 || color == 8);
+ // Set the 'background' option if the value is
+ // wrong.
+ if (dark != -1
+ && dark != (*p_bg == 'd')
+ && !option_was_set((char_u *)"bg"))
+ {
+ set_option_value_give_err((char_u *)"bg",
+ 0L, (char_u *)(dark ? "dark" : "light"), 0);
+ reset_option_was_set((char_u *)"bg");
+ }
}
}
}
/*
* Set the cterm background color for the highlight group at 'idx' to 'color'.
- * Returns TRUE if the background color is set.
*/
static void
highlight_set_ctermbg(int idx, int color, int is_normal_group)
{
HL_TABLE()[idx].sg_cterm_bg = color + 1;
if (is_normal_group)
- {
- cterm_normal_bg_color = color + 1;
+ hl_set_ctermbg_normal_group(color);
+}
+
+/*
+ * Set the cterm underline color for the Normal highlight group to "color".
+ */
+ static void
+hl_set_ctermul_normal_group(int color)
+{
+ cterm_normal_ul_color = color + 1;
#ifdef FEAT_GUI
- // Don't mess with 'background' if the GUI is used.
- if (!gui.in_use && !gui.starting)
+ // Don't do this if the GUI is used.
+ if (!gui.in_use && !gui.starting)
#endif
- {
- set_must_redraw(UPD_CLEAR);
- if (color >= 0)
- {
- int dark = -1;
-
- if (termcap_active)
- term_bg_color(color);
- if (t_colors < 16)
- dark = (color == 0 || color == 4);
- // Limit the heuristic to the standard 16 colors
- else if (color < 16)
- dark = (color < 7 || color == 8);
- // Set the 'background' option if the value is
- // wrong.
- if (dark != -1
- && dark != (*p_bg == 'd')
- && !option_was_set((char_u *)"bg"))
- {
- set_option_value_give_err((char_u *)"bg",
- 0L, (char_u *)(dark ? "dark" : "light"), 0);
- reset_option_was_set((char_u *)"bg");
- }
- }
- }
+ {
+ set_must_redraw(UPD_CLEAR);
+ if (termcap_active && color >= 0)
+ term_ul_color(color);
}
}
/*
* Set the cterm underline color for the highlight group at 'idx' to 'color'.
- * Returns TRUE if the underline color is set.
*/
static void
highlight_set_ctermul(int idx, int color, int is_normal_group)
{
HL_TABLE()[idx].sg_cterm_ul = color + 1;
if (is_normal_group)
- {
- cterm_normal_ul_color = color + 1;
-#ifdef FEAT_GUI
- // Don't do this if the GUI is used.
- if (!gui.in_use && !gui.starting)
-#endif
- {
- set_must_redraw(UPD_CLEAR);
- if (termcap_active && color >= 0)
- term_ul_color(color);
- }
- }
+ hl_set_ctermul_normal_group(color);
}
/*
@@ -1034,90 +1054,90 @@ highlight_set_cterm_color(
long i;
int off;
- if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM))
+ if (init && (HL_TABLE()[idx].sg_set & SG_CTERM))
+ return FALSE;
+
+ if (!init)
+ HL_TABLE()[idx].sg_set |= SG_CTERM;
+
+ // When setting the foreground color, and previously the "bold"
+ // flag was set for a light color, reset it now
+ if (key[5] == 'F' && HL_TABLE()[idx].sg_cterm_bold)
{
- if (!init)
- HL_TABLE()[idx].sg_set |= SG_CTERM;
+ HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
+ HL_TABLE()[idx].sg_cterm_bold = FALSE;
+ }
- // When setting the foreground color, and previously the "bold"
- // flag was set for a light color, reset it now
- if (key[5] == 'F' && HL_TABLE()[idx].sg_cterm_bold)
+ if (VIM_ISDIGIT(*arg))
+ color = atoi((char *)arg);
+ else if (STRICMP(arg, "fg") == 0)
+ {
+ if (cterm_normal_fg_color)
+ color = cterm_normal_fg_color - 1;
+ else
{
- HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
- HL_TABLE()[idx].sg_cterm_bold = FALSE;
+ emsg(_(e_fg_color_unknown));
+ return FALSE;
}
-
- if (VIM_ISDIGIT(*arg))
- color = atoi((char *)arg);
- else if (STRICMP(arg, "fg") == 0)
+ }
+ else if (STRICMP(arg, "bg") == 0)
+ {
+ if (cterm_normal_bg_color > 0)
+ color = cterm_normal_bg_color - 1;
+ else
{
- if (cterm_normal_fg_color)
- color = cterm_normal_fg_color - 1;
- else
- {
- emsg(_(e_fg_color_unknown));
- return FALSE;
- }
+ emsg(_(e_bg_color_unknown));
+ return FALSE;
}
- else if (STRICMP(arg, "bg") == 0)
+ }
+ else if (STRICMP(arg, "ul") == 0)
+ {
+ if (cterm_normal_ul_color > 0)
+ color = cterm_normal_ul_color - 1;
+ else
{
- if (cterm_normal_bg_color > 0)
- color = cterm_normal_bg_color - 1;
- else
- {
- emsg(_(e_bg_color_unknown));
- return FALSE;
- }
+ emsg(_(e_ul_color_unknown));
+ return FALSE;
}
- else if (STRICMP(arg, "ul") == 0)
+ }
+ else
+ {
+ int bold = MAYBE;
+
+ // reduce calls to STRICMP a bit, it can be slow
+ off = TOUPPER_ASC(*arg);
+ for (i = ARRAY_LENGTH(color_names); --i >= 0; )
+ if (off == color_names[i][0]
+ && STRICMP(arg + 1, color_names[i] + 1) == 0)
+ break;
+ if (i < 0)
{
- if (cterm_normal_ul_color > 0)
- color = cterm_normal_ul_color - 1;
- else
- {
- emsg(_(e_ul_color_unknown));
- return FALSE;
- }
+ semsg(_(e_color_name_or_number_not_recognized_str), key_start);
+ return FALSE;
}
- else
- {
- int bold = MAYBE;
-
- // reduce calls to STRICMP a bit, it can be slow
- off = TOUPPER_ASC(*arg);
- for (i = ARRAY_LENGTH(color_names); --i >= 0; )
- if (off == color_names[i][0]
- && STRICMP(arg + 1, color_names[i] + 1) == 0)
- break;
- if (i < 0)
- {
- semsg(_(e_color_name_or_number_not_recognized_str), key_start);
- return FALSE;
- }
- color = lookup_color(i, key[5] == 'F', &bold);
+ color = lookup_color(i, key[5] == 'F', &bold);
- // set/reset bold attribute to get light foreground
- // colors (on some terminals, e.g. "linux")
- if (bold == TRUE)
- {
- HL_TABLE()[idx].sg_cterm |= HL_BOLD;
- HL_TABLE()[idx].sg_cterm_bold = TRUE;
- }
- else if (bold == FALSE)
- HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
+ // set/reset bold attribute to get light foreground
+ // colors (on some terminals, e.g. "linux")
+ if (bold == TRUE)
+ {
+ HL_TABLE()[idx].sg_cterm |= HL_BOLD;
+ HL_TABLE()[idx].sg_cterm_bold = TRUE;
}
-
- // Add one to the argument, to avoid zero. Zero is used for
- // "NONE", then "color" is -1.
- if (key[5] == 'F')
- highlight_set_ctermfg(idx, color, is_normal_group);
- else if (key[5] == 'B')
- highlight_set_ctermbg(idx, color, is_normal_group);
- else // ctermul
- highlight_set_ctermul(idx, color, is_normal_group);
+ else if (bold == FALSE)
+ HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
}
+ // Add one to the argument, to avoid zero. Zero is used for
+ // "NONE", then "color" is -1.
+ if (key[5] == 'F')
+ highlight_set_ctermfg(idx, color, is_normal_group);
+ else if (key[5] == 'B')
+ highlight_set_ctermbg(idx, color, is_normal_group);
+ else // ctermul
+ highlight_set_ctermul(idx, color, is_normal_group);
+
return TRUE;
}
@@ -1142,51 +1162,51 @@ highlight_set_guifg(
char_u **namep;
int did_change = FALSE;
+ if (init && (HL_TABLE()[idx].sg_set & SG_GUI))
+ return FALSE;
+
namep = &HL_TABLE()[idx].sg_gui_fg_name;
- if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
- {
- if (!init)
- HL_TABLE()[idx].sg_set |= SG_GUI;
+ if (!init)
+ HL_TABLE()[idx].sg_set |= SG_GUI;
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
- // In GUI guifg colors are only used when recognized
- i = color_name2handle(arg);
- if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
- {
- HL_TABLE()[idx].sg_gui_fg = i;
+ // In GUI guifg colors are only used when recognized
+ i = color_name2handle(arg);
+ if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
+ {
+ HL_TABLE()[idx].sg_gui_fg = i;
# endif
- if (*namep == NULL || STRCMP(*namep, arg) != 0)
- {
- vim_free(*namep);
- if (STRCMP(arg, "NONE") != 0)
- *namep = vim_strsave(arg);
- else
- *namep = NULL;
- did_change = TRUE;
- }
+ if (*namep == NULL || STRCMP(*namep, arg) != 0)
+ {
+ vim_free(*namep);
+ if (STRCMP(arg, "NONE") != 0)
+ *namep = vim_strsave(arg);
+ else
+ *namep = NULL;
+ did_change = TRUE;
+ }
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_X11
- if (is_menu_group && gui.menu_fg_pixel != i)
- {
- gui.menu_fg_pixel = i;
- *do_colors = TRUE;
- }
- if (is_scrollbar_group && gui.scroll_fg_pixel != i)
- {
- gui.scroll_fg_pixel = i;
- *do_colors = TRUE;
- }
+ if (is_menu_group && gui.menu_fg_pixel != i)
+ {
+ gui.menu_fg_pixel = i;
+ *do_colors = TRUE;
+ }
+ if (is_scrollbar_group && gui.scroll_fg_pixel != i)
+ {
+ gui.scroll_fg_pixel = i;
+ *do_colors = TRUE;
+ }
# ifdef FEAT_BEVAL_GUI
- if (is_tooltip_group && gui.tooltip_fg_pixel != i)
- {
- gui.tooltip_fg_pixel = i;
- *do_colors = TRUE;
- }
+ if (is_tooltip_group && gui.tooltip_fg_pixel != i)
+ {
+ gui.tooltip_fg_pixel = i;
+ *do_colors = TRUE;
+ }
# endif
# endif
- }
-# endif
}
+# endif
return did_change;
}
@@ -1211,51 +1231,51 @@ highlight_set_guibg(
char_u **namep;
int did_change = FALSE;
+ if (init && (HL_TABLE()[idx].sg_set & SG_GUI))
+ return FALSE;
+
namep = &HL_TABLE()[idx].sg_gui_bg_name;
- if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
- {
- if (!init)
- HL_TABLE()[idx].sg_set |= SG_GUI;
+ if (!init)
+ HL_TABLE()[idx].sg_set |= SG_GUI;
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
- // In GUI guibg colors are only used when recognized
- i = color_name2handle(arg);
- if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
- {
- HL_TABLE()[idx].sg_gui_bg = i;
+ // In GUI guibg colors are only used when recognized
+ i = color_name2handle(arg);
+ if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
+ {
+ HL_TABLE()[idx].sg_gui_bg = i;
# endif
- if (*namep == NULL || STRCMP(*namep, arg) != 0)
- {
- vim_free(*namep);
- if (STRCMP(arg, "NONE") != 0)
- *namep = vim_strsave(arg);
- else
- *namep = NULL;
- did_change = TRUE;
- }
+ if (*namep == NULL || STRCMP(*namep, arg) != 0)
+ {
+ vim_free(*namep);
+ if (STRCMP(arg, "NONE") != 0)
+ *namep = vim_strsave(arg);
+ else
+ *namep = NULL;
+ did_change = TRUE;
+ }
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_X11
- if (is_menu_group && gui.menu_bg_pixel != i)
- {
- gui.menu_bg_pixel = i;
- *do_colors = TRUE;
- }
- if (is_scrollbar_group && gui.scroll_bg_pixel != i)
- {
- gui.scroll_bg_pixel = i;
- *do_colors = TRUE;
- }
+ if (is_menu_group && gui.menu_bg_pixel != i)
+ {
+ gui.menu_bg_pixel = i;
+ *do_colors = TRUE;
+ }
+ if (is_scrollbar_group && gui.scroll_bg_pixel != i)
+ {
+ gui.scroll_bg_pixel = i;
+ *do_colors = TRUE;
+ }
# ifdef FEAT_BEVAL_GUI
- if (is_tooltip_group && gui.tooltip_bg_pixel != i)
- {
- gui.tooltip_bg_pixel = i;
- *do_colors = TRUE;
- }
+ if (is_tooltip_group && gui.tooltip_bg_pixel != i)
+ {
+ gui.tooltip_bg_pixel = i;
+ *do_colors = TRUE;
+ }
# endif
# endif
- }
-# endif
}
+# endif
return did_change;
}
@@ -1273,32 +1293,32 @@ highlight_set_guisp(int idx, char_u *arg, int init)
int did_change = FALSE;
char_u **namep;
+ if (init && (HL_TABLE()[idx].sg_set & SG_GUI))
+ return FALSE;
+
namep = &HL_TABLE()[idx].sg_gui_sp_name;
- if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
- {
- if (!init)
- HL_TABLE()[idx].sg_set |= SG_GUI;
+ if (!init)
+ HL_TABLE()[idx].sg_set |= SG_GUI;
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
- // In GUI guisp colors are only used when recognized
- i = color_name2handle(arg);
- if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
- {
- HL_TABLE()[idx].sg_gui_sp = i;
+ // In GUI guisp colors are only used when recognized
+ i = color_name2handle(arg);
+ if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
+ {
+ HL_TABLE()[idx].sg_gui_sp = i;
# endif
- if (*namep == NULL || STRCMP(*namep, arg) != 0)
- {
- vim_free(*namep);
- if (STRCMP(arg, "NONE") != 0)
- *namep = vim_strsave(arg);
- else
- *namep = NULL;
- did_change = TRUE;
- }
-# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+ if (*namep == NULL || STRCMP(*namep, arg) != 0)
+ {
+ vim_free(*namep);
+ if (STRCMP(arg, "NONE") != 0)
+ *namep = vim_strsave(arg);
+ else
+ *namep = NULL;
+ did_change = TRUE;
}
-# endif
+# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
}
+# endif
return did_change;
}
@@ -1995,21 +2015,20 @@ set_group_colors(
int idx;
idx = syn_name2id(name) - 1;
- if (idx >= 0)
- {
- gui_do_one_color(idx, do_menu, do_tooltip);
-
- if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR)
- *fgp = HL_TABLE()[idx].sg_gui_fg;
- else if (use_norm)
- *fgp = gui.def_norm_pixel;
- if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR)
- *bgp = HL_TABLE()[idx].sg_gui_bg;
- else if (use_norm)
- *bgp = gui.def_back_pixel;
- return TRUE;
- }
- return FALSE;
+ if (idx < 0)
+ return FALSE;
+
+ gui_do_one_color(idx, do_menu, do_tooltip);
+
+ if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR)
+ *fgp = HL_TABLE()[idx].sg_gui_fg;
+ else if (use_norm)
+ *fgp = gui.def_norm_pixel;
+ if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR)
+ *bgp = HL_TABLE()[idx].sg_gui_bg;
+ else if (use_norm)
+ *bgp = gui.def_back_pixel;
+ return TRUE;
}
/*
@@ -2042,11 +2061,11 @@ hl_set_font_name(char_u *font_name)
int id;
id = syn_name2id((char_u *)"Normal");
- if (id > 0)
- {
- vim_free(HL_TABLE()[id - 1].sg_font_name);
- HL_TABLE()[id - 1].sg_font_name = vim_strsave(font_name);
- }
+ if (id <= 0)
+ return;
+
+ vim_free(HL_TABLE()[id - 1].sg_font_name);
+ HL_TABLE()[id - 1].sg_font_name = vim_strsave(font_name);
}
/*
@@ -2059,15 +2078,15 @@ hl_set_bg_color_name(
{
int id;
- if (name != NULL)
- {
- id = syn_name2id((char_u *)"Normal");
- if (id > 0)
- {
- vim_free(HL_TABLE()[id - 1].sg_gui_bg_name);
- HL_TABLE()[id - 1].sg_gui_bg_name = name;
- }
- }
+ if (name == NULL)
+ return;
+
+ id = syn_name2id((char_u *)"Normal");
+ if (id <= 0)
+ return;
+
+ vim_free(HL_TABLE()[id - 1].sg_gui_bg_name);
+ HL_TABLE()[id - 1].sg_gui_bg_name = name;
}
/*
@@ -2080,15 +2099,15 @@ hl_set_fg_color_name(
{
int id;
- if (name != NULL)
- {
- id = syn_name2id((char_u *)"Normal");
- if (id > 0)
- {
- vim_free(HL_TABLE()[id - 1].sg_gui_fg_name);
- HL_TABLE()[id - 1].sg_gui_fg_name = name;
- }
- }
+ if (name == NULL)
+ return;
+
+ id = syn_name2id((char_u *)"Normal");
+ if (id <= 0)
+ return;
+
+ vim_free(HL_TABLE()[id - 1].sg_gui_fg_name);
+ HL_TABLE()[id - 1].sg_gui_fg_name = name;
}
/*
@@ -2973,40 +2992,41 @@ highlight_list_arg(
if (got_int)
return FALSE;
- if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0))
+
+ if (type == LIST_STRING ? (sarg == NULL) : (iarg == 0))
+ return didh;
+
+ ts = buf;
+ if (type == LIST_INT)
+ sprintf((char *)buf, "%d", iarg - 1);
+ else if (type == LIST_STRING)
+ ts = sarg;
+ else // type == LIST_ATTR
{
- ts = buf;
- if (type == LIST_INT)
- sprintf((char *)buf, "%d", iarg - 1);
- else if (type == LIST_STRING)
- ts = sarg;
- else // type == LIST_ATTR
+ buf[0] = NUL;
+ for (i = 0; hl_attr_table[i] != 0; ++i)
{
- buf[0] = NUL;
- for (i = 0; hl_attr_table[i] != 0; ++i)
+ if (iarg & hl_attr_table[i])
{
- if (iarg & hl_attr_table[i])
- {
- if (buf[0] != NUL)
- vim_strcat(buf, (char_u *)",", MAX_ATTR_LEN);
- vim_strcat(buf, (char_u *)hl_name_table[i], MAX_ATTR_LEN);
- iarg &= ~hl_attr_table[i]; // don't want "inverse"
- }
+ if (buf[0] != NUL)
+ vim_strcat(buf, (char_u *)",", MAX_ATTR_LEN);
+ vim_strcat(buf, (char_u *)hl_name_table[i], MAX_ATTR_LEN);
+ iarg &= ~hl_attr_table[i]; // don't want "inverse"
}
}
+ }
- (void)syn_list_header(didh,
- (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
- didh = TRUE;
- if (!got_int)
+ (void)syn_list_header(didh,
+ (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
+ didh = TRUE;
+ if (!got_int)
+ {
+ if (*name != NUL)
{
- if (*name != NUL)
- {
- msg_puts_attr(name, HL_ATTR(HLF_D));
- msg_puts_attr("=", HL_ATTR(HLF_D));
- }
- msg_outtrans(ts);
+ msg_puts_attr(name, HL_ATTR(HLF_D));
+ msg_puts_attr("=", HL_ATTR(HLF_D));
}
+ msg_outtrans(ts);
}
return didh;
}
@@ -3380,11 +3400,11 @@ syn_namen2id(char_u *linep, int len)
int id = 0;
name = vim_strnsave(linep, len);
- if (name != NULL)
- {
- id = syn_name2id(name);
- vim_free(name);
- }
+ if (name == NULL)
+ return 0;
+
+ id = syn_name2id(name);
+ vim_free(name);
return id;
}
@@ -3927,40 +3947,42 @@ set_context_in_highlight_cmd(expand_T *xp, char_u *arg)
include_link = 2;
include_default = 1;
+ if (*arg == NUL)
+ return;
+
// (part of) subcommand already typed
- if (*arg != NUL)
+ p = skiptowhite(arg);
+ if (*p == NUL)
+ return;
+
+ // past "default" or group name
+ include_default = 0;
+ if (STRNCMP("default", arg, p - arg) == 0)
{
+ arg = skipwhite(p);
+ xp->xp_pattern = arg;
p = skiptowhite(arg);
- if (*p != NUL) // past "default" or group name
+ }
+ if (*p == NUL)
+ return;
+
+ // past group name
+ include_link = 0;
+ if (arg[1] == 'i' && arg[0] == 'N')
+ highlight_list();
+ if (STRNCMP("link", arg, p - arg) == 0
+ || STRNCMP("clear", arg, p - arg) == 0)
+ {
+ xp->xp_pattern = skipwhite(p);
+ p = skiptowhite(xp->xp_pattern);
+ if (*p != NUL) // past first group name
{
- include_default = 0;
- if (STRNCMP("default", arg, p - arg) == 0)
- {
- arg = skipwhite(p);
- xp->xp_pattern = arg;
- p = skiptowhite(arg);
- }
- if (*p != NUL) // past group name
- {
- include_link = 0;
- if (arg[1] == 'i' && arg[0] == 'N')
- highlight_list();
- if (STRNCMP("link", arg, p - arg) == 0
- || STRNCMP("clear", arg, p - arg) == 0)
- {
- xp->xp_pattern = skipwhite(p);
- p = skiptowhite(xp->xp_pattern);
- if (*p != NUL) // past first group name
- {
- xp->xp_pattern = skipwhite(p);
- p = skiptowhite(xp->xp_pattern);
- }
- }
- if (*p != NUL) // past group name(s)
- xp->xp_context = EXPAND_NOTHING;
- }
+ xp->xp_pattern = skipwhite(p);
+ p = skiptowhite(xp->xp_pattern);
}
}
+ if (*p != NUL) // past group name(s)
+ xp->xp_context = EXPAND_NOTHING;
}
/*
diff --git a/src/version.c b/src/version.c
index 14d4f64fc..6bddfff3c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1166,
+/**/
1165,
/**/
1164,