Patch 9.0.1166
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11792)
Files: src/autocmd.c, src/buffer.c, src/charset.c, src/cindent.c,
src/clientserver.c, src/cmdexpand.c, src/debugger.c, src/dict.c,
src/diff.c, src/digraph.c, src/edit.c, src/evalfunc.c,
src/evalwindow.c, src/ex_cmds.c, src/ex_cmds2.c, src/ex_getln.c,
src/filepath.c, src/findfile.c, src/fold.c, src/hardcopy.c,
src/highlight.c
*** ../vim-9.0.1165/src/autocmd.c 2022-12-09 12:21:46.473444271 +0000
--- src/autocmd.c 2023-01-09 18:57:32.888836973 +0000
***************
*** 1063,1080 ****
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);
! }
return group;
}
--- 1063,1080 ----
for (p = arg; *p && !VIM_ISWHITE(*p) && *p != '|'; ++p)
;
! 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;
}
*** ../vim-9.0.1165/src/buffer.c 2023-01-04 14:31:46.102074865 +0000
--- src/buffer.c 2023-01-09 18:57:32.888836973 +0000
***************
*** 357,390 ****
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
#endif
! if (retval == OK)
{
! // 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;
! // 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)
#ifdef FEAT_EVAL
! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL,
! FALSE, curbuf, &retval);
#else
! apply_autocmds(EVENT_BUFWINENTER, NULL, NULL,
! FALSE, curbuf);
#endif
! // restore curwin/curbuf and a few other things
! aucmd_restbuf(&aco);
! }
}
}
--- 357,390 ----
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
#endif
! 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)
{
! 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);
! if ((flags & READ_NOWINENTER) == 0)
#ifdef FEAT_EVAL
! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL,
! FALSE, curbuf, &retval);
#else
! apply_autocmds(EVENT_BUFWINENTER, NULL, NULL,
! FALSE, curbuf);
#endif
! // restore curwin/curbuf and a few other things
! aucmd_restbuf(&aco);
}
}
***************
*** 1761,1767 ****
}
}
-
return errormsg;
}
--- 1761,1766 ----
***************
*** 3019,3038 ****
char_u *p;
// extra check for valid arguments
! if (name != NULL && 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))
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);
! }
}
return match;
--- 3018,3037 ----
char_u *p;
// extra check for valid arguments
! 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)
! {
! // 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);
}
return match;
***************
*** 3160,3175 ****
{
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;
}
#endif
--- 3159,3173 ----
{
win_T *wp;
! 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,3224 ****
&& (!need_options || wip->wi_optset))
break;
// 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;
}
return wip;
}
--- 3196,3222 ----
&& (!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.
#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;
return wip;
}
*** ../vim-9.0.1165/src/charset.c 2022-12-19 13:30:34.315772238 +0000
--- src/charset.c 2023-01-09 18:57:32.888836973 +0000
***************
*** 345,368 ****
}
else
res = alloc(vim_strsize(s) + 1);
! if (res != NULL)
{
! *res = NUL;
! p = s;
! while (*p != NUL)
{
! 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;
! }
else
! STRCAT(res, transchar_byte(*p++));
}
}
return res;
}
--- 345,369 ----
}
else
res = alloc(vim_strsize(s) + 1);
!
! if (res == NULL)
! return NULL;
!
! *res = NUL;
! p = s;
! while (*p != NUL)
{
! 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;
}
+ else
+ STRCAT(res, transchar_byte(*p++));
}
return res;
}
*** ../vim-9.0.1165/src/cindent.c 2022-11-14 15:31:04.041587447 +0000
--- src/cindent.c 2023-01-09 18:57:32.888836973 +0000
***************
*** 46,66 ****
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
cinw_buf = alloc(cinw_len);
! if (cinw_buf != NULL)
{
! 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])))
! {
! retval = TRUE;
! break;
! }
}
- vim_free(cinw_buf);
}
return retval;
}
--- 46,66 ----
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
cinw_buf = alloc(cinw_len);
! if (cinw_buf == NULL)
! return FALSE;
!
! 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])))
{
! retval = TRUE;
! break;
}
}
+ vim_free(cinw_buf);
return retval;
}
***************
*** 644,686 ****
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;
! cursor_save = curwin->w_cursor;
! while (curwin->w_cursor.lnum > 1)
! {
! --curwin->w_cursor.lnum;
! // 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???
}
! return FALSE;
}
/*
--- 644,685 ----
if (cin_isscopedecl(s))
return FALSE;
! if (!cin_islabel_skip(&s))
! return FALSE;
! // 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;
! cursor_save = curwin->w_cursor;
! while (curwin->w_cursor.lnum > 1)
! {
! --curwin->w_cursor.lnum;
! // 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???
}
/*
***************
*** 1688,1705 ****
{
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;
! }
return trypos;
}
--- 1687,1704 ----
{
pos_T *trypos = find_match_paren(ind_maxparen);
! 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;
}
*** ../vim-9.0.1165/src/clientserver.c 2023-01-02 16:54:48.928860870 +0000
--- src/clientserver.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 157,178 ****
char_u *res = data;
*tofree = NULL;
! if (client_enc != NULL && p_enc != 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
--- 157,178 ----
char_u *res = data;
*tofree = NULL;
! if (client_enc == NULL || p_enc == NULL)
! return res;
!
! 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
*** ../vim-9.0.1165/src/cmdexpand.c 2022-12-10 10:22:25.873096527 +0000
--- src/cmdexpand.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 1850,1870 ****
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
{
! for (++arg; *arg && *arg != '/'; arg++)
! if (*arg == '\\' && arg[1] != NUL)
! arg++;
! if (*arg)
! {
! 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;
! }
}
return NULL;
--- 1850,1871 ----
find_cmd_after_isearch_cmd(expand_T *xp, char_u *arg)
{
arg = skipwhite(skipdigits(arg)); // skip count
! if (*arg != '/')
! return NULL;
!
! // Match regexp, not just whole words
! for (++arg; *arg && *arg != '/'; arg++)
! if (*arg == '\\' && arg[1] != NUL)
! arg++;
! if (*arg)
{
! 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;
}
return NULL;
***************
*** 2780,2786 ****
{
char *opts[] = {"expr", "file", "func", "here"};
! if (idx >=0 && idx <= 3)
{
// breakadd {expr, file, func, here}
if (breakpt_expand_what == EXP_BREAKPT_ADD)
--- 2781,2787 ----
{
char *opts[] = {"expr", "file", "func", "here"};
! if (idx >= 0 && idx <= 3)
{
// breakadd {expr, file, func, here}
if (breakpt_expand_what == EXP_BREAKPT_ADD)
*** ../vim-9.0.1165/src/debugger.c 2022-12-26 12:49:58.648390154 +0000
--- src/debugger.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 315,328 ****
char *p, *q;
int maxbacktrace = 0;
! if (sname != NULL)
{
! p = (char *)sname;
! while ((q = strstr(p, "..")) != NULL)
! {
! p = q + 2;
! maxbacktrace++;
! }
}
return maxbacktrace;
}
--- 315,328 ----
char *p, *q;
int maxbacktrace = 0;
! if (sname == NULL)
! return 0;
!
! p = (char *)sname;
! while ((q = strstr(p, "..")) != NULL)
{
! p = q + 2;
! maxbacktrace++;
}
return maxbacktrace;
}
***************
*** 486,506 ****
{
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;
}
/*
--- 486,505 ----
{
int prev_got_int;
! 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;
}
/*
*** ../vim-9.0.1165/src/dict.c 2023-01-02 18:10:00.015271225 +0000
--- src/dict.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 30,50 ****
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;
! }
return d;
}
--- 30,50 ----
dict_T *d;
d = ALLOC_CLEAR_ONE(dict_T);
! 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,240 ****
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;
! }
return di;
}
--- 228,240 ----
size_t len = STRLEN(key);
di = alloc(offsetof(dictitem_T, di_key) + len + 1);
! 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,259 ****
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);
! }
return di;
}
--- 248,259 ----
size_t len = STRLEN(org->di_key);
di = alloc(offsetof(dictitem_T, di_key) + len + 1);
! 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,355 ****
return NULL;
copy = dict_alloc();
! if (copy != NULL)
{
! 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);
! todo = (int)orig->dv_hashtab.ht_used;
! for (hi = orig->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
{
! if (!HASHITEM_EMPTY(hi))
! {
! --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)
{
! dictitem_free(di);
break;
}
}
}
! ++copy->dv_refcount;
! if (todo > 0)
! {
! dict_unref(copy);
! copy = NULL;
! }
}
return copy;
--- 303,355 ----
return NULL;
copy = dict_alloc();
! if (copy == NULL)
! return NULL;
!
! 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);
! todo = (int)orig->dv_hashtab.ht_used;
! for (hi = orig->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
! {
! if (!HASHITEM_EMPTY(hi))
{
! --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)
+ {
+ dictitem_free(di);
+ break;
+ }
}
+ }
! ++copy->dv_refcount;
! if (todo > 0)
! {
! dict_unref(copy);
! copy = NULL;
}
return copy;
*** ../vim-9.0.1165/src/diff.c 2022-12-26 12:49:58.648390154 +0000
--- src/diff.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 559,572 ****
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;
! }
return dnew;
}
--- 559,572 ----
diff_T *dnew;
dnew = ALLOC_ONE(diff_T);
! if (dnew == NULL)
! return NULL;
!
! dnew->df_next = dp;
! if (dprev == NULL)
! tp->tp_first_diff = dnew;
! else
! dprev->df_next = dnew;
return dnew;
}
*** ../vim-9.0.1165/src/digraph.c 2022-12-26 12:49:58.648390154 +0000
--- src/digraph.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 1533,1561 ****
c = plain_vgetc();
--no_mapping;
--allow_keys;
! if (c != ESC) // ESC cancels CTRL-K
{
! if (IS_SPECIAL(c)) // insert special key code
! return c;
! if (cmdline)
! {
! if (char2cells(c) == 1
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
! && 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);
}
return NUL;
}
--- 1533,1562 ----
c = plain_vgetc();
--no_mapping;
--allow_keys;
!
! if (c == ESC) // ESC cancels CTRL-K
! return NUL;
!
! if (IS_SPECIAL(c)) // insert special key code
! return c;
! if (cmdline)
{
! if (char2cells(c) == 1
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
! && 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);
return NUL;
}
*** ../vim-9.0.1165/src/edit.c 2023-01-01 18:03:55.476613184 +0000
--- src/edit.c 2023-01-09 18:57:32.892836970 +0000
***************
*** 2970,2981 ****
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;
! }
return s;
}
--- 2970,2981 ----
if (last_insert == NULL)
return NULL;
s = vim_strsave(last_insert + last_insert_skip);
! 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;
}
*** ../vim-9.0.1165/src/evalfunc.c 2023-01-02 18:10:00.019271226 +0000
--- src/evalfunc.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 2950,2971 ****
{
argcheck_T *argchecks = global_functions[idx].f_argcheck;
! if (argchecks != NULL)
! {
! 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;
}
--- 2950,2971 ----
{
argcheck_T *argchecks = global_functions[idx].f_argcheck;
! if (argchecks == NULL)
! return OK;
! 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,3488 ****
{
win_T *win = curwin;
! if (argvars[idx].v_type != VAR_UNKNOWN)
{
! win = find_win_by_nr_or_id(&argvars[idx]);
! if (win == NULL)
! {
! emsg(_(e_invalid_window_number));
! return NULL;
! }
}
return win;
}
--- 3475,3488 ----
{
win_T *win = curwin;
! if (argvars[idx].v_type == VAR_UNKNOWN)
! return curwin;
!
! win = find_win_by_nr_or_id(&argvars[idx]);
! if (win == NULL)
{
! emsg(_(e_invalid_window_number));
! return NULL;
}
return win;
}
***************
*** 8624,8666 ****
char_u nbuf[NUMBUFLEN];
int mask;
! if (varp->v_type != VAR_UNKNOWN)
! {
! flags = tv_get_string_buf_chk(varp, nbuf);
! if (flags == NULL)
! return 0; // type error; errmsg already given
! while (*flags != NUL)
! {
! 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)
{
! semsg(_(e_invalid_argument_str), flags);
! dir = 0;
}
! else
! *flagsp |= mask;
! }
! if (dir == 0)
! break;
! ++flags;
}
}
return dir;
}
--- 8624,8666 ----
char_u nbuf[NUMBUFLEN];
int mask;
! 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)
! {
! 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)
! {
! semsg(_(e_invalid_argument_str), flags);
! dir = 0;
! }
! else
! *flagsp |= mask;
}
+ if (dir == 0)
+ break;
+ ++flags;
}
return dir;
}
*** ../vim-9.0.1165/src/evalwindow.c 2023-01-02 16:54:48.932860868 +0000
--- src/evalwindow.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 24,52 ****
if (argvars[0].v_type == VAR_UNKNOWN)
return curwin->w_id;
winnr = tv_get_number(&argvars[0]);
! if (winnr > 0)
{
! if (argvars[1].v_type == VAR_UNKNOWN)
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;
}
return 0;
}
--- 24,52 ----
if (argvars[0].v_type == VAR_UNKNOWN)
return curwin->w_id;
winnr = tv_get_number(&argvars[0]);
! if (winnr <= 0)
! return 0;
!
! if (argvars[1].v_type == VAR_UNKNOWN)
! 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;
return 0;
}
***************
*** 380,397 ****
}
}
! if (nr > 0)
! for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
! wp != twin; wp = wp->w_next)
{
! if (wp == NULL)
! {
! // didn't find it in this tabpage
! nr = 0;
! break;
! }
! ++nr;
}
return nr;
}
--- 380,399 ----
}
}
! if (nr <= 0)
! return 0;
!
! for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
! wp != twin; wp = wp->w_next)
! {
! if (wp == NULL)
{
! // didn't find it in this tabpage
! nr = 0;
! break;
}
+ ++nr;
+ }
return nr;
}
*** ../vim-9.0.1165/src/ex_cmds.c 2022-12-30 18:07:41.690107581 +0000
--- src/ex_cmds.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 5279,5345 ****
need_mouse_correct = TRUE;
# endif
/*
* 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)
{
! 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);
! }
}
! 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.
! */
# ifdef FEAT_PROP_POPUP
! 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'
# ifdef FEAT_DIFF
! curwin->w_p_diff = FALSE; // no 'diff'
# endif
# ifdef FEAT_FOLDING
! curwin->w_p_fdc = 0; // no 'foldcolumn'
# endif
! return TRUE;
! }
! }
! return FALSE;
}
#endif
--- 5279,5345 ----
need_mouse_correct = TRUE;
# endif
+ if (curwin->w_p_pvw)
+ return FALSE;
+
/*
* If there is already a preview window open, use that one.
*/
# 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)
! {
! 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);
}
! }
! else
# endif
! {
! 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);
# 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'
# ifdef FEAT_DIFF
! curwin->w_p_diff = FALSE; // no 'diff'
# endif
# ifdef FEAT_FOLDING
! curwin->w_p_fdc = 0; // no 'foldcolumn'
# endif
! return TRUE;
}
#endif
*** ../vim-9.0.1165/src/ex_cmds2.c 2022-12-30 18:07:41.690107581 +0000
--- src/ex_cmds2.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 828,867 ****
lines = 5;
file = mch_fopen((char *)filename, "r");
! if (file != NULL)
{
! for (i = 0; i < lines; i++)
{
! 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)
{
requires_py_version = 2;
break;
}
! if (STRCMP("# requires python 3.x", IObuff) == 0)
{
requires_py_version = 3;
break;
}
}
! fclose(file);
}
return requires_py_version;
}
--- 828,867 ----
lines = 5;
file = mch_fopen((char *)filename, "r");
! if (file == NULL)
! return 0;
!
! for (i = 0; i < lines; i++)
{
! 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)
! {
! requires_py_version = 2;
! break;
! }
! if (STRCMP("# requires python 3.x", IObuff) == 0)
! {
! requires_py_version = 3;
! break;
! }
}
+ fclose(file);
return requires_py_version;
}
*** ../vim-9.0.1165/src/ex_getln.c 2023-01-02 16:54:48.932860868 +0000
--- src/ex_getln.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 4146,4161 ****
return NULL;
p = get_ccline_ptr();
! if (p != NULL && p->xpc != NULL)
! {
! char_u *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;
}
--- 4146,4161 ----
return NULL;
p = get_ccline_ptr();
! if (p == NULL || p->xpc == NULL)
! return NULL;
!
! char_u *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;
}
*** ../vim-9.0.1165/src/filepath.c 2022-10-19 14:02:34.961276576 +0100
--- src/filepath.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 3084,3096 ****
char_u *dest;
dest = alloc(STRLEN(fname1) + STRLEN(fname2) + 3);
! if (dest != NULL)
! {
! STRCPY(dest, fname1);
! if (sep)
! add_pathsep(dest);
! STRCAT(dest, fname2);
! }
return dest;
}
--- 3084,3096 ----
char_u *dest;
dest = alloc(STRLEN(fname1) + STRLEN(fname2) + 3);
! if (dest == NULL)
! return NULL;
!
! STRCPY(dest, fname1);
! if (sep)
! add_pathsep(dest);
! STRCAT(dest, fname2);
return dest;
}
***************
*** 3122,3135 ****
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);
! }
return new_fname;
}
--- 3122,3135 ----
return NULL;
buf = alloc(MAXPATHL);
! 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;
}
*** ../vim-9.0.1165/src/findfile.c 2023-01-08 13:44:21.065352366 +0000
--- src/findfile.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 1345,1377 ****
* 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)
- {
#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;
#endif
! 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;
! vp->ffv_next = *visited_list;
! *visited_list = vp;
! }
return OK;
}
--- 1345,1376 ----
* 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;
#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;
#endif
! 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;
! vp->ffv_next = *visited_list;
! *visited_list = vp;
return OK;
}
*** ../vim-9.0.1165/src/fold.c 2023-01-08 13:44:21.065352366 +0000
--- src/fold.c 2023-01-09 18:57:32.896836966 +0000
***************
*** 516,522 ****
if (*p_fcl == NUL)
return;
! // can only be "all" right now
checkupdate(curwin);
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
(int)curwin->w_p_fdl))
--- 516,522 ----
if (*p_fcl == NUL)
return;
! // 'foldclose' can only be "all" right now
checkupdate(curwin);
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
(int)curwin->w_p_fdl))
*** ../vim-9.0.1165/src/hardcopy.c 2022-11-07 12:16:46.397761740 +0000
--- src/hardcopy.c 2023-01-09 18:57:32.900836963 +0000
***************
*** 334,368 ****
static void
prt_set_fg(long_u fg)
{
! if (fg != curr_fg)
! {
! 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);
! }
}
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);
! }
}
/*
--- 334,368 ----
static void
prt_set_fg(long_u 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)
! 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)
! return;
!
! curr_underline = underline;
! curr_italic = italic;
! curr_bold = bold;
! mch_print_set_font(bold, italic, underline);
}
/*
***************
*** 434,446 ****
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;
! }
return u;
}
--- 434,448 ----
int i;
static char *(units[4]) = PRT_UNIT_NAMES;
! 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,1648 ****
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;
! }
! // 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);
! 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");
}
! // 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);
}
}
--- 1576,1650 ----
static void
prt_flush_buffer(void)
{
! if (prt_ps_buffer.ga_len <= 0)
! return;
! // 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;
}
!
! // 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);
! 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");
}
+ // 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,3458 ****
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;
! }
}
# endif //FEAT_POSTSCRIPT
--- 3449,3460 ----
void
mch_print_set_fg(long_u fgcol)
{
! if (fgcol == (long_u)prt_fgcol)
! return;
!
! prt_fgcol = (int)fgcol;
! prt_attribute_change = TRUE;
! prt_need_fgcol = TRUE;
}
# endif //FEAT_POSTSCRIPT
*** ../vim-9.0.1165/src/highlight.c 2023-01-02 18:10:00.019271226 +0000
--- src/highlight.c 2023-01-09 18:57:32.900836963 +0000
***************
*** 921,1013 ****
#endif
/*
* 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);
#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 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;
#ifdef FEAT_GUI
! // 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)
! {
! 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 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);
! }
! }
}
/*
--- 921,1033 ----
#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'.
*/
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)
! 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 mess with 'background' 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 the cterm background color for the highlight group at 'idx' to 'color'.
*/
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)
! 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 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);
}
}
/*
* Set the cterm underline color for the highlight group at 'idx' to 'color'.
*/
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)
! hl_set_ctermul_normal_group(color);
}
/*
***************
*** 1034,1123 ****
long i;
int off;
! if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM))
{
! 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)
{
! HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
! HL_TABLE()[idx].sg_cterm_bold = FALSE;
}
!
! 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
! {
! emsg(_(e_fg_color_unknown));
! return FALSE;
! }
}
! else if (STRICMP(arg, "bg") == 0)
{
! if (cterm_normal_bg_color > 0)
! color = cterm_normal_bg_color - 1;
! else
! {
! emsg(_(e_bg_color_unknown));
! return FALSE;
! }
}
! else if (STRICMP(arg, "ul") == 0)
{
! if (cterm_normal_ul_color > 0)
! color = cterm_normal_ul_color - 1;
! else
! {
! emsg(_(e_ul_color_unknown));
! 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);
!
! // 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;
! }
!
! // 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;
}
--- 1054,1143 ----
long i;
int off;
! 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)
{
! HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
! HL_TABLE()[idx].sg_cterm_bold = FALSE;
! }
! 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
{
! emsg(_(e_fg_color_unknown));
! return FALSE;
}
! }
! else if (STRICMP(arg, "bg") == 0)
! {
! if (cterm_normal_bg_color > 0)
! color = cterm_normal_bg_color - 1;
! else
{
! emsg(_(e_bg_color_unknown));
! return FALSE;
}
! }
! else if (STRICMP(arg, "ul") == 0)
! {
! if (cterm_normal_ul_color > 0)
! color = cterm_normal_ul_color - 1;
! else
{
! emsg(_(e_ul_color_unknown));
! 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);
! // 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;
}
+ // 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,1192 ****
char_u **namep;
int did_change = 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 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;
# 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)
# 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;
! }
# ifdef FEAT_BEVAL_GUI
! if (is_tooltip_group && gui.tooltip_fg_pixel != i)
! {
! gui.tooltip_fg_pixel = i;
! *do_colors = TRUE;
! }
# endif
# endif
- }
- # endif
}
return did_change;
}
--- 1162,1212 ----
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 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;
# 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)
# 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;
! }
# ifdef FEAT_BEVAL_GUI
! if (is_tooltip_group && gui.tooltip_fg_pixel != i)
! {
! gui.tooltip_fg_pixel = i;
! *do_colors = TRUE;
! }
# endif
# endif
}
+ # endif
return did_change;
}
***************
*** 1211,1261 ****
char_u **namep;
int did_change = 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 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;
# 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)
# 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;
! }
# ifdef FEAT_BEVAL_GUI
! if (is_tooltip_group && gui.tooltip_bg_pixel != i)
! {
! gui.tooltip_bg_pixel = i;
! *do_colors = TRUE;
! }
# endif
# endif
- }
- # endif
}
return did_change;
}
--- 1231,1281 ----
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 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;
# 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)
# 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;
! }
# ifdef FEAT_BEVAL_GUI
! if (is_tooltip_group && gui.tooltip_bg_pixel != i)
! {
! gui.tooltip_bg_pixel = i;
! *do_colors = TRUE;
! }
# endif
# endif
}
+ # endif
return did_change;
}
***************
*** 1273,1304 ****
int did_change = FALSE;
char_u **namep;
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 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;
# 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)
}
! # endif
}
return did_change;
}
--- 1293,1324 ----
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 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;
# 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)
}
+ # endif
return did_change;
}
***************
*** 1995,2015 ****
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;
}
/*
--- 2015,2034 ----
int idx;
idx = syn_name2id(name) - 1;
! 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,2052 ****
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);
! }
}
/*
--- 2061,2071 ----
int id;
id = syn_name2id((char_u *)"Normal");
! 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,2073 ****
{
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;
! }
! }
}
/*
--- 2078,2092 ----
{
int id;
! 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,2094 ****
{
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;
! }
! }
}
/*
--- 2099,2113 ----
{
int id;
! 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,3012 ****
if (got_int)
return FALSE;
! if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0))
{
! 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)
{
! 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"
! }
}
}
! (void)syn_list_header(didh,
! (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
! didh = TRUE;
! if (!got_int)
{
! if (*name != NUL)
! {
! msg_puts_attr(name, HL_ATTR(HLF_D));
! msg_puts_attr("=", HL_ATTR(HLF_D));
! }
! msg_outtrans(ts);
}
}
return didh;
}
--- 2992,3032 ----
if (got_int)
return FALSE;
!
! 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
{
! buf[0] = NUL;
! for (i = 0; hl_attr_table[i] != 0; ++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"
}
}
+ }
! (void)syn_list_header(didh,
! (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
! didh = TRUE;
! if (!got_int)
! {
! if (*name != NUL)
{
! msg_puts_attr(name, HL_ATTR(HLF_D));
! msg_puts_attr("=", HL_ATTR(HLF_D));
}
+ msg_outtrans(ts);
}
return didh;
}
***************
*** 3380,3390 ****
int id = 0;
name = vim_strnsave(linep, len);
! if (name != NULL)
! {
! id = syn_name2id(name);
! vim_free(name);
! }
return id;
}
--- 3400,3410 ----
int id = 0;
name = vim_strnsave(linep, len);
! if (name == NULL)
! return 0;
!
! id = syn_name2id(name);
! vim_free(name);
return id;
}
***************
*** 3927,3966 ****
include_link = 2;
include_default = 1;
// (part of) subcommand already typed
! if (*arg != NUL)
{
p = skiptowhite(arg);
! if (*p != NUL) // 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 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;
! }
}
}
}
/*
--- 3947,3988 ----
include_link = 2;
include_default = 1;
+ if (*arg == NUL)
+ return;
+
// (part of) subcommand already typed
! 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)
! 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
{
! xp->xp_pattern = skipwhite(p);
! p = skiptowhite(xp->xp_pattern);
}
}
+ if (*p != NUL) // past group name(s)
+ xp->xp_context = EXPAND_NOTHING;
}
/*
*** ../vim-9.0.1165/src/version.c 2023-01-09 16:25:55.570919210 +0000
--- src/version.c 2023-01-09 18:58:47.080775463 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1166,
/**/
--
Never under any circumstances take a sleeping pill
and a laxative on the same night.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230109190459.A7BEB1C044B%40moolenaar.net.