0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2289: Vim9: 'cpo' can become empty

Problem:    Vim9: 'cpo' can become empty.
Solution:   Use empty_option instead of an empty string.  Update quickfix
            buffer after restoring 'cpo'.  (closes #7608)
This commit is contained in:
Bram Moolenaar
2021-01-03 19:52:05 +01:00
parent 5afd081cd3
commit e5a2dc87fd
10 changed files with 56 additions and 11 deletions

View File

@@ -1940,7 +1940,7 @@ pattern_match(char_u *pat, char_u *text, int ic)
// avoid 'l' flag in 'cpoptions'
save_cpo = p_cpo;
p_cpo = (char_u *)"";
p_cpo = empty_option;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL)
{
@@ -6200,8 +6200,14 @@ do_string_sub(
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;
}