Patch 8.2.2289
Problem: Vim9: 'cpo' can become empty.
Solution: Use empty_option instead of an empty string. Update quickfix
buffer after restoring 'cpo'. (closes #7608)
Files: src/evalfunc.c, src/syntax.c, src/eval.c, src/quickfix.c,
src/evalbuffer.c, src/ex_eval.c, src/gui_motif.c, src/map.c,
src/testdir/test_quickfix.vim
*** ../vim-8.2.2288/src/evalfunc.c 2020-12-28 12:56:54.179617297 +0100
--- src/evalfunc.c 2021-01-03 19:40:07.503140131 +0100
***************
*** 6316,6322 ****
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
rettv->vval.v_number = -1;
if (type == MATCH_LIST || type == MATCH_POS)
--- 6316,6322 ----
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = empty_option;
rettv->vval.v_number = -1;
if (type == MATCH_LIST || type == MATCH_POS)
***************
*** 8024,8031 ****
--- 8024,8037 ----
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
+ {
// Darn, evaluating the {skip} expression changed the value.
+ // If it's still empty it was changed and restored, need to restore in
+ // the complicated way.
+ if (*p_cpo == NUL)
+ set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
free_string_option(save_cpo);
+ }
return retval;
}
***************
*** 8723,8729 ****
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
--- 8729,8735 ----
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = empty_option;
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
*** ../vim-8.2.2288/src/syntax.c 2020-11-29 14:11:33.159022814 +0100
--- src/syntax.c 2021-01-03 19:41:50.346592075 +0100
***************
*** 5670,5676 ****
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
! p_cpo = (char_u *)"";
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
p_cpo = cpo_save;
--- 5670,5676 ----
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
! p_cpo = empty_option;
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
p_cpo = cpo_save;
***************
*** 5858,5864 ****
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
! p_cpo = (char_u *)"";
curwin->w_s->b_syn_linecont_prog =
vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC);
p_cpo = cpo_save;
--- 5858,5864 ----
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
! p_cpo = empty_option;
curwin->w_s->b_syn_linecont_prog =
vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC);
p_cpo = cpo_save;
*** ../vim-8.2.2288/src/eval.c 2021-01-01 21:05:51.222773812 +0100
--- src/eval.c 2021-01-03 19:38:29.071700147 +0100
***************
*** 1940,1946 ****
// avoid 'l' flag in 'cpoptions'
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL)
{
--- 1940,1946 ----
// avoid 'l' flag in 'cpoptions'
save_cpo = p_cpo;
! p_cpo = empty_option;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL)
{
***************
*** 6200,6207 ****
--- 6200,6213 ----
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
+ {
// Darn, evaluating {sub} expression or {expr} changed the value.
+ // If it's still empty it was changed and restored, need to restore in
+ // the complicated way.
+ if (*p_cpo == NUL)
+ set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
free_string_option(save_cpo);
+ }
return ret;
}
*** ../vim-8.2.2288/src/evalfunc.c 2020-12-28 12:56:54.179617297 +0100
--- src/evalfunc.c 2021-01-03 19:40:07.503140131 +0100
***************
*** 6316,6322 ****
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
rettv->vval.v_number = -1;
if (type == MATCH_LIST || type == MATCH_POS)
--- 6316,6322 ----
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = empty_option;
rettv->vval.v_number = -1;
if (type == MATCH_LIST || type == MATCH_POS)
***************
*** 8024,8031 ****
--- 8024,8037 ----
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
+ {
// Darn, evaluating the {skip} expression changed the value.
+ // If it's still empty it was changed and restored, need to restore in
+ // the complicated way.
+ if (*p_cpo == NUL)
+ set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
free_string_option(save_cpo);
+ }
return retval;
}
***************
*** 8723,8729 ****
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
--- 8729,8735 ----
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
! p_cpo = empty_option;
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
*** ../vim-8.2.2288/src/quickfix.c 2020-12-22 11:40:40.669481249 +0100
--- src/quickfix.c 2021-01-03 19:48:59.668580325 +0100
***************
*** 8099,8104 ****
--- 8099,8105 ----
int new_qi = FALSE;
char_u *au_name = NULL;
char_u *lang = NULL;
+ int updated = FALSE;
switch (eap->cmdidx)
{
***************
*** 8150,8163 ****
qfl->qf_ptr = qfl->qf_start;
qfl->qf_index = 1;
qf_list_changed(qfl);
! qf_update_buffer(qi, NULL);
}
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
! // Darn, some plugin changed the value.
free_string_option(save_cpo);
if (au_name != NULL)
{
--- 8151,8174 ----
qfl->qf_ptr = qfl->qf_start;
qfl->qf_index = 1;
qf_list_changed(qfl);
! updated = TRUE;
}
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
! {
! // Darn, some plugin changed the value. If it's still empty it was
! // changed and restored, need to restore in the complicated way.
! if (*p_cpo == NUL)
! set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
free_string_option(save_cpo);
+ }
+
+ if (updated)
+ // This may open a window and source scripts, do this after 'cpo' was
+ // restored.
+ qf_update_buffer(qi, NULL);
if (au_name != NULL)
{
*** ../vim-8.2.2288/src/evalbuffer.c 2021-01-02 13:53:55.345783905 +0100
--- src/evalbuffer.c 2021-01-03 19:38:54.179553553 +0100
***************
*** 68,74 ****
save_magic = p_magic;
p_magic = TRUE;
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
TRUE, FALSE, curtab_only));
--- 68,74 ----
save_magic = p_magic;
p_magic = TRUE;
save_cpo = p_cpo;
! p_cpo = empty_option;
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
TRUE, FALSE, curtab_only));
*** ../vim-8.2.2288/src/ex_eval.c 2020-12-19 17:55:50.810666202 +0100
--- src/ex_eval.c 2021-01-03 19:40:35.182989235 +0100
***************
*** 1695,1701 ****
*end = NUL;
}
save_cpo = p_cpo;
! p_cpo = (char_u *)"";
// Disable error messages, it will make current_exception
// invalid.
++emsg_off;
--- 1695,1701 ----
*end = NUL;
}
save_cpo = p_cpo;
! p_cpo = empty_option;
// Disable error messages, it will make current_exception
// invalid.
++emsg_off;
*** ../vim-8.2.2288/src/gui_motif.c 2020-11-05 20:50:45.331984998 +0100
--- src/gui_motif.c 2021-01-03 19:41:02.386843466 +0100
***************
*** 3525,3531 ****
char_u *save_cpo = p_cpo;
// No need to be Vi compatible here.
! p_cpo = (char_u *)"";
u_undo(1);
p_cpo = save_cpo;
gui_update_screen();
--- 3525,3531 ----
char_u *save_cpo = p_cpo;
// No need to be Vi compatible here.
! p_cpo = empty_options;
u_undo(1);
p_cpo = save_cpo;
gui_update_screen();
*** ../vim-8.2.2288/src/map.c 2020-12-18 19:49:52.341571870 +0100
--- src/map.c 2021-01-03 19:41:25.626720783 +0100
***************
*** 2475,2481 ****
char_u *s;
char_u *cpo_save = p_cpo;
! p_cpo = (char_u *)""; // Allow <> notation
s = vim_strsave(map);
if (s != NULL)
{
--- 2475,2481 ----
char_u *s;
char_u *cpo_save = p_cpo;
! p_cpo = empty_option; // Allow <> notation
s = vim_strsave(map);
if (s != NULL)
{
*** ../vim-8.2.2288/src/testdir/test_quickfix.vim 2020-12-16
21:02:51.642934141 +0100
--- src/testdir/test_quickfix.vim 2021-01-03 19:47:26.604988132 +0100
***************
*** 702,707 ****
--- 702,727 ----
call s:test_xhelpgrep('l')
endfunc
+ def Test_helpgrep_vim9_restore_cpo()
+ assert_equal('aABceFs', &cpo)
+
+ var rtp_save = &rtp
+ var dir = 'Xruntime/after'
+ &rtp ..= ',' .. dir
+ mkdir(dir .. '/ftplugin', 'p')
+ writefile(['vim9'], dir .. '/ftplugin/qf.vim')
+ filetype plugin on
+ silent helpgrep grail
+ cwindow
+ silent helpgrep grail
+
+ assert_equal('aABceFs', &cpo)
+ delete(dir, 'rf')
+ &rtp = rtp_save
+ cclose
+ helpclose
+ enddef
+
func Test_errortitle()
augroup QfBufWinEnter
au!
*** ../vim-8.2.2288/src/version.c 2021-01-03 18:33:09.992382498 +0100
--- src/version.c 2021-01-03 19:49:39.684408496 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2289,
/**/
--
% cat /usr/include/long_life.h
long life(double fun);
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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/202101031852.103IqaUC2208793%40masaka.moolenaar.net.